plugins/mod_pubsub/mod_pubsub.lua
changeset 13343 c94989c557cd
parent 13217 50324f66ca2a
child 13460 e9ab660b9c5f
equal deleted inserted replaced
13342:470ab6b55e93 13343:c94989c557cd
   137 	return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item" and #item.tags == 1;
   137 	return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item" and #item.tags == 1;
   138 end
   138 end
   139 
   139 
   140 -- Compose a textual representation of Atom payloads
   140 -- Compose a textual representation of Atom payloads
   141 local summary_templates = module:get_option("pubsub_summary_templates", {
   141 local summary_templates = module:get_option("pubsub_summary_templates", {
   142 	["http://www.w3.org/2005/Atom"] = "{summary|or{{author/name|and{{author/name} posted }}{title}}}";
   142 	["http://www.w3.org/2005/Atom"] = "{@pubsub:title|and{*{@pubsub:title}*\n\n}}{summary|or{{author/name|and{{author/name} posted }}{title}}}";
   143 })
   143 })
   144 
   144 
   145 for pubsub_type, template in pairs(summary_templates) do
   145 for pubsub_type, template in pairs(summary_templates) do
   146 	module:hook("pubsub-summary/"..pubsub_type, function (event)
   146 	module:hook("pubsub-summary/"..pubsub_type, function (event)
   147 		local payload = event.payload;
   147 		local payload = event.payload;
       
   148 
       
   149 		local got_config, node_config = service:get_node_config(event.node, true);
       
   150 		if got_config then
       
   151 			payload = st.clone(payload);
       
   152 			payload.attr["xmlns:pubsub"] = xmlns_pubsub;
       
   153 			payload.attr["pubsub:node"] = event.node;
       
   154 			payload.attr["pubsub:title"] = node_config.title;
       
   155 			payload.attr["pubsub:description"] = node_config.description;
       
   156 		end
       
   157 
   148 		return xtemplate.render(template, payload, tostring);
   158 		return xtemplate.render(template, payload, tostring);
   149 	end, -1);
   159 	end, -1);
   150 end
   160 end
   151 
   161 
   152 
   162