3 # assemble-page: includes the constant parts into an HTML template.
5 # The name of the page is NAME.html and the name of the template is
6 # NAME.t.html. The inclusion markers in the template are similar to
7 # SSI directives, but for the "#".
9 # The script and all the pieces are in the same directory.
10 # cd to that directory and run:
12 # $ ./assemble-page NAME
14 # ===================================================================
16 # Create temporary files.
17 before
=$
(mktemp
-t h2p.XXXXXX
) ||
exit 1
18 after
=$
(mktemp
-t h2p.XXXXXX
) ||
exit 1
19 trap 'rm -f "$before" "$after"' EXIT
21 # Make sure there is a blank line before the first include, otherwise
22 # it will not be added properly.
23 cp $1.t.html
$1.html
&& sed -i '1i\\n' $1.html
26 grep '<!-- include virtual="' $1.html |
27 sed 's,^.*include virtual="\([^"]\+\).*$,\1,' > include-list
29 # Add the listed includes and remove the marker.
31 sed "1,/<!-- include virtual=\"$i\"/!d" $1.html
> $before
32 sed "1,/<!-- include virtual=\"$i\"/d" $1.html
> $after
34 cat $before $i $after > $1.html
38 sed -i "/<!-- include virtual=\"$i\"/d" $1.html
41 # One item in Section 2a (Troubleshooting) of index.html has to be
42 # removed from mac.html and windows.html.
43 if [ "$1" == "mac" ] ||
[ "$1" == "windows" ]; then
44 sed -i '/<!-- START DELETION -->/,/<!-- END DELETION -->/d' $1
45 elif [ "$1" == "index" ]; then
46 sed -i '/DELETION -->/d' $1
49 # Delete extra blank lines at the end.
50 sed -i ':a /^\n*$/ {$d; N; ba}' ..
/$1.html