summaryrefslogtreecommitdiff
path: root/build.sh
blob: fe0d551ea76aa2063b6a831e003d30155e3a44ef (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
#!/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}
. ${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}

if test "${current_div:-}"
then
    sed -i s"${current_div}" ${output}
fi

sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output}