1 local io, string = io, string; |
1 local io, string = io, string; |
2 local error = error; |
2 local error = error; |
3 local print = print; |
3 local print = print; |
|
4 local t_insert = table.insert; |
|
5 local ipairs = ipairs; |
4 |
6 |
5 local http = require "socket.http"; |
7 local http = require "socket.http"; |
6 local st = require "stanza"; |
8 local st = require "stanza"; |
7 local new_stream = require "xmlstream".new; |
9 local new_stream = require "xmlstream".new; |
8 |
10 |
9 local xmlns_atom = "http://www.w3.org/2005/Atom"; |
11 local xmlns_atom = "http://www.w3.org/2005/Atom"; |
10 |
12 |
|
13 --[[ |
|
14 By popular request; a fluffy bunny: |
|
15 |
|
16 (\ /) |
|
17 (. .) |
|
18 c(")(") |
|
19 |
|
20 --]] |
|
21 |
11 module "feeds" |
22 module "feeds" |
12 |
23 |
13 local translate_entry = {}; |
24 local translate_entry = {}; |
14 |
25 |
15 function translate_entry.atom(feed, stanza) |
26 function translate_entry.atom(feed, stanza) |
16 if stanza.name == "entry" then |
27 if stanza.name == "entry" then |
17 feed[#feed+1] = stanza; |
28 feed[#feed+1] = stanza; |
|
29 elseif stanza.name == "author" then |
|
30 feed.author = {}; |
|
31 for i,a in ipairs(stanza) do |
|
32 if a.name and a[1] then |
|
33 feed.author[a.name] = a[1]; |
|
34 end |
|
35 end |
|
36 elseif stanza.name == "link" then |
|
37 if not feed.links then feed.links = {}; end |
|
38 if stanza.attr.href then |
|
39 if stanza.attr.rel then |
|
40 feed.links[stanza.attr.rel] = stanza.attr.href; |
|
41 else |
|
42 t_insert(feed.links, stanza.attr.href) |
|
43 end |
|
44 end |
18 else |
45 else |
19 feed[stanza.name] = stanza:get_text(); |
46 feed[stanza.name] = stanza:get_text(); |
20 end |
47 end |
21 end |
48 end |
22 |
49 |