summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-05-10 16:41:05 +0200
committerVolpeon <git@volpeon.ink>2021-05-10 16:41:05 +0200
commita48d05d1d5fcff414359c8ba6cc8f38467aebdeb (patch)
tree3542bf116c910a1bb42b40d8531f60c2c2498b08 /Makefile
parentUpdate (diff)
downloadvolpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.tar.gz
volpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.tar.bz2
volpeon.ink-a48d05d1d5fcff414359c8ba6cc8f38467aebdeb.zip
Refactoring to fully take advantage of Make
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile146
1 files changed, 109 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index db7db81..a42f693 100644
--- a/Makefile
+++ b/Makefile
@@ -1,55 +1,127 @@
1all: build 1export DEPLOY_TARGET = "vulpes@94.130.78.123:/srv/http/volpeon.ink/"
2 2
3clean: 3-include Env.mk
4 @mkdir -p output 4
5 @rm -rf output/* 5#
6# FILE GROUPS
7#
8
9PANDOC_FILTERS := $(patsubst %,--lua-filter %,$(wildcard filters/*.lua))
10GLOBAL_METADATA := $(patsubst %,--metadata-file %,$(wildcard metadata/*.yaml))
11
12CONTENT_SRC := $(shell find content -type f -name "*.md")
13TEMPLATES_SRC := $(shell find templates -type f -name "*.html")
14CSS_SRC := $(shell find assets/css -type f -name "*.scss")
15
16CONTENT_META := $(patsubst content/%.md,.cache/meta/%.json,$(CONTENT_SRC))
17CONTENT_FILES := $(patsubst content/%.md,out/%.html,$(CONTENT_SRC))
18FONT_FILES := $(patsubst assets/fonts/%.ttf,out/%.woff2,$(wildcard assets/fonts/*.ttf))
19CSS_FILES := $(patsubst assets/css/%.scss,out/%.css,$(wildcard assets/css/style.scss))
20STATIC_FILES := $(patsubst content/%,out/%,$(shell find content -type f ! -name "*.md"))
21
22#
23# TARGETS
24#
6 25
7build_fonts: clean 26all: content_meta content_files static_files font_files css_files
8 @scripts/build_fonts.sh
9 27
10build_sass: clean 28content_meta: $(CONTENT_META)
11 @scripts/build_sass.sh 29content_files: $(CONTENT_FILES)
30static_files: $(STATIC_FILES)
31font_files: $(FONT_FILES)
32css_files: $(CSS_FILES)
12 33
13build_content: clean 34#
14 @scripts/build_content.sh 35# RULES
36#
15 37
16build_only: build_fonts build_sass build_content 38.SECONDEXPANSION:
17 39
18compress_gz: build_only 40namespace = $(patsubst %/index,%,$(patsubst %.json,%,$(patsubst $(2)%,%,$(1))))
19 @echo -e "\033[0;32m[COMPRESS]\033[0m Gzip"
20 @pigz -R -k -9 -- `find output -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\)'`
21 41
22compress_br: build_only 42subpages = $(patsubst content/%.md,.cache/meta/%.json, \
23 @echo -e "\033[0;32m[COMPRESS]\033[0m Brotli" 43 $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \
24 @brotli -k -- `find output -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\|woff\\)'` 44 $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md"))
25 45
26build: export LIVE=false 46.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq | .cache/meta
27build: compress_gz compress_br 47 $(info [META] $< -> $@)
48
49 mkdir -p $(@D)
50 $(eval PAGES_FILES = $(filter .cache/meta/%.json,$^))
51 $(eval PAGES = $(shell mktemp))
52 $(eval NAMESPACE = $(call namespace,$@,.cache/meta))
53 $(file >$(PAGES),$(if $(PAGES_FILES),$(shell jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES)),))
54 pandoc \
55 -f markdown-citations \
56 -t plain \
57 --no-highlight \
58 --template scripts/metadata_tpl.json \
59 --metadata namespace="$(NAMESPACE)" \
60 --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \
61 --metadata-file "$(PAGES)" \
62 -o "$@" "$<"
63 rm "$(PAGES)"
28 64
29watch_sass: build_only 65out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out
30 @scripts/watch_sass.sh 66 $(info [MARK] $< -> $@)
67
68 mkdir -p $(@D)
69 pandoc \
70 -f markdown-citations \
71 -t html5 \
72 --no-highlight \
73 --template templates/base.html \
74 --lua-filter scripts/metadata_filter.lua \
75 $(GLOBAL_METADATA) \
76 --metadata-file "$(filter .cache/meta/%.json,$^)" \
77 $(PANDOC_FILTERS) \
78 -o "$@" "$<"
31 79
32watch_content: build_only 80out/%: content/% | out
33 @scripts/watch_content.sh 81 $(info [COPY] $< -> $@)
34 82
35watch_templates: build_only 83 mkdir -p $(@D)
36 @scripts/watch_templates.sh 84 cp "$<" "$@"
37 85
38watch_metadata: build_only 86out/%.woff2: assets/fonts/%.ttf assets/fonts/glyphs.txt | out
39 @scripts/watch_metadata.sh 87 $(info [FONT] $< -> $@)
88
89 pyftsubset "$<" \
90 --text-file="assets/fonts/glyphs.txt" \
91 --layout-features+=ss02,ss09,dlig \
92 --flavor="woff2" \
93 --output-file="$@"
40 94
41watch_filters: build_only 95out/%.css: assets/css/%.scss $(CSS_SRC) | out
42 @scripts/watch_filters.sh 96 $(info [SCSS] $< -> $@)
43 97
44watch: export LIVE=true 98 sassc -t compressed "$<" | ./node_modules/.bin/postcss --use autoprefixer --no-map > "$@"
45watch: watch_sass watch_content watch_templates watch_metadata watch_filters
46 99
47serve_only: build_only 100.cache/meta: .cache
48 @python -m http.server --bind 127.0.0.1 --directory output 101 mkdir -p .cache/meta
49 102
50serve: watch serve_only 103.cache/pages: .cache
104 mkdir -p .cache/pages
51 105
52deploy: build 106.cache:
53 @scripts/deploy.sh 107 mkdir -p .cache
54 108
55.PHONY: all clean build watch serve deploy 109out:
110 mkdir -p out
111
112#
113# UTILITIES
114#
115
116compress: all
117 pigz -R -k -9 -- `find out -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\)'`
118 brotli -k -- `find out -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\|woff\\)'`
119
120serve: all
121 python -m http.server --directory out 8000
122
123#deploy: compress
124# rsync --progress --stats -rvz --delete out "$(DEPLOY_TARGET)"
125
126clean:
127 rm -rf out