Archive

Posts Tagged ‘RSS’

Adding an RSS Feed to a Data-Driven Website

May 25th, 2009 Richard Luck No comments

One of the things I love about Bluyah is how quickly it can solve a variety of feature requests made of an application.  As an IT professional, I’m constantly weighing the time it will take to develop an application feature against the benefit that feature will provide to the end-users.  In some cases it comes down to simple math: will it cost our company more (in terms of a developer’s salary) than this feature will return (in terms of revenue)?  In other cases it’s much more subtle - especially when dealing with web properties that don’t have a straight-forward revenue model.

Case in point: Pif Magazine (www.pifmagazine.com).  

Pif Magazine has been online for nearly 15 years now.  It is one of the oldest, continually published literary journals on the Net.  It has published original works by well-known authors like Julia Slavin, Amy Hempel, and Poet Laureate  David Lehman.  It has also introduced countless unknown, previously unpublished authors and poets who have, because of their exposure in Pif, gone on to land contracts with traditional publishers.

In short, it’s an important venue with a very dedicated following.

One thing it is not, however, is technologically up-to-date.  The content management system used by the editorial staff is a highly customized version of PHP-Nuke 5.2 (codenamed: SIDney), which was deployed in the spring of 2001 and, save a few minor visual enhancements, has not been upgraded since.  It may sport a robust publication contracting system, but it lacks basic modern features. 

So when the editorial team recently asked me to add RSS capabilities to the site so they could syndicate the newly published articles, my first reaction was: “Well, there goes my weekend.”  Then, just as quickly I realized: “Hey - I can do this in Bluyah in about 3 minutes.”

Step 1: Getting the Data

This first step is always the most difficult.  Every application has it’s own database schema and SIDney is no different.  Only with SIDney, the schema is complicated by the fact that author information is (for historical reasons) stored in a separate database from article information.  In addition, the author’s email address is stored in a separate table from the author’s first and last name.  Just to complicate matters even more, the SIDney application allows editors to control things like title wrapping with special comment tags.  

To work around all of these inconveniences, I decided that the easiest way to gain access to all of the data bits I needed for an RSS feed would be to create a database view against the articles database and then point Bluyah at this view.

The view structure looks similar to this:

CREATE OR REPLACE SQL SECURITY INVOKER VIEW PIF_RSS_VIEW AS
SELECT
    CONCAT('http://www.pifmagazine.com/SID/',s.sid) AS link, 
    REPLACE("<!--titlebreak-->"," ") AS title,
    REPLACE(REPLACE(s.hometext,"\\'","'"),'\\"','') AS description, 
    s.pubdate,
    t.topictext, t.topicname,
    us.username as email,
    CONCAT(ui.fname,' ',ui.lname) AS author,
    ui.city, ui.state, ui.zipcode
FROM ARTICLE.stories s
    JOIN ARTICLE.topics t ON (s.topic=t.topicid)
    JOIN USER.user us ON (s.uid=us.uid)
    JOIN USER.userinfo ui ON (us.uid=ui.uid) 
ORDER BY s.pubdate DESC
LIMIT 20

Once the database view was defined and created, the rest was a snap.

Step 2: Connecting to the View

In Bluyah, I already had a Database Connection created for the Pif Magazine database.  I just needed to “discover” the newly created view and user it in a report.  To discover the view, I went to the Connect tab, found the already existing connection, then clicked on the “List DB Tables/Views” link in the Action column:Link DB Tables/Views
This will bring up a list of all tables and database views in your database.  Finding the newly created view, I clicked on the link “Use in New Report” in the Action column:

rss2

This brought me to the Report Create screen that you’re already familiar with from other posts.  Being that the view already contained the column names I wanted to see in my report, I simply clicked the Create Report button and went straight to the Export tab.

Step 3: Creating the RSS Export

I spent the most time on this screen trying to decide what to input into the free-form fields:

RSS Export Screen

Everything on the left-hand side of the screen describes the feed itself, while everything on the right-hand side of the screen describes the individual listings in the feed.  As such, everything on the left-hand side of the screen will need to be provided by you when you create the RSS export.  Don’t worry - if you don’t like what you’ve input into the fields you can always come back later and update them.

