|
|
||||
rssTruncate macro |
||||
|
#title "rssTruncate" #opmlStory "http://radio.weblogs.com/0104487/gems/opml/rssTruncate.opml" #renderOutlineWith "activeRenderer" What is rssTruncate ? rssTruncate is a UserTalk macro command that shortens the xml/rss published version of each post to its title and first paragraph or sentence. If the post is longer, a [read more] link to the HTML rendered version of the full post is appended. In addition, any image inserted within the first paragraph/sentence is replaced by the [img] marker. Why add truncation to the rss feed ? To make posts more readable in a news aggregator. The first sentence or paragraph of each post should provide a clear indication of what the post is about, in addition to the post's title. Subscribers interested in the post can access the full version by clicking on the [read more] link. With Radio, the post's title usually provides the same link, but you can post without a title (a bad habit :-), or provide a different link for the title (something I do often in s l a m). Installing rssTruncate. 1. Display the rssTruncate code in a new browser window by clicking on this link. 2. Select all the code's text and copy it. 3. In Radio, open the weblogData.callbacks.rssFilterDescription table. 4. Double-click on the empty 'item #1' item, enter rssTruncate as name, and Script as type, then click zoom. 5. In the script editor window that pops up, paste the text of the rssTruncate script. 6. Delete all empty lines before: on rssTruncate (description, adrpost ) 7. Click the compile button, then close the script editor window. That's it, rssTruncate is ready for your next post. 8. If you want to see rss truncation in action : First subscribe to your own weblog. Then post a new message. Then quit and restart Radio, and check the last published message in Radio's News Aggregator. How does it work ? rssTruncate tries to retrieve the first HTML paragraph of the post, using html.getOneTagValue ( description, "P" ) ) The first HTML paragraph is any string encapsulated by the <p> and </p> tags. The tag is not case sensitive. If there is no formal HTML paragraph to retrieve, rssTruncate gets the first sentence of the post, using string.firstSentence ( description ). The first sentence is any string preceding a dot followed by a 'whitespace' character. In that case, any leading <p> tag, part of a malformed HTML 4.0 paragraph is stripped from the sentence. The length of the first paragraph/sentence is then compared with the length of the full post description, stripped of any leading/trailing paragraph tags. If the full description is longer than the first paragraph/sentence, the [read more] link is appended. The link is computed by starting with the weblog home url returned by radio.macros.homePageUrl(). Then a path to the post's page is computed out of the post's date, accessed through rssTruncate's second parameter: the address of the post's table in weblogData. Finally, an anchor within the page is added, based on the post's item number. The last step is to remove any image included in the first paragraph/sentence. The img html tag is any string starting with <img, followed by any number of characters different from >, followed by >. The whole <img> tag is replaced by an [img] marker. The completed abbreviated description is then returned to the rss publishing routine. Credits rssTruncate originates from a hack by Jon Udell, who can be considered the pioneer of rss truncation. Dave Winer then added a callbacks table to rss publication, making this hack both cleaner and supported by UserLand. Paul Holbrook came up with the idea of using the first HTML paragraph of each post instead of the first sentence. |
© copyright 2004 |
|||