summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..62487bd
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,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}