For the most part, you can see that the database view I created contained field names very similar to what they would map to in the RSS Item screen.  I did this on purpose to speed deployment - but you could name your columns anything you want to and simply map them to the RSS Item attributes as appropriate on this screen.

Step 4: Embedding in the Website

Once the RSS Export was created, I pointed my browser at the URL Bluyah provided by clicking on the “Get Link” link in the Action column:

RSS Get Link

As you can see, the results are a standard RSS feed:

     https://richard.bluyah.com/export/rss/89387b6026e5012c6ef9002241319b39

Rather than use the IFRAME embed code provided by Bluyah (above) I decided I wanted a simple RSS icon hyperlinked to the feed instead.  If you checkout the homepage of Pif Magazine you’ll see the feed icon at the top-left of the screen.  

Final Thoughts

To me, the speed at which this feature was deployed to Pif is absolutely amazing.  Rather than spend 2-3 days writing an RSS feed generator into the code base (including testing and deployment), I spent a little over 10 minutes creating the database view, another 2 connecting to that view through Bluyah, creating the report and RSS export, and finally another 2 minutes embedding the RSS image with hyperlink to the RSS feed into the side-nav of the website.  All total, it was less than 15 minutes from “soup to nuts”.  In terms of development costs, the magazine just saved itself roughly $500 - and turned around the feature far quicker.  What could be better?


Tweet This Share via Facebook Digg It! Add to Del.cio.us Add to Technorati Favorites Stumble It! Email this Print Friendly

Categories: Eating Our Own Dogfood Tags: ,

Google Map from RSS Feed

April 5th, 2009 admin 1 comment

Here we present a screencast demonstrating the steps you would go through to create a Google Map from an RSS feed, as was described in the post “Fun With Google Maps“:


Tweet This Share via Facebook Digg It! Add to Del.cio.us Add to Technorati Favorites Stumble It! Email this Print Friendly

Fun with Google Maps

February 14th, 2009 Richard Luck No comments

With version 0.4.4 of the code base we introduced Enhanced Maps which allow you to easily control the marker color and the contents of the “bubble” that displays when you click on the marker.  

With these new features, creating robust, data-driven maps become an extremely easy thing to pull off.

Case in point:

The USGS publishes an RSS feed that contains data on all of the earthquakes that have occurred over the past 30 days.   We went from feed to map in about 3 minutes by doing the following:

 

  • I created a new Atom/RSS connector.  The input screen only required I give it a memorable name and input the feed’s URL.
  • Once saved I clicked on the “Report” link for the newly established connector.  This brings up the Report Edit screen:

 

Report Edit Screen Shot 

  • On this page I changed the ‘pubDate’ column to ‘Reported’ and changed the ’summary’ column name to read ‘Earthquake’.  You change the column name by clicking on the name itself.  I also hid a couple of columns I didn’t need by clicking the [x] box in the upper-right of the column header.  
  • Once I had saved the report (you can see the report in tabular format here - or as a CSV file here), I then clicked on the ‘Export’ link at the top of the screen, then the ‘New Map’ link and selected the newly created Report name.  The map edit screen has a few more configuration possibilities:

Map Edit Screen Shot

  • Because the data elements ‘lat’ and ‘long’ already existed in the RSS feed, they were automatically selected as the fields to be used by ‘Latitude’ and ‘Longitude’.  (If my data set had contained street addresses instead, I would have clicked the ‘Plot by Geocode’ link instead )
  • I only wanted the ‘Reported’ and ‘Earthquake’ columns from my report to show in the bubble that displays when a user clicks on a map marker, so I dragged them from the ‘Available Data’ box beneath the map, onto the bubble, and ordered them appropriately.
  • Saving the map resulted in this: 

Let us know your thoughts.  Or better yet ~ create a map of your own and send us the link.  We’d like to see what you’ve done.

[UPDATE] A screencast of this tutorial can now be found here.


Tweet This Share via Facebook Digg It! Add to Del.cio.us Add to Technorati Favorites Stumble It! Email this Print Friendly