#!/bin/bash set -eu input=$1 parameters=$2 template=$3 outdir=$4 uri=$5 output="${outdir}/${uri}" . settings.sh cp ${template} ${output} transform-li-current-a () { local old="
  • " local new="
  • " echo "s/${old}/${new}/" } transform-li-dropdown-current-a () { local old="
  • " local new="
  • " echo "s/${old}/${new}/" } transforms=() postprocess=true iconcolor= . ${parameters} sed -i s/'{TITLE}'/"${title}"/ ${output} sed -i s,'{URI}',"${uri}", ${output} sed -i s,'{DOMAIN}',"${domain}", ${output} link_stylesheets='' for s in "${stylesheets[@]}" do # Prefer relative paths so that drafts under /admin/drafts find # the correct stylesheets. # ${input} might be a temporary file; assume ${template} is a # bona-fide node in our directory hierarchy, and use that to # compute the path to the stylesheets folder. spath=$(realpath --relative-to $(dirname "${template}") stylesheets/"${s}".css) link_template='\n' link_stylesheets+=$(printf "${link_template}" "${spath}") done sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output} sed -i s/'{TRANSLATION}'/"${translation}"/ ${output} for transform in "${transforms[@]}" do sed -i "${transform}" ${output} done if test "${iconcolor}" then sed -i s/'{ICONCOLOR}'/"-${iconcolor}"/ ${output} else sed -i s/'{ICONCOLOR}'// ${output} fi sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output} ${postprocess} ${output}