plugins/browsing.lua

changeset 403
6f4f60ebb796
child 466
1eaec52ff71a
equal deleted inserted replaced
402:81b109281879 403:6f4f60ebb796
1 local verse = require "verse";
2
3 local xmlns_browsing = "urn:xmpp:browsing:0";
4
5 function verse.plugins.browsing(stream)
6 stream:add_plugin("pep");
7 function stream:browsing(infos, callback)
8 if type(infos) == "string" then
9 infos = { uri = infos; };
10 end
11
12 local link = verse.stanza("page", {xmlns=xmlns_browsing})
13 for info, value in pairs(infos) do
14 link:tag(info):text(value):up();
15 end
16 return stream:publish_pep(link, callback);
17 end
18
19 stream:hook_pep(xmlns_browsing, function(event)
20 local item = event.item;
21 return stream:event("browsing", {
22 from = event.from;
23 description = item:get_child_text"description";
24 keywords = item:get_child_text"keywords";
25 title = item:get_child_text"title";
26 uri = item:get_child_text"uri";
27 });
28 end);
29 end
30

mercurial