codahale.com٭blog

Coda Hale lives in Berkeley, CA, where he writes about Ruby on Rails, usability, web design and development, and the occasional bit about bicycles.

BloglinesReader

BloglinesReader is a WordPress plugin which will download a list of websites that you monitor via Bloglines and display them in your WordPress blog. You can specify which folder in your feeds you want to limit the results to, as well as how you want the results displayed. It has the benefits of an integrated administration panel as well as the ability to format the output to integrate into your blog’s design.

It will work with both WordPress 1.5.x and 2.0.x.

Download

You can download BloglinesReader here:

v0.2: bloglines-reader-0.2.zip/bloglines-reader-0.2.tar.gz

If you have any questions, feel free to email me at coda dot hale at gmail dot com.

Install

Extract the file bloglines-reader.php from the archive, and copy it to your WordPress plugins directory (which should be /wp-content/plugins/). Go to the Plugins page in the administration interface, and click the Activate link for BloglinesReader. Next, go to the BloglinesReader submenu of the Options page and enter your Bloglines username. If you’d like to limit the feeds displayed to just one folder, enter the folder’s name into the Base Folder field. Click the Save button.

Use

Finally, you’ll have to edit your WordPress template to add the function call which actually does the displaying.

Adding the following to your sidebar will display a set of nested unordered lists:

if ( function_exists('showBloglinesReader') ) {
  showBloglinesReader();
}

The output will look something like this:

<ul>
  <li><a href="http://www.example-one.com">Example One</a></li>
  <li>Folder 1
    <ul>
      <li><a href="http://www.example-two.com">Example Two</a></li>
    </ul>
  </li>
</ul>

Formatting Defaults

There are two ways to customize the formatting of showBloglinesReader().

First, you can tell showBloglinesReader() which formatting preset to use. Currently, there’s only one preset ('unorderedList'), but this will change in later releases. To use a preset, simply call showBloglinesReader() with an additional parameter:

if ( function_exists('showBloglinesReader') ) {
  showBloglinesReader('unorderedList');
}

Right now this isn’t terribly useful, but once I start to add formatting defaults, it’ll make sense.

Advanced Formatting

If you’re anything like me, you’re incredibly picky about what your website looks like, and with BloglinesReader you can customize every aspect of its display. To do this, you need to pass showBloglinesReader() a blank first parameter and an associative array as the second parameter. The blank first parameter tells showBloglinesReader() that you’re supplying your own formatting, and then the associative array contains the formatting strings. The array should look like this:

$formats = array(
 'beginFeeds' => '<ul class="links">',
 'endFeeds' => '</ul>',
 'beginFolder' => '<li>%title%<ul class="links">',
 'endFolder' => '</ul></li>',
 'beginLink' => '<li><a href="%url%">%title%</a></li>',
 'endLink' => '');

Each string can contain the following stubs:

  • %url%: The URL of the website (not the feed)
  • %title%: The feed’s title
  • %type%: The feed’s type (almost always RSS, I think)
  • %feedurl%: The feed’s URL (i.e., the XML feed, not the website)

And each formatting array needs to have the following elements:

  • beginFeed: Begins the list of feeds. Usually a wrapping <ul> or <div>.
  • endFeed: Ends the list of feeds. Usually closes the element introduced in beginFeed.
  • beginFolder: Begins a folder. The name of the folder is in %title%.
  • endFolder: Ends a folder.
  • beginLink: Begins a feed item, the details for which are in %title%, %url%, %type%, and %feedurl%.
  • endLink: Ends a feed item, and is never really called with any information. Might as well be blank.

Thanks & Credit

A lot of credit goes to my friend, Peter Dolan, who worked on this plugin first and talked me down from making it Ajax-y (“Why does it need Ajax?” “Well… umm… man, just check out Dojo!” “Yeah, but why does it need Ajax?”). He’d be the one making this plugin, but he’s got a day job.

If you have any questions, feel free to email me at coda dot hale at gmail dot com.