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/"; |
5 local xmlns_activitystreams = "http://activitystrea.ms/spec/1.0/"; |
6 local activitystreams_schema_base = "http://activitystrea.ms/schema/1.0/"; |
|
7 |
6 |
8 return function (opts, arg) |
7 return function (opts, arg) |
9 if opts.short_help then |
8 if opts.short_help then |
10 print("Publish an Atom entry to a pubsub node"); |
9 print("Publish an Atom entry to a pubsub node"); |
11 return; |
10 return; |
36 if opts.content then |
35 if opts.content then |
37 atom_entry:tag("content", { type = opts["content-type"] }):text(opts.content):up(); |
36 atom_entry:tag("content", { type = opts["content-type"] }):text(opts.content):up(); |
38 end |
37 end |
39 |
38 |
40 for opt, optval in pairs(opts) do |
39 for opt, optval in pairs(opts) do |
41 if opt:match"^as_" then |
40 if opt:match"^as%-" then |
42 atom_entry:tag(opt:sub(4):gsub("_", "-"), { xmlns = xmlns_activitystreams } ) |
41 atom_entry:tag(opt:sub(4), { xmlns = xmlns_activitystreams } ) |
43 :text(activitystreams_schema_base..optval):up(); |
42 :text(optval):up(); |
44 end |
43 end |
45 end |
44 end |
46 |
45 |
47 conn.pubsub(opts.service, opts.node):publish(entry_id, nil, atom_entry |
46 conn.pubsub(opts.service, opts.node):publish(entry_id, nil, atom_entry |
48 , function(ok) |
47 , function(ok) |