2003-01-28 04:17 GMT.
Feed My Ego
Scott Ventura's Site Generator
Scott Ventura's Site Generator
I found myself wishing for a free piece of software that would let me
have a consistent look and feel to my web site without a lot of
cutting and pasting. When I originally did my site in WordPerfect
Internet Publisher, I didn't mind the cutting and pasting so much, but
it still felt like an inefficient way to accomplish what I wanted.
Microsoft FrontPage provided the functionality I was looking for
coupled with a seductively simple WYSIWYG editor. Unfortunately,
FrontPage isn't cheap, and it's much simpler to use if the server is
running special Microsoft extensions to the server software. Most
server administrators aren't happy about installing extra software on
important multi-user machines, and I can't blame them.
In the beginning of the summer of 1997, I followed up on a vision I'd
had several months earlier: Use the C preprocessor to insert files in
the middle of other files. I played with gpp for a bit until I came
up with a set of command-line options that worked, then wrote a
makefile to automatically run the command for specified files.
Guess what! It worked. My HTML source is now split into header files
and content files. The header files contain the HTML source for the
graphics, the navigation links, the boilerplate at the bottom, and
even a few other things. The content files have the text that makes
each page unique, with a few references to the header files.
Reasons I Use It
It has an interface only a programmer could love.
I can edit my source in emacs, and we all know there's nothing
I love as much as emacs.
All of the software it relies on is freely available to anyone
running just about any flavor of UNIX.
All of the software it relies on is available on the machine I
keep my site on.
I don't have to trust somebody else's application's HTML
generator. I write all of the HTML (even if it is in separate
files) so I know exactly what the browser gets when it goes to
display the page.
I've got a lot of pages on this site. I'd hate to have to do
copy and paste into each of them every time I want to change
one of the common design features of my site.
It will never be outdated by new versions of HTML because it
has no concept of HTML.
Automatically #defines the name of the .c file being compiled,
substituting underscores for periods and hyphens as necessary.
Makes content editting easier because anything in a separate file
stays out of the way.
Automatically replaces the word FILE with the name
of the html file being generated.
Provides a nice middle-ground between hand-coding and full
Processing power is only needed at generation time,
not every time the page is requested, like server-side
#defines CDATE, which is an integer representation
of the date in the form YYMMDD. #if can handle comparison operators
to compare CDATE to specific dates. This allows content
to change according to the date of site generation. Utilities like
cron and at can be used to automatically generate the site right after
a date change.
#defines CTIME, which is an integer representation of the
time of day in the form HHMMSS. #if can be used to have content
only appear when the page is generated at certain times of day.
Uses grep to remove blank lines from the final product.
Selective compilation normally produces a very large number
of blank lines, which we circumvent here.
(Not everyone will consider this a "feature", but
.h files can't have single quotes in them because the
preprocessor tries to find a terminating single quote to make a
character constant. This is taken care of in the .c files by
running sed on the .c file first. I have yet to figure out a
good way to do this except to create a rule to go from .hp to
.h or somesuch. That will mess things up quite a bit.
Previewing is a bit of a hassle: you have to generate the HTML
files before you can see the final result. If you understand
HTML, this probably won't be a big problem, but it does slow
the development cycle slightly.
I used to offer to send the site generator out to anyone who wanted
it. I've since decided that nobody should go through the anguish of
using it other than myself. My poor choice of macro languages is
certainly one of the factors. Sorry!
On the bright side, there is now a program that will do the job, has
many more features, and is a Perl program (woo hoo!) distributed under
the GPL (woo hoo!).
This program is GTML, available at
This page was lovingly hand-crafted by Scott Ventura
, who is solely responsible for the contents. Scott
is also the sole owner of the content of this page, including all of
the graphics. Send comments or questions.