summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile178
1 files changed, 125 insertions, 53 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
3-include Env.mk
4
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#
25
26all: content_meta content_files static_files font_files css_files
27
28content_meta: $(CONTENT_META)
29content_files: $(CONTENT_FILES)
30static_files: $(STATIC_FILES)
31font_files: $(FONT_FILES)
32css_files: $(CSS_FILES)
33
34#
35# RULES
36#
37
38.SECONDEXPANSION:
39
40namespace = $(patsubst %/index,%,$(patsubst %.json,%,$(patsubst $(2)%,%,$(1))))
41
42subpages = $(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") \
44 $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md"))
45
46.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) scripts/subpages.jq | .cache/meta
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)"
64
65out/%.html: content/%.md .cache/meta/%.json $(TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata_filter.lua | out
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 "$@" "$<"
79
80out/%: content/% | out
81 $(info [COPY] $< -> $@)
82
83 mkdir -p $(@D)
84 cp "$<" "$@"
85
86out/%.woff2: assets/fonts/%.ttf assets/fonts/glyphs.txt | out
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="$@"
94
95out/%.css: assets/css/%.scss $(CSS_SRC) | out
96 $(info [SCSS] $< -> $@)
97
98 sassc -t compressed "$<" | ./node_modules/.bin/postcss --use autoprefixer --no-map > "$@"
99
100.cache/meta: .cache
101 mkdir -p .cache/meta
102
103.cache/pages: .cache
104 mkdir -p .cache/pages
105
106.cache:
107 mkdir -p .cache
108
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)"
2 125
3clean: 126clean:
4 @mkdir -p output 127 rm -rf out
5 @rm -rf output/*
6
7build_fonts: clean
8 @scripts/build_fonts.sh
9
10build_sass: clean
11 @scripts/build_sass.sh
12
13build_content: clean
14 @scripts/build_content.sh
15
16build_only: build_fonts build_sass build_content
17
18compress_gz: build_only
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
22compress_br: build_only
23 @echo -e "\033[0;32m[COMPRESS]\033[0m Brotli"
24 @brotli -k -- `find output -type f -iregex '.*\\.\\(css\\|js\\|json\\|html\\|xml\\|txt\\|svg\\|ico\\|woff\\)'`
25
26build: export LIVE=false
27build: compress_gz compress_br
28
29watch_sass: build_only
30 @scripts/watch_sass.sh
31
32watch_content: build_only
33 @scripts/watch_content.sh
34
35watch_templates: build_only
36 @scripts/watch_templates.sh
37
38watch_metadata: build_only
39 @scripts/watch_metadata.sh
40
41watch_filters: build_only
42 @scripts/watch_filters.sh
43
44watch: export LIVE=true
45watch: watch_sass watch_content watch_templates watch_metadata watch_filters
46
47serve_only: build_only
48 @python -m http.server --bind 127.0.0.1 --directory output
49
50serve: watch serve_only
51
52deploy: build
53 @scripts/deploy.sh
54
55.PHONY: all clean build watch serve deploy