-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (71 loc) · 2.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.PHONY: all book web preview publish clean reversion shadowify
# All target
all: book web
## Building the TW book ##
book: wiki/package-lock.json reversion shadowify wiki/pubfolder/output/index.html wiki/pubfolder/output/static/
wiki/tiddlywiki-git:
git clone https://github.com/TiddlyWiki/TiddlyWiki5.git wiki/tiddlywiki-git
cd wiki/tiddlywiki-git && git pull
wiki/package-lock.json: wiki/tiddlywiki-git
cd wiki && npm install
reversion:
cd wiki && scripts/reversion.sh
shadowify:
cd wiki && scripts/shadowify.sh 2>/dev/null
SPACEIFY_SED_EXPR := -e ':a' -e 's/^\(\t*\)\t/\1 /;ta' -e 's/^[[:space:]]*$$//'
spaceify:
cd wiki && \
find plugins tiddlers -type f -name '*.tid' -print0 | \
while IFS= read -r -d '' i; do \
if [ "$$(uname)" = "Darwin" ]; then \
sed $(SPACEIFY_SED_EXPR) -i '' "$$i"; \
else \
sed $(SPACEIFY_SED_EXPR) -i "$$i"; \
fi \
done
wiki/pubfolder/output/index.html: wiki/plugins/* wiki/scripts/* wiki/tiddlers/* wiki/tiddlywiki.info
cd wiki && scripts/export.sh
# An inaccurate way to specify this rule, but trying to match tiddlers with
# their doubly URL-encoded names in GNU Make sounds like a nightmare I don't
# need. This appears to work fine since index.html should always update when
# any wiki content is updated, but possible ordering problems?
wiki/pubfolder/output/static/: wiki/pubfolder/output/index.html
cd wiki/pubfolder && npx tiddlywiki --build static
## Building the website (including the latest version of the book) ##
web: _build/donate _build/thankyou _build/read/index.html _build/static _build/static/index.html
_build/donate: web/donate
cp -r web/donate _build
_build/thankyou: web/thankyou
cp -r web/thankyou/ _build
_build/read/index.html: wiki/pubfolder/output/index.html
mkdir -p _build/read/
cp wiki/pubfolder/output/index.html _build/read/index.html
_build/static: wiki/pubfolder/output/static
mkdir -p _build/static/
cp wiki/pubfolder/output/static/* _build/static/
_build/static/index.html: _build/static/Welcome%20to%20Grok%20TiddlyWiki.html
cp $< $@
## Utility functions
edit:
cd wiki && npx tiddlywiki --listen port=2000
preview:
cd _build && twistd web -n --path=. --port="tcp:port=8001"
xdg-open http://localhost:8001/read/index.html
publish:
-kill $(cat _build/twistd.pid)
rm -f _build/twistd.*
# Root /index.html sits in the container with a redirect on it and is NOT updated.
# If I add more subfolders they have to be listed below:
aws s3 sync --delete _build/donate/ s3://groktiddlywiki-webserve/donate
aws s3 sync --delete _build/read/ s3://groktiddlywiki-webserve/read
aws s3 sync --delete _build/static/ s3://groktiddlywiki-webserve/static
aws s3 sync --delete _build/thankyou/ s3://groktiddlywiki-webserve/thankyou
aws cloudfront create-invalidation --distribution-id E165ACBA2QEFAJ --paths '/*'
checkout-tiddlywiki-version:
cd wiki/tiddlywiki-git && \
git fetch --all && \
git clean -fdx && \
git checkout "$(VERSION)"
clean:
rm -rf wiki/pubfolder/
rm -rf _build/