X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=fr%2Fkitchen%2Fassemble-all-pages;h=75e459c5ba6d55c37b4510f7c1996866de755d8c;hb=bc80744425c741604a7ec521148fde29a22671dd;hp=4e8859f9f9e88196e9179516a9c17ebd7ebec427;hpb=d2a7098b7daacc86f0ff6b6a6c11d4679d069b36;p=enc.git diff --git a/fr/kitchen/assemble-all-pages b/fr/kitchen/assemble-all-pages index 4e8859f9..75e459c5 100755 --- a/fr/kitchen/assemble-all-pages +++ b/fr/kitchen/assemble-all-pages @@ -1,72 +1,115 @@ #!/bin/bash -# assemble-all-pages: includes the constant parts into all the HTML -# templates in the working directory. +## assemble-all-pages -- generate a set of HTML pages with variable parts +# for emailselfdefense.fsf.org -# The name of a page is NAME.html and the name of the template is -# NAME.t.html. The inclusion markers in the template are similar to -# SSI directives, but for the "#". +## Synopsis: assemble-all-pages -# The script is in the same directory as all the pieces. It can be -# launched by double-clicking on it provided the path to the working -# directory is set at the first line. +## Description -# ===================================================================== +# Each page is built from a template and one or several includes, as usual; +# in addition, several versions of a page can be built from a single +# template which contains all the variable parts, by deleting irrelevant +# text. -wdir=~/GNU/enc/fr/kitchen +# The templates have 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 those borders belongs to. + +# The script processes all the templates in the working directory and the +# pages are created in the parent directory. + +# Ideally, any modifications should be done to the templates or includes, +# not to the final 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 (contains 2 alternate sets of keywords) +# javascript.html +# translist.html + +## Graphic-user-interface howto + +# - Place the script in the same directory as the templates. +# - Display this directory in the file browser (do not just unfold the parent +# directory) and double-click on the script. + +# And if anything goes wrong, you can do a git reset, right? ;-) + +# =========================================================================== set -e -cd $wdir +set -o pipefail + +function close_term () { + printf '\n%s' '*** Close the terminal window or press Return.'; read OK + test -z "$OK" && exit $1 +} # Create temporary files. -before=$(mktemp -t h2p.XXXXXX) || exit 1 -after=$(mktemp -t h2p.XXXXXX) || exit 1 -trap 'rm -f "$before" "$after"' EXIT +names=$(mktemp -t aap.XXXXXX) || close_term 1 +list=$(mktemp -t aap.XXXXXX) || close_term 1 +before=$(mktemp -t aap.XXXXXX) || close_term 1 +after=$(mktemp -t aap.XXXXXX) || close_term 1 +trap 'rm -f "$names" "$list" "$before" "$after"' EXIT # List all the templates in the working directory. -if ! ls *.t.html > template-list ; then - echo "There is no template in this directory." && exit 1 +if ls *.t.html > $names 2>/dev/null; then + sed -i 's,\.t\.html$,,' $names +else + echo "*** There is no template in this directory." && close_term 1 fi -# Process each template of the list. -while read template; do - - page=${template/.t/} - echo $page +## Add the includes to the templates. +while read name; do # Make sure there is a blank line before the first include, otherwise # it will not be added properly. - cp $template $page && sed -i '1i\\n' $page - + sed '1i\\n' $name.t.html > ../$name.html # List the includes. - grep '/,//d' $page - elif [ "$page" == "index.html" ]; then - sed -i '/DELETION -->/d' $page - fi - - # Delete extra blank lines at the end. - sed -i ':a /^\n*$/ {$d; N; ba}' $page - - # Move the complete page to its final location. - mv $page ../$page - -done < template-list -exit 0 + sed -i "/^