comparison mod_pubsub_googlecode/mod_pubsub_googlecode.lua @ 951:ef54ae817689

mod_pubsub_googlecode: Split name and email when possible
author Matthew Wild <mwild1@gmail.com>
date Wed, 03 Apr 2013 18:49:27 +0100
parents 79b4a1db7a57
children d988f2db9773
comparison
equal deleted inserted replaced
950:bea0ef13575c 951:ef54ae817689
47 if what then break; end 47 if what then break; end
48 end 48 end
49 end 49 end
50 rev.message = "wiki ("..(what or "unknown page").."): "..rev.message; 50 rev.message = "wiki ("..(what or "unknown page").."): "..rev.message;
51 end 51 end
52
53 local name = rev.author;
54 local email = name:match("<([^>]+)>$");
55 if email then
56 name = name:gsub("%s*<[^>]+>$", "");
57 end
52 58
53 local ok, err = pubsub_service:publish(node, true, project, 59 local ok, err = pubsub_service:publish(node, true, project,
54 st.stanza("item", { xmlns = "http://jabber.org/protocol/pubsub", id = project }) 60 st.stanza("item", { xmlns = "http://jabber.org/protocol/pubsub", id = project })
55 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" }) 61 :tag("entry", { xmlns = "http://www.w3.org/2005/Atom" })
56 :tag("id"):text(tostring(rev.revision)):up() 62 :tag("id"):text(tostring(rev.revision)):up()
57 :tag("title"):text(rev.message):up() 63 :tag("title"):text(rev.message):up()
58 :tag("link", { rel = "alternate", href = rev.url }):up() 64 :tag("link", { rel = "alternate", href = rev.url }):up()
59 :tag("published"):text(datetime(rev.timestamp)):up() 65 :tag("published"):text(datetime(rev.timestamp)):up()
60 :tag("author") 66 :tag("author")
61 :tag("name"):text(rev.author):up() 67 :tag("name"):text(name):up()
68 :tag("email"):text(email):up()
62 :up() 69 :up()
63 ); 70 );
64 end 71 end
65 module:log("debug", "Handled POST: \n%s\n", tostring(body)); 72 module:log("debug", "Handled POST: \n%s\n", tostring(body));
66 return "Thank you Google!"; 73 return "Thank you Google!";