two passes project technical examples links #
printer / text mode version
mksite.sh

project
- summary
- tutorial (2) (3)
  (4) (5) (6) (7) (8) (9)
- usage (2)
technical
- reasoning
- two passes
- still tiny
- sitemaps
- variables
- accessibility
  WAI SubSects
examples
- horizontal
- vertical
- tabbed (2)
- multi section
- printer style
links
- some hints
- faq&issues
- all features #
- about me
- our sitemap
- download

 

 

 

 

(C) 2004-04-22 <guidod>
 Guido Draheim

using two passes

Lately I did convert the original MKSITE.SH script into an original twopass model and this is the first version of the mksite idea that I want to publish to a wider audience. Previously the site.html was put as the last "href" in the navigation bar - each file being processed would also register some meta information to sitemap input file that would be used to generate the site.html sitemap.

Now the meta information detection is seperated out to its own pass which does not do anything on output. The per-file meta information can be looked at in a file named "target.html.~~" and the global meta information is found in "-mksite.~~". The ".~~" was chosen since my `make clean` rule usually has an entry `rm *~` so it would also clear out any remainings of the MKSITE.SH runs. Furthermore, many gnu filetools do not list any "backup" files which are recognized via a "*~" pattern.

When all meta information has been parsed then the second pass can start off which will look at the same files again that were also seen in the first pass. For each file we generate two sed scripts - a file "target.html.~head~" and a file "target.html.~body~". The two scripts are then combined with as simple a run as

  sed -f target.html.~head~ site.htm    > target.html
  sed -f target.html.~body~ target.htm >> target.html

Therefore the main intelligence lies in making of the sed scripts. You can easily implant your own functionality in that model, just invent something that can be expressed in terms of an sed line with an anchor expression and and edit definition. The functionality present can be a guide to your stuff.

The functionality already present will include things like

  • convert any uppercase html tag (like <P>) into lowercase and class tag (like <p class="P">). That allows to customize sister variants of common html marks without touching the original style of the target browser.
  • expand comment variable tags with a meta name to bear the meta value, e.g. "<!--$title-->" will become "current title". There are some variants of that available as well and most importantly and word following will cleaned as well as it is regared as the default value: "<!--$modified:-->2004/04" might be turned into "2004-04-30".
  • Some information as defined in the Dublin Core are generated as true HEAD META tags. The ''<meta name="DC.*">'' lines are pregenerated in an extra file and the "~head~" sed script contains an entry "/r.meta.tmp" to actually implant the meta tags in the correct place in the header.
  • And the printerfriendly layout option that creates an alternative view automatically that is best suited to improve web accessibility for those being visually impaired - while still keeping your default layout made up to look nice. Note there is not even a need to write a second sitefile as the printerfriendly one is derived automatically.
Again, there is no magic here. And you can do it too.