Up: The Mighty Machine Unleashed | [Related] «^» «T» |
Sunday, October 14, 2001
Scripts
By Paul Ford
An overview of all the scripts in the system
ftrain_vars.xsl
This is the variables file; it's loaded into nearly every script and includes all directory references and file names, as well as some utility functions.
ftrain_links.xsl
This pulls in a flat XML links file (i.e. links arranged one record at a time) and creates 3 views of the links:
- By category, which it does by consulting a hierarchically structured XML file with each category name listed (this is called link_categories.xml in the main XML directory, and I edit it by hand) and turning every category into a section; it then figures out which links have categories that aren't in the categories XML file and lists those categories in the top-level of the hierarchical view. You can see an example of the output of this view at All the Links.
- Chronologically, which it does by doing a sort on all the links and organizing them by day. The example of this view is at [#links_in_chron_order_all_nice_like].
- In a table for the left navbar. This is similar to the chronological view, but it oscillates the table color and only picks the last 15 links or so for the left nav bar, so that everything looks swell (see left). It spits out an include file, recent_links.xml, which is then included whenever a regular file is created.
ftrain_map.xsl
This is a very simple script that makes a “map” of the entire Ftrain structure - i.e. it grabs every <section> tag and the title, desc, and key data. It's much faster to work with this map than with the actual document.
ftrain_map2.xsl
Now we use the map we created and create a new map - this one is flat and lists all the sections in the order they appear in the document with a position number and a random number associated with them. This allows us
to associate a random number with each section when we process it, which in turn allows us to choose to include certain parts
of other XML files randomly. It's not proper randomness, really, but it'll do until math:random is widely implemented in XSLT
processors.
ftrain_paths.xsl
This doesn't really do much for the time being; it's mostly here as a placeholder for some functionality I'd like to offer
in the future.
ftrain_toc.xsl
This generates several XML files which are later included in the main XML document - this is a little tricky if you're new
to XML, but basically what I do is use system entities, which refer to outside files, to include the output of XSLT transformations
against the main Ftrain document in the document itself. This run creates a Reverse Chronological Order TOC, a Forward Chronological
Order TOC, a (Not really) RDF (needs an update), and a "Last 10" view.
ftrain_calendar_func.xsl
Utility functions for the two calendar scripts below; I got the code somewhere on the Web, but I can't find it now. It was
on a mailing list, so I'll pretend it's more-or-less GNUish.
ftrain_calendar.xsl
Generates an XML file which is included in the master XML file to become the ite_calendar.
ftrain_calendar_nav.xsl
Generates an XML file which is included with every output page to become the small calendar to your left.
ftrain_main.xsl
The main processor. Now that we've put together all our maps and views, we go back to the map and with every section in the
map, we run the processor again and it creates individual HTML pages, one per section, turning the files we created into new
pages or including them in every page as nav elements.
cal3.xml
This contains the month listing for the calendar.
ftrain_images.xsl
Eventually, I'd like a thumbnail directory of all the links of Ftrain; this is a first draft and will grow in time. It's currently
not run when I build the site.
ftrain_data.xsl
A placeholder script.
build
A shell script that calls everything; pretty straightforward to anyone who has dealt with unix, and fairly straightforward
in general.
mirror
Mirrors the /xml and /art directories and then runs the build script on a remote machine.
util_flog.cgi
A perl CGI script that makes organizing sites into hierarchies practically fun! As I browse through the Infobahn, when I see
a site I like, I click on a button on my browser - a bookmarklet - that calls the following code:
That code puts the title and the name of the link into the right fields; I fill in a category and a descriptions and submit. This then writes to a file in my xml/ directory called flog.xml, and that's what's turned into the links via the XSLT scripts described above.