Project
bx-feeds
RSS, Atom, JSON Feed and OPML for BoxLang, built for feed readers. It finds the feeds behind a pasted address, fetches them with a conditional GET, and parses any format into one plain struct with a stable id on every item. XML is parsed by ROME; the module adds what a reader needs on top of it.
One shape for every feed
RSS 0.9x to 2.0, Atom and JSON Feed come back as the same struct: UTC dates or null, absolute URLs, and an item id to dedupe on even when the feed gives none.
Fetching that behaves
If-None-Match and If-Modified-Since, permanent-redirect reporting, a timeout and a size limit, fallback User-Agents, bot-check detection and a pause for sites that answer 429.
Find, import, subscribe
findFeeds() for an "add a feed" box, parseOpml() and toOpml() for subscription lists, and webSub() so a feed's hub pushes new posts to you.
Safe with strangers' XML
No DTD is ever read, so XXE and entity-expansion attacks don't work, and fetches refuse private network addresses. Broken real-world feeds are repaired and read through.
bx-rss to port cffeed code or publish a feed; use bx-feeds to subscribe to other people's. How the two differ.bashinstall-bx-module bx-feeds
javascript// "add a feed": whatever was pasted, to the feeds behind it
found = findFeeds( "example.com/blog" )
// poll it, sending back what the last fetch returned
result = fetchFeed( found[ 1 ].url, { etag: saved.etag, lastModified: saved.lastModified } )
if ( len( result.permanentUrl ) ) {
// the feed moved for good: save result.permanentUrl as its address
}
if ( result.status == 200 ) {
for ( item in result.feed.items ) {
// item.id, item.title, item.link, item.published, item.contentHtml
}
// save result.etag and result.lastModified for next time
}