| ||||||
|
||||||
| Projects | Languages | Computers | iBook | Card | msite | Pulses | ||||||
Site generation with msiteThis site, and a couple of others I maintain (in particular livewires.org.uk), are generated using a perl script called msite. Sometimes people who are working on bits of the other sites ask me for a copy of the program, so it's available here for anybody who's interested. You can download msite. This code, other than very minor tweaks, is about 5 years old, and I'd probably approach things differently now. The idea goes back to the days when few cheap web service providers offered dynamic content facilities (CGI, PHP and so on), so automatically generating the menus and common layout into static pages was a good idea. You can achieve many of the same things with a few lines of PHP or eRuby (or one of numerous other server-side embedded code setups), and such options are probably worth considering before static generation unless you either have very limited facilities with your ISP or you need the speed advantage of static-generated pages. It offers a small advantage if you have to develop the pages on a machine without a webserver or suitable scripting language installed, too, because you can browse your site with file: URLs during development. Having said all that, msite does what it was supposed to do reasonably well, and the code isn't too bad, for perl. :-) You are most likely to want this script if you're already working on a site written using this (if you're on the LiveWires team, for example). There isn't enough documentation here to start using it from scratch, unless you're very fond of reading source; so this is mainly here as a curiousity for now. When I have time to write a small example configuration that works, I'll post one. Using msiteYour website should live in a directory with three subdirectories: meta, site, and target. Run msite from the directory containing these three, and it'll populate the target directory with the website described by the files in the other two directories. It makes some (rather limited) attempts to update only the files it needs to: if that doesn't work, try the -a option. The contents of site is basically copied directly into target, except that .html pages are checked for some simple macro-language headers and processed. The headers are simple: this page, for example, looks like this:
.TITLE msite
.AUTHOR Mark
.EMAIL webmaster@celos.net
.CVS $Id: msite.html 191 2007-10-03 16:42:34Z mark $
.NAV Computing
.SUBNAVFILE comp.nav
.PAGE
(page body continues here, in regular HTML)
.END
(the CVS tag gets filled in automatically by Subversion). The NAV tag controls what gets hilighted in the master menu when this page is displayed; the SUBNAVFILE points to a file in meta containing a list of pages in this group, which generates the sub-menu below the main one, and figures out which item to is current based on the filename. Other bits are obvious, I think. The meta directory contains a pile of files defining the style and various other bits of the site. It has several quirks: for example, it ignores version control directories from CVS and Subversion, and can translate php files as well as HTML if needed. There are probably others I don't remember. At the moment, it calls the UNIX find utility and a few others, so it probably won't work on Windows. In principle, it would be easy to replace this dependency with Perl's own functions to achieve the same thing, and so run it on Windows. I've not been sufficiently motivated to do this myself, though. |