23 local function on_connect(conn) |
23 local function on_connect(conn) |
24 -- Required: id, title, updated, author (which must have a name) |
24 -- Required: id, title, updated, author (which must have a name) |
25 local entry_id = opts.id or new_uuid(); |
25 local entry_id = opts.id or new_uuid(); |
26 local atom_entry = verse.stanza("entry", { xmlns = xmlns_atom}) |
26 local atom_entry = verse.stanza("entry", { xmlns = xmlns_atom}) |
27 :tag("id"):text(entry_id):up() |
27 :tag("id"):text(entry_id):up() |
28 :tag("title"):text(opts.title or ""):up() |
28 :tag("title", { type = opts["title-type"] }):text(opts.title or ""):up() |
29 :tag("updated"):text(opts.updated or datetime()):up(); |
29 :tag("updated"):text(opts.updated or datetime()):up(); |
30 atom_entry:tag("author"):tag("name"):text(opts.author or os.getenv("USER") or "Unknown author"):up(); |
30 atom_entry:tag("author"):tag("name"):text(opts.author or os.getenv("USER") or "Unknown author"):up(); |
31 atom_entry:up(); |
31 atom_entry:up(); |
32 if opts.summary then |
32 if opts.summary then |
33 atom_entry:tag("summary"):text(opts.summary):up(); |
33 atom_entry:tag("summary", { type = opts["summary-type"] }):text(opts.summary):up(); |
34 end |
34 end |
35 |
35 |
36 if opts.content then |
36 if opts.content then |
37 atom_entry:tag("content"):text(opts.content):up(); |
37 atom_entry:tag("content", { type = opts["content-type"] }):text(opts.content):up(); |
38 end |
38 end |
39 |
39 |
40 for opt, optval in pairs(opts) do |
40 for opt, optval in pairs(opts) do |
41 if opt:match"^as_" then |
41 if opt:match"^as_" then |
42 atom_entry:tag(opt:sub(4):gsub("_", "-"), { xmlns = xmlns_activitystreams } ) |
42 atom_entry:tag(opt:sub(4):gsub("_", "-"), { xmlns = xmlns_activitystreams } ) |