Comparison

mod_pubsub_summary/mod_pubsub_summary.lua @ 4435:a620bf249e63

mod_pubsub_summary: Explain why it picks content or summary in a comment
author Kim Alvefur <zash@zash.se>
date Wed, 10 Feb 2021 16:04:17 +0100
parent 4426:3fe2c264aac4
child 4436:07529dba102d
comparison
equal deleted inserted replaced
4434:f10ab82be166 4435:a620bf249e63
2 -- 2 --
3 -- Compose a textual representation of Atom payloads 3 -- Compose a textual representation of Atom payloads
4 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event) 4 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event)
5 local payload = event.payload; 5 local payload = event.payload;
6 local title = payload:get_child_text("title"); 6 local title = payload:get_child_text("title");
7 -- Note: This prefers content over summary, it was made for a news feed where
8 -- the interesting stuff was in the content and the summary was .. meh.
7 local content_tag = payload:get_child("content") or payload:get_child("summary"); 9 local content_tag = payload:get_child("content") or payload:get_child("summary");
8 local content = content_tag:get_text(); 10 local content = content_tag:get_text();
9 if content_tag.attr.type == "html" then 11 if content_tag.attr.type == "html" then
10 content = content:gsub("\n*<p[^>]*>\n*(.-)\n*</p>\n*", "%1\n\n"); 12 content = content:gsub("\n*<p[^>]*>\n*(.-)\n*</p>\n*", "%1\n\n");
11 content = content:gsub("<li>(.-)</li>\n", "* %1\n"); 13 content = content:gsub("<li>(.-)</li>\n", "* %1\n");