375 Eleventh Street
San Francisco, CA 94103


   
Web Site Scripts

These are the scripts I use to maintain the web site you're reading right now. The web site is constructed solely of static HTML pages that are regenerated as needed. For example, when I've added an event to the master calendar file, I just type "make cal" to re-generate any of the calendar HTML pages that should have new information on them.

Many people build web sites like this one using PHP or ASP or similar tools where the web server generates the pages on the fly. That's very wasteful. My philosophy is that that, for a primarily-non-dynamic site like this one (where only a very small number of pages change daily) the pages should instead be generated only once, at the time the change happens. Not only is it a more efficient use of server resources, but it also avoids opening you up to the kind of security holes that are endemic to tools like PHP.

I doubt these scripts will be directly useful to many people, but several people have asked how I do it, so here it is.

These scripts are all driven by a Makefile which contains shorthand, but you can guess what that looks like.


HTML Templates

menuify.pl This script reads a "template" file and updates the given HTML file to match the template. This is what splices the left-side menu onto each page. The content of the menu is defined in this file. It also takes care of the logic of not having a page link to itself: for example, on the menu on the Directions page, the "Directions" menu item is not clickable.

There are magic comments in the HTML pages that specify which part of the page the text should go in: for example, text that goes underneath the menu is bracketed by lines that say <!-- %%LEFT_START%% --> and <!-- %%LEFT_END%% -->.

This script also contains a simple HTML validator, a more general version of which can be found over at jwz.org in validate.pl.

menuify-all.sh This just does a "find" and runs menuify.pl on each HTML file on the site. This will overwrite any files that need to be changed, and leave them untouched otherwise.
update-latest-
links.pl
The menu itself points to URLs like "/calendar/latest.html", but there is no file on the site called "latest.html": instead there is an entry in the "/.htaccess" file that does an HTTP 302 redirect to a more specific URL like "/calendar/2005/02.html#15". This script runs nightly.

Calendar Pages


generate-
calendar.pl
The raw calendar lives in a simple file called "calendar.txt" and all of the HTML pages under /calendar/ are generated from that. The syntax of that file has a bunch of features (e.g., for repeating events) but mainly it contains the date of the event, followed by the HTML describing it.

There are a few special tags used in that HTML: for example, it will say <DJ HREF="...">DJ Foo</DJ> when mentioning a DJ. This is translated to a normal <A HREF="..."> in the generated HTML pages, but lets us collect the information necessary to generate the statistics on the ledger.html page.

This script also generates the RSS and iCal presentations of the calendar data, and a few other things.

Like all the other scripts, this only overwrites files when their contents would have changed.

infoline-sable.pl
infoline-mp3.pl
If you have ever called our telephone infoline, you've noticed that it reads the calendar to you in a computer-generated voice! The text for that is created by generate-calendar.pl. Then infoline-sable.pl converts that into a "Sable" XML file to use as input to the Festival speech synthesizer; it has a zillion special-cases to make Festival pronounce our various performer names correctly. Finally, infoline-mp3.pl runs Festival and creates an MP3. It re-tries a few times until it ends up with an MP3 file that is less than 3 minutes long (since that's the limit our phone system gives us.)

Then (believe it or not) we update the outgoing message on our voicemail by holding the telephone up to the computer's speaker.


Flyer Gallery


flyerize.pl Every time a promoter sends me an image of their event's flyer, I run this script on it, and it resizes the image(s) to the right size; copies them to the proper subdirectory and filename; and creates thumbnails.
wrap-flyers.pl This regenerates any changed HTML files under the /flyers/ directory, including updating the by-month and by-year indexes. It also puts in the "<< prev event_name" links that let you navigate to all the flyers of a given series of events.

Photo Gallery


gallery.pl This is the script that I use to generate the photo galleries themselves. It makes thumbnails and HTML wrappers for each image. It's pretty general-purpose.
wrap-gallery.pl This regenerates any changed HTML files under the /gallery/ directory, including updating the by-month and by-year indexes. It also puts in the "<< prev band_name" links that let you navigate to other photo sets of bands who have performed here more than once.

What's New Pages


build-index.pl This regenerates the by-month index of the "What's New" weblog.

Most of the heavy lifting of keeping the blog pages linked together is done via "magic comments" that are handled by menuify.pl (described above.)

wrap-images.pl This is a somewhat-specialized gallery generator that wraps HTML around the various images referenced by the "What's New" pages. It links those images back to the log entry in which they are first referenced.
generate-rss.pl This parses the weblog HTML pages and generates an RSS file of the most-recent 6 entries.

Top Level Page


randomize-
snapshots.pl
This picks a random set of six images from the whole image gallery and creates cleverly-sized thumbnails of them. It writes the HTML to a "staging" file for use by:
splice-
frontpage.pl
This takes the HTML snippet generated by randomize-snapshots.pl and splices it in to the top-level /index.html file. It does a similar trick for the "Calendar Overview", "Next Event", and "Upcoming live shows" boxes. This script runs nightly.

_______________________________________________