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.
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 and JDK, 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 labelled 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 or JSP, the referencing file itself does not change when the referenced file changes.
| Canadian Mind Products Tools For HTML Static Macros | |
|---|---|
| Tool | Function |
| Amper | Amper just tidies web pages converting & to & intelligently. I do this for high level compliance with W3C 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 JSP.
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 the age in years as of today. |
| 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 | |
|---|---|
| Tool | Function |
| 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. 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 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. |
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.
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.18] | The information on this page is for non-military use only. | ||
| You are visitor number 6,001. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/Mindprod website mirror) | ||
| http://mindprod.com/jgloss/htmlstaticmacros.html | J:\mindprod\jgloss\htmlstaticmacros.html | ||