-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (104 loc) · 3.95 KB
/
Makefile
File metadata and controls
134 lines (104 loc) · 3.95 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
serve := node_modules/.bin/serve
tiddlywiki := node_modules/.bin/tiddlywiki
merge_json := ./bin/merge-json
deploy_path := ktohg@tritarget.org:tritarget.org
plugins_src := $(shell find plugins -type f)
plugins_out := $(patsubst plugins/%,wiki/plugins/%,$(plugins_src))
asset_files := $(patsubst public/%,wiki/output/%,$(shell find public -type f))
sourcecode_src := $(shell find -L sourcecode -type f)
sourcecode_html := $(patsubst sourcecode/%,wiki/sourcecode/%.html,$(sourcecode_src))
sourcecode_tid := $(patsubst sourcecode/%,tiddlers/sourcecode/%.tid,$(sourcecode_src))
obfuscated_tid := $(patsubst deobfuscated/%.html,tiddlers/obfuscated/%.tid,$(wildcard deobfuscated/*.html))
modified_date = $(shell date +%Y%m%d%H%M%S000)
pgp_fingerprint = FA9F14008BA5A847B0977C06EBD99C92DE767C8A
.PHONY: build-files build clean generated diagrams assets tiddlywiki server devpublic media-build deploy updatekey certs obfuscate deobfuscate
build:
@rm -f wiki/tiddlywiki.info
$(MAKE) -e NODE_ENV=production tiddlywiki
$(MAKE) assets
devpublic:
ifeq (,$(wildcard devcerts/cert.pem))
$(serve) --cors public/
else
$(serve) --cors --ssl-cert ./devcerts/cert.pem --ssl-key ./devcerts/key.pem public/
endif
server:
@rm -f wiki/tiddlywiki.info
$(MAKE) -e NODE_ENV=development build-files
ifeq (,$(wildcard devcerts/cert.pem))
$(tiddlywiki) wiki --listen host=0.0.0.0
else
$(tiddlywiki) wiki --listen host=0.0.0.0 tls-cert=../devcerts/cert.pem tls-key=../devcerts/key.pem
endif
media-build:
@rm -f wiki/tiddlywiki.info
$(MAKE) -e NODE_ENV=development build-files
clean:
rm -rf wiki devcerts
diagrams:
cd diagrams && $(MAKE)
certs: devcerts
devcerts:
mkdir -p $@
openssl genrsa -out $@/key.pem
openssl req -new -key $@/key.pem -out $@/csr.pem
openssl x509 -req -days 9999 -in $@/csr.pem -signkey $@/key.pem -out $@/cert.pem
rm $@/csr.pem
generated: $(sourcecode_tid) $(obfuscated_tid) tiddlers/generated/sourcecode.css tiddlers/generated/PGPKeyFile.tid tiddlers/generated/PGPKeyInfo.tid
deploy: build
rsync -rlvz --delete --exclude-from ./config/rsync-exclude wiki/output/ $(deploy_path)
assets: $(asset_files)
build-files: wiki/tiddlywiki.info wiki/tiddlers wiki/themes generated diagrams $(plugins_out)
tiddlywiki: build-files
$(tiddlywiki) wiki --build index favicon static feed
wiki/tiddlers:
ln -s ../tiddlers $@
wiki/themes:
ln -s ../themes $@
wiki/tiddlywiki.info: config/tiddlywiki.info config/includes.json
@mkdir -p $(@D)
$(merge_json) config/tiddlywiki.info config/includes.json > $@ || rm $@
wiki/plugins/%: plugins/%
@mkdir -p $(@D)
cp $< $@
wiki/output/key.info: wiki/output/key
gpg -v $< > $@
wiki/output/%: public/%
@mkdir -p $(@D)
cp $< $@
wiki/sourcecode/%.html: sourcecode/%
@mkdir -p $(@D)
SOURCE_FILE="$<" TARGET_FILE="$@" vim -NRE -S "scripts/sourcecode-to-html.vim" $<
tiddlers/sourcecode/%.tid: wiki/sourcecode/%.html
@mkdir -p $(@D)
SOURCE_FILE="$(patsubst wiki/sourcecode/%.html,%,$<)" TARGET_FILE="$@" ./bin/sourcecode-html < $< > $@
tiddlers/generated/sourcecode.css: $(sourcecode_html)
cat $^ | ./bin/sourcecode-css > $@
updatekey:
gpg --armor --export-options export-minimal --export $(pgp_fingerprint) > public/key
tiddlers/generated/PGPKeyFile.tid: public/key
@echo "Generating $@"
@echo "modified: $(modified_date)" > $@
@echo "title: PGPKeyFile" >> $@
@echo "type: text/plain" >> $@
@echo "caption: Public Key" >> $@
@echo >> $@
@cat $< >> $@
tiddlers/generated/PGPKeyInfo.tid: public/key
@echo "Generating $@"
@echo "modified: $(modified_date)" > $@
@echo "title: PGPKeyInfo" >> $@
@echo "type: text/plain" >> $@
@echo "caption: Public Key Info" >> $@
@echo >> $@
@gpg --show-keys $< >> $@
deobfuscate:
@mkdir -p deobfuscated
for src in tiddlers/obfuscated/*.tid; do \
echo "bin/obfuscate -d \"$$src\" \"deobfuscated/$$(basename \"$$src\" .tid).html"; \
bin/obfuscate -d "$$src" "deobfuscated/$$(basename "$$src" .tid).html"; \
done
obfuscate: $(obfuscated_tid)
tiddlers/obfuscated/%.tid: deobfuscated/%.html
@mkdir -p $(@D)
bin/obfuscate $< $@