The alternative is to use Servlets/JSP/PHP/CGI/SSI etc. and dynamically generate the web page on the server each time someone requests a page.
|How It Works||Example Macro Expansions|
|Advantages of HTML Static Macros||Availability of the HTML Static Macro Tools|
|Disadvantages of HTML Static Macros||Website Philosophy|
|Canadian Mind Products HTML Static Macro Tools||Links|
|Third Party HTML Static Macro Tools|
The basic idea is you write a computer program to generate HTML, that looks just as if you had composed it by hand, then you upload it. The server just delivers fully-prepared HTML pages. It does no dynamic content generation.
I use two different techniques to statically generate the HTML for my website:
<!-- macro Xxxxxxx xxxxxxx -->which are used to generate a lot of the boilerplate, such as headers, footers, book referrals, references to the JRE (Java Runtime Environment) and JDK (Java Development Kit), international currency references, lists of browsers etc. I invented my own macro generator where the macros are written in Java.
Most of the site is done by embedding magic comments in the HTML markup that are later expanded my macros written in Java. For example, if you look the top of this page you will see
<!-- example of a macro to generate a page header for the Java glossary --> <!-- macro JglossHead "HTML static macros" -->
The MacroExpander converts that to:You can see signs of Java’s cleverness in the expansion. The expansion is not simply included boilerplate. It generated a URL-encoded Google search string, for example and it inserted the name of the file, which was not passed an a parameter. It also inserted the file last change date. It built and labeled links to related pages. It figured out how many ../ it needed to access the images directory from this page.
The big advantage is if I want to change that header, I change the program that generates it and the next time I regenerate the website, all the headers will be automatically changed.
You get frivolous updates often like this. Let us say that file B has a macro that expands to display the size or date of file A. Every time file A changes, that expansion will change, triggering a change to file B. If file C contains a reference to the date or size of file B, you get a propagation and C too will change and before you know it, a tiny change has triggered a fission reaction dozen dependent uploads. With SSI (Server Side Includes) or JSP, the referencing file itself does not change when the referenced file changes.
I have written a number of tools to implement HTML static macros. The tools include:
|Canadian Mind Products Tools For HTML Static Macros|
|Amper||Amper just tidies web pages converting & to & intelligently. I do this for high level compliance with W3C (World Wide Web Consortium) standards demanded by the HTML Validator. I have already released Amper for general distribution.|
|Splitter||Used to split a big HTML file into smaller pieces. I embed commands in the big file telling it which pieces of it are to go where, then let Splitter do the work. It is much faster and more accurate than trying to select huge blocks of text in an editor. You don’t accidentally lose or duplicate text. I have already released Splitter for general distribution. Keeping files small makes the site more responsive.|
|MacroExpander||This is the guts of the system and the most complicated. You need to write
custom macros to generate headers and footers of various sorts in
Java. Your macro gets passed the
parameters and it returns a String containing the
HTML. Your macro is free to use what ever tools it
wants to do that. The MacroExpander searches for embedded macros in the text
and calls your code to expand them. The macro expansion code is written in
ordinary Java. That gives you the power to do anything Java can to expand
your macro, including even things like reading files, checking a database,
finding out the time, checking if files exist, reading files, sending off a
transaction to JSP… This not some impoverished ad-hoc macro language.
You have the full power of Java at your command, same as in
With the latest version, it takes about 20 seconds to expand the macros and compact the results to remove excess white space in 4200 files, leaving the files unchanged if the macros expanded the same way as last time. I do this prior to every upload.
Check out my website. You will see <! macro XXXX all over the website with the <generated> … </generated> expansion. You can see from the examples what sorts of things are possible. Some of my macros you would use too, others you might modify, others would be useless to you. You would need to write your own before you could generate your own website. Here is what the source code for a simple macro looks like. It takes a birthdate and generates
|Compactor||Removes excess white space from generated HTML files. This makes them faster to upload and download.|
|Qf: quick Find||Builds indexes for the various glossaries, with master and letter index pages. Builds the files for the Go Applet to do quick lookups on the glossaries.|
|SeeSort||At the bottom of most pages is the links see also section. It sorts the items alphabetically and removes duplicates. It also builds missing href links by looking up words in the glossary index.|
|Untouch||Redates files back the way they were if they have not really changed. The macroexpander and the compactor don’t write out a new file if it would be same as last time. However, it is still possible to disturb the files, say with an HTML reformat, in ways that don’t really change anything. Untouch undoes nugatory changes. It mainly helps avoid needless file uploading.|
|PriceList||Instead of using macros, I generate the price list/download pages from a CSV file with the PriceList Program. I did a similar one that generated multilevel catalogs sorted in various orders all cross linked for a client.|
|The Replicator||Allows clients to keep a mirror copy of the entire website for local browsing, when mindprod.com is down, busy, or the link to it is unavailable, or simply to avoid connect charges. The mirror copy is automatically kept up to date with just the changes.|
|publish.bat||After I make a series of changes, I just run a bat file called publish.bat that runs these utilities in order and uploads the changed files to my server.|
|Third Party Tools For HTML Static Macros|
|SlickEdit||This is an ordinary text editor I use for composing the content. It does HTML syntax highlighting and it can tidy HTML to indent it to make it easier to read. The Compactor squeezes it back down again. You might use DreamWeaver for as your editor. You don’t need anything special. Any tool for editing HTML will do. The macros look like comments to the editor.|
|TopStyle||CSS style sheet editor and CSS Validator. It also checks I have not used any invalid classes in my HTML markup.|
|HTMLValidator||Check that HTML is well formed. You must check after expansion to make sure both the original HTML and the generated HTML meld properly.|
|Xenu||Link checker. Makes sure that links both internal and external point to a valid URL (Uniform Resource Locator). Also tells you about orphan files, files and images that nothing points to. You may be able to delete these if they are obsolete, or you may need to hook them in with a reference somewhere so they become accessible.|
|NetLoad||Automated FTP (File Transfer Protocol) upload of just the changed files to the website. The product is buggy and no longer supported. Eventually I will write a replacement. Every FTP program I have tried is fatally flawed when it comes to reliably uploading files unattended.|
Here are some examples of the output of the approximately 100 macros I have written:
I wrote these tools for my own use. For the most part, they are not yet documented other than in Javadoc. Further, they do things my way. You would have to change the code to make them do things your way. Eventually I may make them configurable without modifying source so that non-technical people could use them too.
I have no far not packaged my HTML static macro tools for general distribution, except for Splitter, Amper and the Replicator. I did not want to get into trying to support the suite for non-programmers or inexperienced programmers.
However, I am willing to share them with you on an as-is basis. Email me at . The MacroExpander, Qf, SeeSort, Compactor and Untouch are not documented other than in Javadoc. Compactor and Untouch could be fairly easily be prepared for general distribution. I’m not sure of the general applicability of Qf and SeeSort. That leaves the big mother MacroExpander. The catch there is you have to write code to customise it to your own use. It is just a starting point. It would be a beast to document.
Perhaps I could write macros to your specifications or act as a paid consultant.
HTML static macros fit well with my website design philosophy. I aim for functionality rather than gee whiz. The site looks a little on pedestrian side (that was deliberate), but I have incorporated many suggestions to make it less frustrating to navigate. A local university uses my website to teach the principles of good web design. They like my automatically generated you are here feature. Google tends to rank me high. This is because my pages tend to be small and stick to a single topic. I don’t do anything consciously to try to manipulate the rankings. Also many people have links into my glossaries for their own quick reference. Google notices this and ups my ranks.
This page is posted
Optional Replicator mirror
Please read the feedback from other visitors, or send your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
Your face IP:[126.96.36.199]
You are visitor number|