-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·80 lines (64 loc) · 1.25 KB
/
build.sh
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
#!/bin/sh -e
cd ${0%/*}
MINIFY=true
if [ "$1" = "--nomin" ]; then
MINIFY=false
shift
fi
out=index.html
if [ -n "$1" ]; then
out="$1"
fi
src="src"
# HTML head.
cat > "$out" <<EOF
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
EOF
# CSS.
cat ${src}/styles/*.css >> "$out"
echo '</style>' >> "$out"
if [ -f ${src}/head.html ]; then
cat ${src}/head.html >> "$out"
fi
echo '</head><body>' >> "$out"
# HTML body.
cat ${src}/body.html >> "$out"
# HTML templates.
for t in ./${src}/templates/*.html; do
[ -e "$t" ] || continue
name=$(basename ${t%.html})
if test ${name%.multi} = "$name"; then
echo "<script type=\"text/html\" id=\"t-$name\">" >> "$out"
cat "$t" >> "$out"
echo "</script>" >> "$out"
else
cat "$t" >> "$out"
fi
done
# Javascript
echo '<script>' >> "$out"
for f in ./${src}/js_lib/*.js; do
[ -e "$f" ] || continue
if $MINIFY && [ ${f%%.min.js} = "$f" ]; then
uglifyjs "$f" -c -m >> "$out"
else
cat "$f" >> "$out"
fi
echo >> "$out"
done
for f in ./${src}/js_app/*.js; do
[ -e "$f" ] || continue
if $MINIFY; then
uglifyjs "$f" -c -m >> "$out"
else
cat "$f" >> "$out"
fi
echo >> "$out"
done
echo '</script>' >> "$out"
# Close HTML.
echo '</body></html>' >> "$out"