RSS export: Use chunk of description as title if title is empty.

The first 100 chars of the description will be used as title.
This commit is contained in:
tastytea 2019-09-21 21:44:44 +02:00
parent 28f194c910
commit c9221757e6
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,7 @@
*/
#include <ctime>
#include <cstdint>
#include <Poco/XML/XMLWriter.h>
#include <Poco/SAX/AttributesImpl.h>
#include <Poco/DateTime.h>
@ -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");