Summary Files Commits Branches @commit @diff @stats
path: root / generate.sh
blob: 49096fa942b296cd8389257ade191ba787c980a6 (plain) (blame)
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
#!/bin/bash

: ${SRC:=$PWD/src}
: ${HEADER:=$PWD/html/header.html}
: ${FOOTER:=$PWD/html/footer.html}
: ${GEN_DIR:=./website}
: ${META_FILE:=meta.tsv} # Relative to SRC

# 0 Fix hardlinks {{{
	while read -r folder
	do
		if [ -f "$folder.du" ] && [ ! "$folder.du" -ef "$folder/index.du" ]
		then
			rm "$folder/index.du" >/dev/null 2>&1
			ln "$folder.du" "$folder/index.du"
		fi
	done << EOF
$(find "$SRC" -maxdepth 1 -type d)
EOF
	if [ ! "src/favicon.ico" -ef "src/img/favicon.ico" ]
	then
		rm "src/favicon.ico" >/dev/null 2>&1
		ln "src/img/favicon.ico" "src/favicon.ico"
	fi
	echo "[Stage 0] Fixed folder/index.md hardlinks"
# }}}
# 1. Dunbar source to HTML {{{
	mkdir -p "$GEN_DIR"
	cp -a "$SRC/." "$GEN_DIR"
	rm "$GEN_DIR/$META_FILE" "$GEN_DIR/."*

	META="$SRC/$META_FILE"
	AWK="mawk"
	export HEADER FOOTER META GEN_DIR AWK

	/usr/bin/env dash ./dunbar/dunbar_awk/dunbar.sh html  \
		-i                                                \
		-e ./ext/attention.awk                            \
		-e ./ext/heading-anchors.awk -e ./ext/pagenav.awk \
		-e ./ext/icons.awk -e ./ext/presentation.awk      \
		-e ./ext/contents.awk -e ./ext/teaching.awk       \
		-wo                                               \
		$(find "$GEN_DIR" -type f -name "*.du")
# }}}
# 2. Meta handling {{{
	awk -f meta.awk $(find "$GEN_DIR" -type f -name "*.html")
# }}}
# 2. Tiny version, strip away styles and other stuff {{{
	# TODO
# }}}