diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 67 |
1 files changed, 47 insertions, 20 deletions
@@ -6,27 +6,31 @@ export DEPLOY_TARGET = vulpes@94.130.78.123:/srv/http/volpeon.ink/ | |||
6 | # FILE GROUPS | 6 | # FILE GROUPS |
7 | # | 7 | # |
8 | 8 | ||
9 | PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua)) | 9 | PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua)) |
10 | GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml)) | 10 | GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml)) |
11 | 11 | ||
12 | CONTENT_SRC := $(shell find content -type f -name "*.md") | 12 | CONTENT_SRC := $(shell find content -type f -name "*.md") |
13 | TEMPLATES_SRC := $(shell find templates -type f -name "*.html") | 13 | FEED_SRC := $(shell grep -l "^create_feed: *true$$" $(CONTENT_SRC)) |
14 | CSS_SRC := $(shell find assets/css -type f -name "*.scss") | 14 | CONTENT_TEMPLATES_SRC := $(shell find templates -type f -name "*.html") |
15 | 15 | FEED_TEMPLATES_SRC := $(shell find templates -type f -name "*.xml") | |
16 | CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC)) | 16 | CSS_SRC := $(shell find assets/css -type f -name "*.scss") |
17 | CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC)) | 17 | |
18 | FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) | 18 | CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC)) |
19 | CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss)) | 19 | CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC)) |
20 | STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) | 20 | FEED_FILES := $(patsubst content/%.md,out/%.xml,$(FEED_SRC)) |
21 | FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) | ||
22 | CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss)) | ||
23 | STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) | ||
21 | 24 | ||
22 | # | 25 | # |
23 | # TARGETS | 26 | # TARGETS |
24 | # | 27 | # |
25 | 28 | ||
26 | all: content_meta content_files static_files font_files css_files | 29 | all: content_meta content_files feed_files static_files font_files css_files |
27 | 30 | ||
28 | content_meta: $(CONTENT_META) | 31 | content_meta: $(CONTENT_META) |
29 | content_files: $(CONTENT_FILES) | 32 | content_files: $(CONTENT_FILES) |
33 | feed_files: $(FEED_FILES) | ||
30 | static_files: $(STATIC_FILES) | 34 | static_files: $(STATIC_FILES) |
31 | font_files: $(FONT_FILES) | 35 | font_files: $(FONT_FILES) |
32 | css_files: $(CSS_FILES) | 36 | css_files: $(CSS_FILES) |
@@ -43,14 +47,13 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ | |||
43 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \ | 47 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \ |
44 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md")) | 48 | $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md")) |
45 | 49 | ||
46 | .cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq | .cache/meta | 50 | .cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq scripts/metadata_tpl.json | .cache/meta |
47 | $(info [META] $< -> $@) | 51 | $(info [META] $< -> $@) |
48 | 52 | ||
49 | mkdir -p $(@D) | 53 | mkdir -p $(@D) |
50 | $(eval PAGES_FILES = $(filter .cache/meta/%.json,$^)) | 54 | $(eval PAGES_FILES = $(filter .cache/meta/%.json,$^)) |
51 | $(eval PAGES = $(shell mktemp)) | ||
52 | $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) | 55 | $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) |
53 | $(file >$(PAGES),$(if $(PAGES_FILES),$(shell jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES)),)) | 56 | $(if $(PAGES_FILES),jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES) > "$@.pages",touch "$@.pages") |
54 | pandoc \ | 57 | pandoc \ |
55 | -f markdown-citations \ | 58 | -f markdown-citations \ |
56 | -t plain \ | 59 | -t plain \ |
@@ -58,11 +61,18 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ | |||
58 | --template scripts/metadata_tpl.json \ | 61 | --template scripts/metadata_tpl.json \ |
59 | --metadata namespace="$(NAMESPACE)" \ | 62 | --metadata namespace="$(NAMESPACE)" \ |
60 | --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \ | 63 | --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \ |
61 | --metadata-file "$(PAGES)" \ | 64 | --metadata-file "$@.pages" \ |
62 | -o "$@" "$<" | 65 | -o "$@" "$<" |
63 | rm "$(PAGES)" | 66 | # pandoc \ |
64 | 67 | -f markdown-citations \ | |
65 | out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua out/style.css | out | 68 | -t markdown \ |
69 | -o "$@.content" "$<" | ||
70 | # jq '. + { content: $$content }' --rawfile content "$@.content" "$@.meta" > "$@" | ||
71 | rm "$@.pages" | ||
72 | # rm "$@.meta" | ||
73 | # rm "$@.content" | ||
74 | |||
75 | out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua out/style.css | out | ||
66 | $(info [MARK] $< -> $@) | 76 | $(info [MARK] $< -> $@) |
67 | 77 | ||
68 | mkdir -p $(@D) | 78 | mkdir -p $(@D) |
@@ -74,10 +84,27 @@ out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml fil | |||
74 | --lua-filter scripts/metadata_filter.lua \ | 84 | --lua-filter scripts/metadata_filter.lua \ |
75 | $(GLOBAL_METADATA) \ | 85 | $(GLOBAL_METADATA) \ |
76 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ | 86 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ |
87 | --metadata file_out="$@" \ | ||
77 | --metadata style_hash="$(shell sha256sum out/style.css | cut -d ' ' -f 1)" \ | 88 | --metadata style_hash="$(shell sha256sum out/style.css | cut -d ' ' -f 1)" \ |
78 | $(PANDOC_FILTERS) \ | 89 | $(PANDOC_FILTERS) \ |
79 | -o "$@" "$<" | 90 | -o "$@" "$<" |
80 | 91 | ||
92 | out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out | ||
93 | $(info [FEED] $< -> $@) | ||
94 | |||
95 | mkdir -p $(@D) | ||
96 | pandoc \ | ||
97 | -f markdown-citations \ | ||
98 | -t html5 \ | ||
99 | --no-highlight \ | ||
100 | --template templates/feed.xml \ | ||
101 | --lua-filter scripts/metadata_filter.lua \ | ||
102 | $(GLOBAL_METADATA) \ | ||
103 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ | ||
104 | --metadata file_out="$@" \ | ||
105 | $(PANDOC_FILTERS) \ | ||
106 | -o "$@" "$<" | ||
107 | |||
81 | out/%: content/% | out | 108 | out/%: content/% | out |
82 | $(info [COPY] $< -> $@) | 109 | $(info [COPY] $< -> $@) |
83 | 110 | ||