Jan 09

Launchpad bug feeds in Wordpress

Filed under: Launchpad, UbuntuMatthew Revell at 5:20 pm

One of the goals we have for Launchpad is to offer different ways to get data in and out.

For example, in addition to the web interface we have an email interface for the Bug Tracker. For many people, the quickest way to file a bug is to fire off an email. Of course, it also provides a full range of options for editing and commenting on existing bugs.

Launchpad bugs feedIn Launchpad 1.1.12 we introduced bug feeds. Now, each bug, person, team, project and distribution in Launchpad has an associated Atom feed. I’ve used my bug feed on the home page of my website to give a flavour of what I’m working on. As I use Wordpress, which has built-in support for MagpieRSS, this was supremely easy.

Upgrade to the latest Wordpress

Before you begin, you should upgrade to the latest Wordpress. Previously, I was running 2.2.2 and it had some trouble with the Atom feed.

Pulling in the feed

First off, you need to pull in MagpieRSS, which is distributed with Wordpress.

I’ve created a sidebar specifically for the my site’s home page and I’ve got the following at the top of my home-sidebar.php template file:

<?
include_once(ABSPATH . WPINC . '/rss.php');
$myBugs = fetch_rss("http://feeds.launchpad.net/~matthew.revell/latest-bugs.atom");
$myBugsItems = array_slice($myBugs->items, 0, 4);
?>

The first line includes MagpieRSS and the next creates an array of the feed’s posts in $myBugs. I don’t have too much room in my side bar, so I use the last line to cut it down to the top four entries.

Displaying the feed

Actually displaying the feed is simple:

<ul>
<? foreach ($myBugsItems as $item ) {
	$title = $item[title];
	$url   = $item[link];
	echo "<li><a href=$url>$title</a></li>";
}

?>
</ul>

I’m looking to seeing how other people, in particular projects, use these new feeds.

Please post a comment or
contact me if you’re using Launchpad’s feeds or you have a suggestion for how we can improve them.

Update: two suggestions of easier ways to achieve the same effect. Dave Murphy suggested Wigitize.com (hat-tip Joey) and Jeremy Visser commented that Wordpress has a widget to embed a feed into your page.

Something I forget to put in the original post was that I’ve also used straight MagpieRSS (i.e. without Wordpress) to create an ugly but functional page at http://launchpad.understated.co.uk/. The code is pretty much exactly as shown in the Wordpress example above.

4 Responses to “Launchpad bug feeds in Wordpress”

  1. Some guy from the interwebs says:

    Aren’t you DDoS’ing launchpad this way? (Honest question, no flame intended)

  2. Matthew Revell says:

    Nah, this is what feeds are intended for. The feeds setup on Launchpad is built to handle exactly this sort of usage. Besides, the feed is cached at my end so doesn’t hit Launchpad each time the page is viewed.

  3. new bug feed, decent code snippets. | not waving but drowning says:

    […] by Mr Ultra lounge himself, I’ve made some upgrades. The sidebar to this blog now has a feed of the latest […]

  4. Jeremy says:

    Actually, it’s even easier if you use WordPress Widgets (built in to WP 2.3 and later), where you can just use the RSS widget to achieve exactly the same effect with no code.