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:
parent
28f194c910
commit
c9221757e6
|
@ -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");
|
||||
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");
|
||||
|
|
Loading…
Reference in New Issue