HandlerFeedGenerator: Improvements to make feed vlaid

Этот коммит содержится в:
Albert S. 2022-03-28 20:06:42 +02:00
родитель 1ae5495e61
Коммит 5bb3f55945
3 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -56,9 +56,10 @@ std::string HandlerFeedGenerator::generateAtom(const std::vector<HandlerFeedGene
auto revisionDao = this->database->createRevisionDao(); auto revisionDao = this->database->createRevisionDao();
auto pageDao = this->database->createPageDao(); auto pageDao = this->database->createPageDao();
std::string subtitle = filter;
if(utils::trim(filter).empty()) if(utils::trim(filter).empty())
{ {
filter = "All pages"; subtitle = "All pages";
} }
for(const EntryRevisionPair &entry : entries) for(const EntryRevisionPair &entry : entries)
@ -72,6 +73,7 @@ std::string HandlerFeedGenerator::generateAtom(const std::vector<HandlerFeedGene
newestPublished = initialRevision.timestamp; newestPublished = initialRevision.timestamp;
} }
std::string entryPublished = utils::formatLocalDate(initialRevision.timestamp, dateformat) + "Z"; std::string entryPublished = utils::formatLocalDate(initialRevision.timestamp, dateformat) + "Z";
std::string entryUpdated = utils::formatLocalDate(current.timestamp, dateformat) + "Z";
std::string entryurl = std::string entryurl =
this->urlProvider->combine({this->urlProvider->rootUrl(), this->urlProvider->page(page.name)}); this->urlProvider->combine({this->urlProvider->rootUrl(), this->urlProvider->page(page.name)});
TemplatePage atomentry = this->templ->getPage("feeds/atomentry"); TemplatePage atomentry = this->templ->getPage("feeds/atomentry");
@ -79,16 +81,18 @@ std::string HandlerFeedGenerator::generateAtom(const std::vector<HandlerFeedGene
atomentry.setVar("entryurl", utils::html_xss(entryurl)); atomentry.setVar("entryurl", utils::html_xss(entryurl));
atomentry.setVar("entryid", utils::html_xss(entryurl)); atomentry.setVar("entryid", utils::html_xss(entryurl));
atomentry.setVar("entrypublished", entryPublished); atomentry.setVar("entrypublished", entryPublished);
atomentry.setVar("entryupdated", entryUpdated);
Parser parser; Parser parser;
atomentry.setVar("entrycontent", utils::html_xss(parser.parse(*pageDao, *this->urlProvider, current.content))); atomentry.setVar("entrycontent", utils::html_xss(parser.parse(*pageDao, *this->urlProvider, current.content)));
stream << atomentry.render(); stream << atomentry.render();
} }
stream << atomfooter; stream << atomfooter;
TemplatePage atomheader = this->templ->getPage("feeds/atomheader"); TemplatePage atomheader = this->templ->getPage("feeds/atomheader");
atomheader.setVar("subtitle", filter); atomheader.setVar("subtitle", subtitle);
atomheader.setVar("atomfeeduniqueid", utils::html_xss(this->urlProvider->atomFeed(filter))); std::string selflink = utils::html_xss(this->urlProvider->atomFeed(filter));
atomheader.setVar("atomfeeduniqueid", selflink);
atomheader.setVar("atomselflink", selflink);
atomheader.setVar("atomfeedupdate", utils::formatLocalDate(newestPublished, dateformat) + "Z"); atomheader.setVar("atomfeedupdate", utils::formatLocalDate(newestPublished, dateformat) + "Z");
return atomheader.render() + stream.str(); return atomheader.render() + stream.str();
} }

Просмотреть файл

@ -3,5 +3,6 @@
<link href="{qswiki:var:entryurl}"/> <link href="{qswiki:var:entryurl}"/>
<id>{qswiki:var:entryid}</id> <id>{qswiki:var:entryid}</id>
<published>{qswiki:var:entrypublished}</published> <published>{qswiki:var:entrypublished}</published>
<updated>{qswiki:var:entryupdated}</updated>
<content type="html">{qswiki:var:entrycontent}</content> <content type="html">{qswiki:var:entrycontent}</content>
</entry> </entry>

Просмотреть файл

@ -5,4 +5,5 @@
</author> </author>
<title>{qswiki:config:wikiname} - {qswiki:var:subtitle}</title> <title>{qswiki:config:wikiname} - {qswiki:var:subtitle}</title>
<id>{qswiki:var:atomfeeduniqueid}</id> <id>{qswiki:var:atomfeeduniqueid}</id>
<link rel="self" href="{qswiki:var:atomselflink}"/>
<updated>{qswiki:var:atomfeedupdate}</updated> <updated>{qswiki:var:atomfeedupdate}</updated>