leah blogs

May 2004

28may2004 · Nukumi

During the last two days, I’ve been writing Nukumi, my new weblog system.

So far, “chris blogs” has been generated by a bunch of ruby scripts, Makefiles and XSLT stylesheets. This was by no means bad; it was very effective and just worked. But it also was very brainless. I had no way to do “real” permalinks, and the archive support I added recently was a kludge.

Therefore, I have been dropping the Makefile stuff and replaced it with some clever script. The pages are still generated with XSLT, because it’s the easiest way to get multiple output formats (so far, XHTML, RSS and Atom) from a single source.

However, the new system is much more flexible at this. While the only script, dubbed xml2entries.rb as you may notice, just outputted the last 15 entries (or all of them, if supplied the --archive parameter), into xsltproc, the new one supports multiple views of the same entry base.

My configuration code so far is:

#        Extension Stylesheet         Views
n.flavor "html",   "xml2xhtml.xsl",   :ALL
n.flavor "rss",    "xml2rss.xsl",     :front
n.flavor "atom",   "xml2atom.xsl",    :front

First, we define several flavors (term stolen from Blosxom) for the different output formats.

The second part is more interesting, however:

#        Name      Prefix      Hashfunc
n.view   :archive, "archive-", proc { |e,i| e.time.strftime("%Y-%m") }
n.view   :daily,   "entry-",   proc { |e,i|
  e.time.strftime("%Y-%m-%d-") + \
    e.header["Subject"].downcase.
    gsub(/[^a-z]/, '_').squeeze('_')
}
n.view   :front,   "index",    proc { |e,i|
                                        i < FRONT_LENGTH ? "" : nil
                                    }

The Hashfunc maps every entry onto a string which they get grouped by. The first entry just generates archives for each different month, that is 2004-05, 2004-04 etc.

The second one generates a permalink file for each entry of the form 2004-03-27-kurt_cobain_jokes, providing some context to the person coming from an external page.

Finally, it generates the index page (inclusive feeds in RSS and Atom) for all entries appearing before FRONT_LENGTH.

All these views get generated in each defined flavor into a file which has the flavor extension appended.

Note that all this is very efficient: Only the files which are new or would get changed (i.e. modification time of any entry in the file is newer than the entry itself) get generated anew.

Nukumi, which has its name from the japanese word for “warmth” (which was missing to the Makefile approach… :-)), works already very nicely, though I spend only about 5 hours coding it. I’ll relase it when I’m back from holidays.

I’ll be away for the next week till Sunday, and not be able to blog during that period.

NP: Beatsteaks—Big Attack

Copyright © 2004–2022