From e3240a57eef6bf0afa193ae83ecd8c5cf627c72f Mon Sep 17 00:00:00 2001 From: Volpeon Date: Wed, 26 May 2021 08:54:19 +0200 Subject: Category list improvements, generate ATOM feeds --- Makefile | 67 +++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index aa4ecf3..b4a58e8 100644 --- a/Makefile +++ b/Makefile @@ -6,27 +6,31 @@ export DEPLOY_TARGET = vulpes@94.130.78.123:/srv/http/volpeon.ink/ # FILE GROUPS # -PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua)) -GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml)) - -CONTENT_SRC := $(shell find content -type f -name "*.md") -TEMPLATES_SRC := $(shell find templates -type f -name "*.html") -CSS_SRC := $(shell find assets/css -type f -name "*.scss") - -CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC)) -CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC)) -FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) -CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss)) -STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) +PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua)) +GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml)) + +CONTENT_SRC := $(shell find content -type f -name "*.md") +FEED_SRC := $(shell grep -l "^create_feed: *true$$" $(CONTENT_SRC)) +CONTENT_TEMPLATES_SRC := $(shell find templates -type f -name "*.html") +FEED_TEMPLATES_SRC := $(shell find templates -type f -name "*.xml") +CSS_SRC := $(shell find assets/css -type f -name "*.scss") + +CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC)) +CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC)) +FEED_FILES := $(patsubst content/%.md,out/%.xml,$(FEED_SRC)) +FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) +CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss)) +STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) # # TARGETS # -all: content_meta content_files static_files font_files css_files +all: content_meta content_files feed_files static_files font_files css_files content_meta: $(CONTENT_META) content_files: $(CONTENT_FILES) +feed_files: $(FEED_FILES) static_files: $(STATIC_FILES) font_files: $(FONT_FILES) css_files: $(CSS_FILES) @@ -43,14 +47,13 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \ $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md")) -.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq | .cache/meta +.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq scripts/metadata_tpl.json | .cache/meta $(info [META] $< -> $@) mkdir -p $(@D) $(eval PAGES_FILES = $(filter .cache/meta/%.json,$^)) - $(eval PAGES = $(shell mktemp)) $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) - $(file >$(PAGES),$(if $(PAGES_FILES),$(shell jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES)),)) + $(if $(PAGES_FILES),jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES) > "$@.pages",touch "$@.pages") pandoc \ -f markdown-citations \ -t plain \ @@ -58,11 +61,18 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ --template scripts/metadata_tpl.json \ --metadata namespace="$(NAMESPACE)" \ --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \ - --metadata-file "$(PAGES)" \ + --metadata-file "$@.pages" \ -o "$@" "$<" - rm "$(PAGES)" - -out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua out/style.css | out +# pandoc \ + -f markdown-citations \ + -t markdown \ + -o "$@.content" "$<" +# jq '. + { content: $$content }' --rawfile content "$@.content" "$@.meta" > "$@" + rm "$@.pages" +# rm "$@.meta" +# rm "$@.content" + +out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua out/style.css | out $(info [MARK] $< -> $@) mkdir -p $(@D) @@ -74,10 +84,27 @@ out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml fil --lua-filter scripts/metadata_filter.lua \ $(GLOBAL_METADATA) \ --metadata-file "$(filter .cache/meta/%.json,$^)" \ + --metadata file_out="$@" \ --metadata style_hash="$(shell sha256sum out/style.css | cut -d ' ' -f 1)" \ $(PANDOC_FILTERS) \ -o "$@" "$<" +out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out + $(info [FEED] $< -> $@) + + mkdir -p $(@D) + pandoc \ + -f markdown-citations \ + -t html5 \ + --no-highlight \ + --template templates/feed.xml \ + --lua-filter scripts/metadata_filter.lua \ + $(GLOBAL_METADATA) \ + --metadata-file "$(filter .cache/meta/%.json,$^)" \ + --metadata file_out="$@" \ + $(PANDOC_FILTERS) \ + -o "$@" "$<" + out/%: content/% | out $(info [COPY] $< -> $@) -- cgit v1.2.3-70-g09d2