ATG RSS Generator Droplet

I sat down a few hours ago to start a droplet which would generate an RSS feed based on data in an ATG Repository. Surprisingly, I think I’m done.

Basically what it is is a droplet, which you put on an otherwise empty JSP page (it’s important that there is no whitespace on the JSP as well). You configure the droplet via it’s .properties file to point to a Repository, and you give it an item descriptor, which will be the primary item to use for the data in the feed. You then configure a bunch of mostly optional data points for the channel data of the RSS feed (this includes things like the main site link, the RSS feed title and description, and optional elements like author, copyright information, etc…

Then you provide the property names (and nested “.” driven properties are okay here) for the various elements of the RSS Item like title, link, description, publish date, etc… Currently it sorts based on the publish date property, to provide items in newest-to-oldest order. I may support a separate sort property later on if people want one.

Since many repository items may not have a usable link property, you can pass in a itemLink property value with an embedded property (also supporting nested properties, and supporting the special repositoryId). For instance you can do this:

itemLink=/catalog/product.jsp?productId=#{repositoryId}

or even something like:

itemLink=http://#{author.homepageURL}?referrer=mySite

The JSP page, when hit, generates a nice RSS 2.0 compliant feed based on the data in the Repository.

You can also include the following in your <head> element of your site’s main page to get the nice automatic feed discovery in many browsers:

You can download the entire package here. This includes the source, a heavily commented properties file, a jsp file, and a jar file to load into your classpath.

Some examples where you might want to use this: Blog, Newsletter, any site with updated content, a commerce site’s catalog, discussion forums, etc…..

Enjoy!


Posted

in

,

by

Tags:

Comments

6 responses to “ATG RSS Generator Droplet”

  1. Matt Sidesinger Avatar
    Matt Sidesinger

    FYI, You could have used the StrSubstitutor in the code that resolves variables in the itemLink property.

    http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrSubstitutor.html

  2. Doug Henderson Avatar

    Hey Devon,
    Thanks for sharing this code with the world. We just recently decided to use RSS feeds
    for our press releases. So I pointed the repository to our PR rep, and used the title and
    publishDate as the items to expose and sort by. But I am having trouble with the end
    game here. That is, using the above “link href” the Firefox 2 and Sage RSS readers don’t
    seem to want to recognize the channel/feed as RSS and instead spew the rendered
    contents on the jsp page, rather than have them be discoverable feeds. I am using your
    rss.jsp page and the droplet is communicating fine with results. Did you ever have such
    a problem and perhaps could shed light on what I might be doing wrong here?
    Thanks, Doug

  3. Devon Avatar

    Hmm. Honestly I only tested it using the Safari built-in RSS reader, so it’s possible that the other readers need a special content type header or something? I don’t have a good answer for you, but I’m happy to work with you to figure it out. Do you have any sample code you can send me or a world facing URL? Feel free to e-mail me: [email protected]

  4. Devon Avatar

    For all of you who are following along at home: the moral of this story is to not reformat the JSP or the added whitespace breaks picky RSS readers.

    I’ve also identified a few other areas where my output isn’t 100% in line with the strict spec, which I will work on fixing when I get back from France. However, it seems to work with most readers as is, so don’t hesitate to use it.

  5. […] me some code updates I have released a new version of the RSS Feed Droplet (first mentioned in this post) which supports configurable character encodings. This can be very useful if you have “interesting” […]

Leave a Reply

Your email address will not be published. Required fields are marked *

PHP Code Snippets Powered By : XYZScripts.com