From c9221757e6524af9a0ad7f1da8e7a4d3b9435129 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 21 Sep 2019 21:44:44 +0200 Subject: [PATCH 1/3] RSS export: Use chunk of description as title if title is empty. The first 100 chars of the description will be used as title. --- src/lib/export/rss.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/export/rss.cpp b/src/lib/export/rss.cpp index 758b8a5..fc2f382 100644 --- a/src/lib/export/rss.cpp +++ b/src/lib/export/rss.cpp @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -79,7 +80,20 @@ namespace remwharead writer.startElement("", "", "item"); writer.startElement("", "", "title"); - writer.characters(entry.title); + if (!entry.title.empty()) + { + writer.characters(entry.title); + } + else + { + constexpr std::uint8_t maxlen = 100; + string title = entry.description.substr(0, maxlen); + if (entry.description.length() > maxlen) + { + title += " […]"; + } + writer.characters(title); + } writer.endElement("", "", "title"); writer.startElement("", "", "link"); From 2f8dffff90be6dab152924ec084d64d75c1ca742 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 21 Sep 2019 21:46:30 +0200 Subject: [PATCH 2/3] RSS export: Make description more readable. Add HTML tags to make it look neat. --- src/lib/export/rss.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/export/rss.cpp b/src/lib/export/rss.cpp index fc2f382..ac82bd8 100644 --- a/src/lib/export/rss.cpp +++ b/src/lib/export/rss.cpp @@ -58,7 +58,6 @@ namespace remwharead writer.endElement("", "", "title"); writer.startElement("", "", "link"); - // FIXME: There has to be an URL here. writer.endElement("", "", "link"); writer.startElement("", "", "description"); @@ -115,11 +114,11 @@ namespace remwharead string description = entry.description; if (!description.empty()) { - description += "\n\n"; + description = "

" + description + "

"; } if (!entry.tags.empty()) { - description += "Tags: "; + description += "

Tags: "; for (const string &tag : entry.tags) { description += tag; @@ -128,10 +127,13 @@ namespace remwharead description += ", "; } } + description += "

"; } if (!entry.archive_uri.empty()) { - description += "\n\nArchived version: " + entry.archive_uri; + description += "

Archived version: " + "" + + entry.archive_uri + ""; } writer.startElement("", "", "description"); writer.characters(description); From 98553a5315530d6bc086425a4e78dd08895e8a09 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 21 Sep 2019 21:51:36 +0200 Subject: [PATCH 3/3] Add RSS example to manpage. --- man/remwharead.1.adoc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/man/remwharead.1.adoc b/man/remwharead.1.adoc index 1de1ca1..71cfd32 100644 --- a/man/remwharead.1.adoc +++ b/man/remwharead.1.adoc @@ -2,7 +2,7 @@ :doctype: manpage :Author: tastytea :Email: tastytea@tastytea.de -:Date: 2019-09-20 +:Date: 2019-09-21 :Revision: 0.0.0 :man source: remwharead :man manual: General Commands Manual @@ -92,7 +92,12 @@ Print version, copyright and license. .Output all articles by Jan Müller, consider different spellings. ==== -`remwharead -e simple -S 'Jan\[[:space:]]+M(ü|ue)ller' -r` +`remwharead -e simple -S 'Jan[\s]+M(ü|ue?)ller' -r` +==== + +.Export all things from the last week to an RSS feed. +==== +`remwharead -e rss -T $(date -d "-1 week" -I),$(date -I) | sed 's||https://example.com/|' > /var/www/feed.rss` ==== === Display database