clix/publish_atom.lua

changeset 97
83cd777fb294
parent 96
a2214d821394
child 111
ab7e4845b6c1
equal deleted inserted replaced
96:a2214d821394 97:83cd777fb294
1 local new_uuid = require "util.uuid".generate; 1 local new_uuid = require "util.uuid".generate;
2 local datetime = require "util.datetime".datetime; 2 local datetime = require "util.datetime".datetime;
3 3
4 local xmlns_atom = "http://www.w3.org/2005/Atom"; 4 local xmlns_atom = "http://www.w3.org/2005/Atom";
5 local xmlns_activitystreams = "http://activitystrea.ms/spec/1.0/";
6 local activitystreams_schema_base = "http://activitystrea.ms/schema/1.0/";
5 7
6 return function (opts, arg) 8 return function (opts, arg)
7 if opts.short_help then 9 if opts.short_help then
8 print("Publish an Atom entry to a pubsub node"); 10 print("Publish an Atom entry to a pubsub node");
9 return; 11 return;
38 40
39 if opts.content then 41 if opts.content then
40 atom_entry:tag("content"):text(opts.content):up(); 42 atom_entry:tag("content"):text(opts.content):up();
41 end 43 end
42 44
45 for opt, optval in pairs(opts) do
46 if opt:match"^as_" then
47 atom_entry:tag(opt:sub(4):gsub("_", "-"), { xmlns = xmlns_activitystreams } )
48 :text(activitystreams_schema_base..optval):up();
49 end
50 end
51
43 conn.pubsub(opts.service, opts.node):publish(entry_id, nil, atom_entry 52 conn.pubsub(opts.service, opts.node):publish(entry_id, nil, atom_entry
44 , function(ok) 53 , function(ok)
45 -- TODO Report success? 54 -- TODO Report success?
46 conn:close(); 55 conn:close();
47 end); 56 end);

mercurial