# HG changeset patch # User Kim Alvefur # Date 1296440873 -3600 # Node ID 4afd0e6206b288baee069675f2b589a940a19e6c # Parent 58d3cecc68b75401040fdb7216233c2768fa0fc7 Add special handling of author and link elements, and a fluffy bunny diff -r 58d3cecc68b7 -r 4afd0e6206b2 feeds.lua --- a/feeds.lua Mon Dec 06 04:39:22 2010 +0000 +++ b/feeds.lua Mon Jan 31 03:27:53 2011 +0100 @@ -1,6 +1,8 @@ local io, string = io, string; local error = error; local print = print; +local t_insert = table.insert; +local ipairs = ipairs; local http = require "socket.http"; local st = require "stanza"; @@ -8,6 +10,15 @@ local xmlns_atom = "http://www.w3.org/2005/Atom"; +--[[ +By popular request; a fluffy bunny: + + (\ /) + (. .) +c(")(") + +--]] + module "feeds" local translate_entry = {}; @@ -15,6 +26,22 @@ function translate_entry.atom(feed, stanza) if stanza.name == "entry" then feed[#feed+1] = stanza; + elseif stanza.name == "author" then + feed.author = {}; + for i,a in ipairs(stanza) do + if a.name and a[1] then + feed.author[a.name] = a[1]; + end + end + elseif stanza.name == "link" then + if not feed.links then feed.links = {}; end + if stanza.attr.href then + if stanza.attr.rel then + feed.links[stanza.attr.rel] = stanza.attr.href; + else + t_insert(feed.links, stanza.attr.href) + end + end else feed[stanza.name] = stanza:get_text(); end