This post originated from an RSS feed registered with Ruby Buzz
by Joey Gibson.
Original Post: New "Reading Room" Blosxom Plugin
Feed Title: Joey Gibson's Blog
Feed URL: http://www.jobkabob.com/index.html
Feed Description: Thoughts, musings, ramblings and rants on Java, Ruby, Python, obscure languages, politics and other exciting topics.
I've just released a new plugin for Blosxom called Reading_Room.
It is what I used to produce the "Reading Room" box at the bottom of
the page on the left.
The idea was to automate the creation of these boxes so I could do it
for books, records, films, etc. without having to write HTML each time. What
I ended up with is a data file + template setup where you put the
important information in a data file that you associate with a
template. At page load time the data are read from the file, replacing
the appropriate bits in the template for each record, and the output
shows up where you specify on your page. This is an example data file
called reading.dat:
reading
Author|Title|ISBN|Rank
J.R.R. Tolkein|The Lord of the Rings|0618260587|5
Fred Rogers|The World According to Mr. Rogers|1401301061|4
Richard Condon|The Manchurain Candidate|1568582706|2
Michael Crichton|Prey|0061015725|4
Andrew Burgess|A Clockwork Orange|0393312836|-1
The first line is the name of the template to use (it will have .tpl
appended to its name). The second line lists the columns that will
make up the following lines, in this case separated by a pipe. Each
additional line is one book, giving the author, title, the ISBN and a
ranking, which will be converted to stars. A 0 ranking will be
replaced with "Stinks!" and a -1 will be replaced with "Rating
Pending." Both of these are configurable, as is the graphic to use for
the stars.
The template file, called reading.tpl, looks like this:
And you can see that in the template each column's name shows up,
spelled and capitalized exactly as it is in the data
file.
A variable with the same name as the data file, without the .dat
extension, will be created in the $reading_room package, so to get our
"reading" list, we would add $reading_room::reading somewhere
in our blosxom flavour files, probably in head.html. Similarly if we
had a data file called "movies", then this HTML would be in the
$reading_room::movies variable.
I don't know if anyone other than me will find this useful or amusing,
but if you are game to give it a go, you can download it here.
The archive comes with the plugin itself, reading.dat and reading.tpl
as examples, and star.gif to get you started. Please let me know if
you find it useful and, more importantly, if you find bugs or have
problems with it.