Software / code / verse
Comparison
plugins/browsing.lua @ 466:1eaec52ff71a
browsing: whitespace fixes
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 17 Mar 2023 09:23:56 +0000 |
| parent | 403:6f4f60ebb796 |
comparison
equal
deleted
inserted
replaced
| 465:6707e3a47f71 | 466:1eaec52ff71a |
|---|---|
| 4 | 4 |
| 5 function verse.plugins.browsing(stream) | 5 function verse.plugins.browsing(stream) |
| 6 stream:add_plugin("pep"); | 6 stream:add_plugin("pep"); |
| 7 function stream:browsing(infos, callback) | 7 function stream:browsing(infos, callback) |
| 8 if type(infos) == "string" then | 8 if type(infos) == "string" then |
| 9 infos = { uri = infos; }; | 9 infos = {uri = infos}; |
| 10 end | 10 end |
| 11 | 11 |
| 12 local link = verse.stanza("page", {xmlns=xmlns_browsing}) | 12 local link = verse.stanza("page", {xmlns = xmlns_browsing}) |
| 13 for info, value in pairs(infos) do | 13 for info, value in pairs(infos) do |
| 14 link:tag(info):text(value):up(); | 14 link:tag(info):text(value):up(); |
| 15 end | 15 end |
| 16 return stream:publish_pep(link, callback); | 16 return stream:publish_pep(link, callback); |
| 17 end | 17 end |
| 18 | 18 |
| 19 stream:hook_pep(xmlns_browsing, function(event) | 19 stream:hook_pep(xmlns_browsing, function(event) |
| 20 local item = event.item; | 20 local item = event.item; |
| 21 return stream:event("browsing", { | 21 return stream:event("browsing", { |
| 22 from = event.from; | 22 from = event.from; |
| 23 description = item:get_child_text"description"; | 23 description = item:get_child_text "description"; |
| 24 keywords = item:get_child_text"keywords"; | 24 keywords = item:get_child_text "keywords"; |
| 25 title = item:get_child_text"title"; | 25 title = item:get_child_text "title"; |
| 26 uri = item:get_child_text"uri"; | 26 uri = item:get_child_text "uri"; |
| 27 }); | 27 }); |
| 28 end); | 28 end); |
| 29 end | 29 end |
| 30 | 30 |