diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-12-30 19:20:36 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-12-30 19:20:36 +0100 |
| commit | 8170b6616c13828b434e0103b362ca0e056309d0 (patch) | |
| tree | d7c8367ffc38c507a7cec22327a5e62a19ce5ae9 /build.sh | |
| parent | 74a28fd0f2ccab43a51430dd29093053f9e366ea (diff) | |
| download | quatuorbellefeuille.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-x | build.sh | 34 |
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} |
