3 # assemble-all-pages: includes the constant parts into all the HTML
4 # templates in the working directory.
6 # The name of a page is NAME.html and the name of the template is
7 # NAME.t.html. The inclusion markers in the template are similar to
8 # SSI directives, but for the "#".
10 # The script is in the same directory as all the pieces. It can be
11 # launched by double-clicking on it provided the path to the working
12 # directory is set at the first line.
14 # =====================================================================
16 wdir
=~
/GNU
/enc
/fr
/kitchen
21 # Create temporary files.
22 before
=$
(mktemp
-t h2p.XXXXXX
) ||
exit 1
23 after
=$
(mktemp
-t h2p.XXXXXX
) ||
exit 1
24 trap 'rm -f "$before" "$after"' EXIT
26 # List all the templates in the working directory.
27 if ! ls *.t.html
> template-list
; then
28 echo "There is no template in this directory." && exit 1
31 # Process each template of the list.
32 while read template
; do
37 # Make sure there is a blank line before the first include, otherwise
38 # it will not be added properly.
39 cp $template $page && sed -i '1i\\n' $page
42 grep '<!-- include virtual="' $page |
43 sed 's,^.*include virtual="\([^"]\+\).*$,\1,' > include-list
45 # Add the listed includes and remove the marker.
46 while read include
; do
47 sed "1,/<!-- include virtual=\"$include\"/!d" $page > $before
48 sed "1,/<!-- include virtual=\"$include\"/d" $page > $after
49 if [ -f "$include" ]; then
50 cat $before $include $after > $page
52 echo "$include is missing." && exit 1
54 sed -i "/<!-- include virtual=\"$include\"/d" $page
57 # One item in Section 2a (Troubleshooting) of index.html has to be
58 # removed from mac.html and windows.html.
59 if [ "$page" == "mac.html" ] ||
[ "$page" == "windows.html" ]; then
60 sed -i '/<!-- START DELETION -->/,/<!-- END DELETION -->/d' $page
61 elif [ "$page" == "index.html" ]; then
62 sed -i '/DELETION -->/d' $page
65 # Delete extra blank lines at the end.
66 sed -i ':a /^\n*$/ {$d; N; ba}' $page
68 # Move the complete page to its final location.