New “Reading Room” Blosxom Plugin

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. Tolkien|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.

Update: I’ve now packaged the distro up as a zip file for those of you who may be having problems with the tarball. Get it here.

New Version of My Google Blosxom Plugin

I’ve finally gotten around to updating my Google plugin for Blosxom that’s been languishing for several months now. No longer must you use the cheesy ‘KW:’ style keywords; I now use the Meta plugin, so you can add a meta-google_keywords: line in your meta area and get the same effect. I’ve left the old style support in, so if you’ve been using it, you don’t have to go through and change all your stories to the new format.

Thus, the old style was:

and the new-and-improved style is:

meta-google_keywords: comment spam

One caveat: make certain that the meta plugin runs before this one or your google links will show up one story too late. That took a while to track down. I renamed my meta plugin to 00meta and now all is well.

Get it here and please let me know if you have problems with it.

User-Agent Based Content Inclusion Plugin

I’ve just released a new Blosxom plugin called UAInclude that allows you to include specific content in the section of a page, based on the User-Agent of the user’s browser. This came about because when I added Todd’s nice Categories plugin. My pages looked great with Moz or other sane browsers, but they looked like crap with IE. The reason for the difference is that IE and Moz render various styles differently, and my painstaking design was suffering because of it. Todd offered a solution, but while it made the pages look better under IE, they didn’t look as good under Moz.

Thus, I wrote this plugin. It’s driven by a hash of regexes that map to (possibly non-existent) files relative to $blosxom::datadir. Each of these regexes are compared against the User-Agent from the current user’s browser to decide which content to include. A variable called $uainclude::included_content is exposed and should be added inside the section in your head.html flavour file. This variable will contain the text of the matching file, or will be empty if the matching file doesn’t exist. (An example of when this would be useful is for a browser like Lynx which is a text-only browser; it will ignore styles, so why send them?) If nothing matches, there’s a default that will be served up, to account for all the browsers that I don’t know about.

This may not be useful to anyone but me, but I wanted to make it available. Get it here and let me know if it’s useful to you or you have suggestions for improvements.

UAInclude could certainly be generalized to support more than just head-related stuff, but I didn’t feel like thinking about it that much. If there are requests for that, I’ll think about it some more.

My Blosxom 2.0 Google Plugin

I’m releasing a preview version of my Google plugin for Blosxom 2.0. We’ve all seen blog entries with a little “G” or “Google” that when clicked execute a search at Google for something related to the blog topic. I’ve seen those that strictly took the article title and used all those words in the query, but I wanted more control. So in my plugin I inspect the first line of the blog entry body, and if it starts with “KW:” (user-configurable) then the rest of that line is taken as keywords. These keywords are joined with “+” signs and tacked onto a configurable Google search query URL. For example, if the first line of the body (obviously after the title) looked like this:

 	KW: fox news channel 

then the resulting URL (assuming no config changes) would look like this 

and would show up in the story as “| Google”.

The look of the link is also user-configurable. You can see from all of my entries that I use a pipe, then the word “Google” but you can use whatever you want. In order to get the link, just include $google::google in your story.html and that’s it.

There’s also a setting that will make the link open in a new window or not.

What license are people using for this type of stuff? I read through the Blosxom license but I couldn’t tell if it was one of the “well known” licenses or not. I think I lean towards LGPL, but the alphabet soup of licenses is somewhat hard to get through. Do I even need to license this?

This is a 0.1 release with very little in the way of docs other than this entry and the sparse comments in the code. Get it here

If you use this plugin, please let me know. If you have suggestions/comments/complaints send me an email.


Thanks to the rapid suggestions of Todd Larason I’ve made some changes to the plugin to make it better. Here’s what I did:

The new version is available here and the old version from here just in case I messed something up!

Again, please let me know of anything else!

New Version of Blosxom

Ooo yah! I checked my email this morning and see that Rael has dropped a new version of Blosxom. It’s 2.0 beta1 and it sports a new plugin architecture and other nifty features. I’ve gotten it setup on my local box and have ported some code I’d written against the 0+5i release to the new plugin format. I’ll be getting this site up with the new version later today I suspect.

Googling From Blosxom

I’ve made a few changes to my copy of Blosxom to add the little “Google” link you see at the end of this entry. I’ve seen this on other blogs here and there so I decided to add it to mine. It consists of a subroutine called buildGoogle that takes the second line of each story file and builds the Google URL with the query string built from your keywords. The second line of the file will only be used as keywords if the line starts with KW:. If it starts with anything other than that, it will be included as part of the body. For example, a file with this

KW: blosxom perl blog

as its second line will produce this

 | Google

To include the link itself in your stories, edit your story.html and add $google wherever you want the link to show up. If the link was not built because you didn’t have a KW: line, then nothing will show up. This is from my story.html. Notice it comes right after code creating the perma-link.


Here is the patch if you would like to use it.