summaryrefslogtreecommitdiff
path: root/build.sh
blob: 5f492f24230dc7d9976283f13a2454b2984d75c2 (plain)
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
#!/bin/sh

usage() {
	echo "$0: usage: $0 <destdir> [<srcdir>]" >&2
}

if [ $# -lt 1 ] || [ $# -gt 2 ]; then
	usage
	return 1
fi

dst=$1
src=${2:-.}

echo "building at $(date)"

# build page
bp() {
	echo "${src}/$1 ==> ${dst}/$2"
	lua "${src}/$1" >"${dst}/$2"
}
# build page with extensions automatically
bpn() { bp ${1}.lua ${1}.html; }

# build page into subdir (xyz.lua becomes /xyz/)
bpnd() { md "$1"; bp ${1}.lua ${1}/index.html; }

# copy file (or dir)
cf() {
	echo "${src}/$1 -> ${dst}/$1"
	cp -r "${src}/$1" "${dst}/$1"
}
# mkdir
md () {
	mkdir -p "${dst}/$1"
}

bpn index
cf bg.png
cf me.png

md questions
bpn questions/questions

bpnd garden


# md blog
# bp blogindex.lua blog/index.html
# for p in blog/*; do
# 	bpn ${p%.lua}
# done