tikz.escobar.life

The setup for tikz.escobar.life

Makefile (2222B)

 1 .PHONY: all build runserver
 2 
 3 all : build
 4 
 5 build:
 6 	# Compile the main document and copy the dependencies to _site
 7 	haml main.haml _site/index.html
 8 	cp --verbose using.html _site/
 9 	find images/ -name '*.tikz' \
10 		| xargs -I {} cp --verbose {} _site/tikz/
11 	find images/ -name '*.eps' \
12 		| xargs -I {} cp --verbose {} _site/eps/
13 	find images/ -name '*.png' \
14 		| xargs -I {} cp --verbose {} _site/png/
15 	find images/ -name '*.jpg' -or -\name '*.jpeg' \
16 		| xargs -I {} cp --verbose {} _site/jpg/
17 	cp --verbose LICENSE _site/ -r
18 	find css   -type f | xargs -I {} cp --verbose {} _site/css
19 	find fonts -type f | xargs -I {} cp --verbose {} _site/fonts
20 	find icons -type f | xargs -I {} cp --verbose {} _site/icons
21 	
22 	# Convert vector graphics to SVG
23 	find images/ -name '*.tikz' -or -name '*.eps' \
24 		| awk '{ gsub(/\.tikz|\.eps/, ".svg", $$0); print "_site/" $$0 }' \
25 		| xargs -r make
26 	
27 	# Compress raster images
28 	find images/ -name '*.jpg' -or -name '*.jpeg' -or -name '*.png' \
29 		| awk '{ gsub(/\.jpg|\.jpeg|\.png/, ".webp", $$0); print "_site/" $$0 }' \
30 		| xargs -r make
31 
32 runserver:
33 	cd _site && python3 -m http.server 
34 
35 auto-build:
36 	ls index.haml Makefile css/*.css images/*.tikz | entr make build || exit 0
37 
38 _site/images/%.svg: images/%.tikz
39 	tikztosvg -o "$@" \
40 	          -p relsize \
41 	          -p xfrac \
42 	          -l matrix \
43 	          -l patterns \
44 	          -l shapes.geometric \
45 	          -l arrows \
46 	          -q \
47 	          "$^"
48 	svgo --pretty "$@"
49 
50 # TODO: Replace this with an actual check for file-size before calling SVGO?
51 # SVGO is ommited for this specific file because it is too big -- it freaking 
52 # crashes V8 when I try to optimize it with SVGO in my webserver
53 _site/images/monster-group-character-table.svg: images/monster-group-character-table.eps
54 	$(eval TMP := $(shell mktemp))
55 	epstopdf '$^' -o '$(TMP)'
56 	pdf2svg '$(TMP)' '$@'
57 	rm '$(TMP)'
58 
59 _site/images/%.svg: images/%.eps
60 	$(eval TMP := $(shell mktemp))
61 	epstopdf '$^' -o '$(TMP)'
62 	pdf2svg '$(TMP)' '$@'
63 	rm '$(TMP)'
64 	svgo --pretty '$@'
65 
66 _site/images/%.webp: images/%.png
67 	convert '$^' -quality 50 '$@'
68 
69 _site/images/%.webp: images/%.jpg
70 	convert '$^' -quality 50 '$@'
71 
72 _site/images/%.webp: images/%.jpeg
73 	convert '$^' -quality 50 '$@'
74