summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-12-30 19:20:36 +0100
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-12-30 19:20:36 +0100
commit8170b6616c13828b434e0103b362ca0e056309d0 (patch)
treed7c8367ffc38c507a7cec22327a5e62a19ce5ae9 /build.sh
parent74a28fd0f2ccab43a51430dd29093053f9e366ea (diff)
downloadquatuorbellefeuille.com-8170b6616c13828b434e0103b362ca0e056309d0.tar.xz
Add template machinery
*Of course* it's going to be an ugly Bash script. Is there anything else?
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}