#!/bin/bash # "assemble-all-pages" inserts the constant parts into all HTML templates # in the working directory and creates the OS-specific pages by removing # the irrelevant text from a common file which contains the OS-variable # parts. # The page is NAME.html and the template is NAME.t.html. The template has # inclusion markers (similar to SSI directives, except for the lack of "#") # to indicate where the constant parts are to be inserted, and deletion # markers to identify the borders of each deletion and indicate which # page(s) the text between them belongs to. # All the ingredients are is in [...]/enc/[lang]/kitchen/: # Script: assemble-all-pages # Templates: confirmation.t.html # index.t.html (contains variable parts for mac and windows) # infographic.t.html # next_steps.t.html # Includes: footer.html # head.html # javascript.html # translist.html # To regenerate the pages in [...]/enc/[lang]/: # - in the terminal, cd to [...]/enc/[lang]/kitchen/ and enter: # $ ./assemble-all-pages # - alternatively, display the directory [...]/kitchen/ in the file browser # (not the parent directory) and double-click on the script. # And if anything goes wrong, you can do a git reset, right? ;-) # ========================================================================== set -e # Create temporary files. names=$(mktemp -t aap.XXXXXX) || exit 1 list=$(mktemp -t aap.XXXXXX) || exit 1 before=$(mktemp -t aap.XXXXXX) || exit 1 after=$(mktemp -t aap.XXXXXX) || exit 1 trap 'rm -f "$names" "$list" "$before" "$after"' EXIT # List all the templates in the working directory. if ls *.t.html > $names 2>/dev/null; then sed -i 's,\.t\.html$,,' $names else echo "There is no template in this directory." && exit 1 fi # Add the includes to the templates. while read name; do # echo $name # Make sure there is a blank line before the first include, otherwise # it will not be added properly. cp $name.t.html ../$name.html && sed -i '1i\\n' ../$name.html # List the includes. grep '^