diff options
| author | Volpeon <git@volpeon.ink> | 2022-06-20 18:32:44 +0200 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2022-06-20 18:32:44 +0200 |
| commit | cfa66c5ec0fe8d948df16bf3ce17291e9913b2a8 (patch) | |
| tree | b206ef9448e6e900703792262f32dc91ed39e5e5 /Makefile | |
| parent | WIP: Hashing all static assets (diff) | |
| download | volpeon.ink-cfa66c5ec0fe8d948df16bf3ce17291e9913b2a8.tar.gz volpeon.ink-cfa66c5ec0fe8d948df16bf3ce17291e9913b2a8.tar.bz2 volpeon.ink-cfa66c5ec0fe8d948df16bf3ce17291e9913b2a8.zip | |
Add hash to more assets
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 35 |
1 files changed, 21 insertions, 14 deletions
| @@ -21,19 +21,20 @@ FEED_FILES := $(patsubst content/%.md,out/%.xml,$(FEED_SRC)) | |||
| 21 | FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf)) | 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)) | 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")) | 23 | STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md")) |
| 24 | ASSET_FILES := $(FONT_FILES) $(CSS_FILES) out/icons.svg $(patsubst content/%,out/%,$(shell find content -maxdepth 1 -type f ! -name "*.md")) | ||
| 24 | 25 | ||
| 25 | # | 26 | # |
| 26 | # TARGETS | 27 | # TARGETS |
| 27 | # | 28 | # |
| 28 | 29 | ||
| 29 | all: content_meta content_files feed_files static_files font_files css_files icons | 30 | all: content_meta content_files feed_files font_files css_files static_files |
| 30 | 31 | ||
| 31 | content_meta: $(CONTENT_META) | 32 | content_meta: $(CONTENT_META) |
| 32 | content_files: $(CONTENT_FILES) | 33 | content_files: $(CONTENT_FILES) |
| 33 | feed_files: $(FEED_FILES) | 34 | feed_files: $(FEED_FILES) |
| 34 | static_files: $(STATIC_FILES) | ||
| 35 | font_files: $(FONT_FILES) | 35 | font_files: $(FONT_FILES) |
| 36 | css_files: $(CSS_FILES) | 36 | css_files: $(CSS_FILES) |
| 37 | static_files: $(STATIC_FILES) | ||
| 37 | 38 | ||
| 38 | # | 39 | # |
| 39 | # RULES | 40 | # RULES |
| @@ -65,6 +66,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ | |||
| 65 | --metadata-file "$@.pages" \ | 66 | --metadata-file "$@.pages" \ |
| 66 | $(PANDOC_FILTERS) \ | 67 | $(PANDOC_FILTERS) \ |
| 67 | -o "$@.meta" "$<" | 68 | -o "$@.meta" "$<" |
| 69 | rm "$@.pages" | ||
| 68 | pandoc \ | 70 | pandoc \ |
| 69 | -f markdown-citations-implicit_figures \ | 71 | -f markdown-citations-implicit_figures \ |
| 70 | -t html5 \ | 72 | -t html5 \ |
| @@ -77,11 +79,13 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ | |||
| 77 | $(PANDOC_FILTERS) \ | 79 | $(PANDOC_FILTERS) \ |
| 78 | -o "$@.content" "$<" | 80 | -o "$@.content" "$<" |
| 79 | jq '. + { content: $$content }' --rawfile content "$@.content" "$@.meta" > "$@" | 81 | jq '. + { content: $$content }' --rawfile content "$@.content" "$@.meta" > "$@" |
| 80 | rm "$@.pages" | ||
| 81 | rm "$@.meta" | 82 | rm "$@.meta" |
| 82 | rm "$@.content" | 83 | rm "$@.content" |
| 83 | 84 | ||
| 84 | out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua out/style.css | out | 85 | .cache/assets.json: $(ASSET_FILES) | .cache |
| 86 | sha256sum $^ | sed -r 's/([0-9a-f]+) +out\/(.*)/{ "\2": "\/\2?\1" }/' | jq '{ assets: [inputs] | add | with_entries( .key |= gsub( "\\."; "_") ) }' > "$@" | ||
| 87 | |||
| 88 | out/%.html: content/%.md .cache/meta/%.json .cache/assets.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out | ||
| 85 | $(info [MARK] $< -> $@) | 89 | $(info [MARK] $< -> $@) |
| 86 | 90 | ||
| 87 | mkdir -p $(@D) | 91 | mkdir -p $(@D) |
| @@ -93,9 +97,9 @@ out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*. | |||
| 93 | --template templates/base.html \ | 97 | --template templates/base.html \ |
| 94 | --lua-filter scripts/metadata_filter.lua \ | 98 | --lua-filter scripts/metadata_filter.lua \ |
| 95 | $(GLOBAL_METADATA) \ | 99 | $(GLOBAL_METADATA) \ |
| 100 | --metadata-file .cache/assets.json \ | ||
| 96 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ | 101 | --metadata-file "$(filter .cache/meta/%.json,$^)" \ |
| 97 | --metadata file_out="$@" \ | 102 | --metadata file_out="$@" \ |
| 98 | --metadata style_hash="$(shell sha256sum out/style.css | cut -d ' ' -f 1)" \ | ||
| 99 | $(PANDOC_FILTERS) \ | 103 | $(PANDOC_FILTERS) \ |
| 100 | -o "$@" "$<" | 104 | -o "$@" "$<" |
| 101 | 105 | ||
| @@ -140,14 +144,8 @@ out/%.css: assets/css/%.scss $(CSS_SRC) | out | |||
| 140 | 144 | ||
| 141 | sass --load-path=node_modules "$<" | ./node_modules/.bin/postcss --use autoprefixer --no-map -o "$@" | 145 | sass --load-path=node_modules "$<" | ./node_modules/.bin/postcss --use autoprefixer --no-map -o "$@" |
| 142 | 146 | ||
| 143 | out/%: content/% | out | 147 | out/icons.svg: | out |
| 144 | $(info [COPY] $< -> $@) | 148 | $(info [ICON] $@) |
| 145 | |||
| 146 | mkdir -p $(@D) | ||
| 147 | cp "$<" "$@" | ||
| 148 | |||
| 149 | icons: | out | ||
| 150 | $(info [ICON] out/icons.svg) | ||
| 151 | 149 | ||
| 152 | node ./node_modules/iro-icons/scripts/create_sprite.js \ | 150 | node ./node_modules/iro-icons/scripts/create_sprite.js \ |
| 153 | asterisk \ | 151 | asterisk \ |
| @@ -168,7 +166,16 @@ icons: | out | |||
| 168 | x \ | 166 | x \ |
| 169 | chevron-left \ | 167 | chevron-left \ |
| 170 | chevron-right \ | 168 | chevron-right \ |
| 171 | "out/icons.svg" | 169 | "$@" |
| 170 | |||
| 171 | out/%: content/% | out | ||
| 172 | $(info [COPY] $< -> $@) | ||
| 173 | |||
| 174 | mkdir -p $(@D) | ||
| 175 | cp "$<" "$@" | ||
| 176 | |||
| 177 | .cache/hash: | .cache | ||
| 178 | mkdir -p .cache/hash | ||
| 172 | 179 | ||
| 173 | .cache/meta: | .cache | 180 | .cache/meta: | .cache |
| 174 | mkdir -p .cache/meta | 181 | mkdir -p .cache/meta |
