blob: b4fc8f8a6a96de101308e036e1305196f4b4ef86 (
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/bash
set -eu
input=$1
output=$2
parameters=${input/%.html/.sh}
if ! test -f ${parameters}
then
cp ${input} ${output}
exit
fi
cp template.html ${output}
transform-li-current-a ()
{
local old="<li><a href=\"$1.html\">"
local new="<li class=\"current\"><a href=\"$1.html\">"
echo "s/${old}/${new}/"
}
transform-li-dropdown-current-a ()
{
local old="<li class=\"dropdown\"><a href=\"$1.html\">"
local new="<li class=\"dropdown current\"><a href=\"$1.html\">"
echo "s/${old}/${new}/"
}
transforms=()
postprocess=true
. ${parameters}
sed -i s/'{TITLE}'/"${title}"/ ${output}
link_stylesheets=''
for s in "${stylesheets[@]}"
do
link_stylesheets+=$(printf '<link rel="stylesheet" href="%s.css">\n' "${s}")
done
sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output}
for transform in "${transforms[@]}"
do
sed -i "${transform}" ${output}
done
sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output}
${postprocess} ${output}
|