« googleapi for radio | Home | Library cats »

April 11, 2002

Code for using first para as RSS summary in Radio

Following up on Jon Udell's discussion of reducing the size of RSS summaries, and later Dave Winer's implementation of a callback to make this possible, and then my note on CNN.com's practice of using the first 'graph as a summary, I believe I've made it all work.

As Dave suggested, I defined my own callback in weblogData.callbacks.rssFilterDescription:

on firstPara(description, adrpost) {
 return (html.getOneTagValue(description,"P"))}
 

The description is stored in HTML, so getOneTagValue conveniently does exactly what I want.

Of course, if the first tag in my description isn't a P, this won't do what I want it to do.  I'll work on that another time. 

Side note on figuring this out: I spent what seemed like hours trying to make this work with regex.split (which basically worked if you split at </P>) and regex.extract (which never seemed to work.)  Extract was particularly annoying: I had a pattern that looked something like "<P>.*</P>".  Although the documentation of regex.extract suggested that the * would grab the minimum number of characters to make a match work, the * in fact seemed to be greedy: it appeard to match the entire description, which of course starts with a <P> (for the first 'graph) and ends with a </P> (which is actually part of the last 'graph, not the first.)