The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
New "Reading Room" Blosxom Plugin

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Joey Gibson

Posts: 71
Nickname: joeygibson
Registered: Jun, 2003

Joey Gibson is an opinionated software architect who blogs about technology, politics, music, etc.
New "Reading Room" Blosxom Plugin Posted: Feb 3, 2004 8:33 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Joey Gibson
Latest Posts From Joey Gibson's Blog

Advertisement
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:
<dl>
	<dt>$reading_room::Author</dt>
	<dd><a
	href="http://www.amazon.com/$reading_room::ISBN/XXX">
	   $reading_room::Title</a>
	<br/>$reading_room::Rank</dd>
</dl>
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.

Read: New "Reading Room" Blosxom Plugin

Topic: Standard Library Documentation Available on Ruby-doc.org Previous Topic   Next Topic Topic: RubConf.new(2003) (Friday)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use