handlers: HandlerPageView: Add '[dynamic:postlist]' tag by callback
This commit is contained in:
parent
a524674149
commit
ac793c6d39
@ -23,7 +23,7 @@ SOFTWARE.
|
|||||||
#include "../logger.h"
|
#include "../logger.h"
|
||||||
#include "../parser.h"
|
#include "../parser.h"
|
||||||
#include "../htmllink.h"
|
#include "../htmllink.h"
|
||||||
|
#include "../dynamic/dynamiccontentpostlist.h"
|
||||||
bool HandlerPageView::canAccess(std::string page)
|
bool HandlerPageView::canAccess(std::string page)
|
||||||
{
|
{
|
||||||
return effectivePermissions(page).canRead();
|
return effectivePermissions(page).canRead();
|
||||||
@ -136,10 +136,21 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
std::string indexcontent;
|
std::string indexcontent;
|
||||||
std::string parsedcontent;
|
std::string parsedcontent;
|
||||||
|
|
||||||
|
std::function<std::string(std::string_view, std::string_view)> dynamicParseCallback =
|
||||||
|
[&](std::string_view key, std::string_view value) -> std::string
|
||||||
|
{
|
||||||
|
if(key == "dynamic:postlist")
|
||||||
|
{
|
||||||
|
std::shared_ptr<DynamicContentPostList> postlist = createDynamic<DynamicContentPostList>();
|
||||||
|
postlist->setCategory(std::string(value));
|
||||||
|
return postlist->render();
|
||||||
|
}
|
||||||
|
return std::string{};
|
||||||
|
};
|
||||||
if(revisionid > 0)
|
if(revisionid > 0)
|
||||||
{
|
{
|
||||||
indexcontent = createIndexContent(parser, revision->content);
|
indexcontent = createIndexContent(parser, revision->content);
|
||||||
parsedcontent = parser.parse(pageDao, *this->urlProvider, revision->content);
|
parsedcontent = parser.parse(pageDao, *this->urlProvider, revision->content, dynamicParseCallback);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -162,7 +173,7 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parsedcontent = parser.parse(pageDao, *this->urlProvider, revision->content);
|
parsedcontent = parser.parse(pageDao, *this->urlProvider, revision->content, dynamicParseCallback);
|
||||||
this->cache->put(cachekeyparsedcontent, parsedcontent);
|
this->cache->put(cachekeyparsedcontent, parsedcontent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +182,7 @@ Response HandlerPageView::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
page.setVar("content", parsedcontent);
|
page.setVar("content", parsedcontent);
|
||||||
page.setVar("index", indexcontent);
|
page.setVar("index", indexcontent);
|
||||||
page.setVar("editedby", revision->author);
|
page.setVar("editedby", revision->author);
|
||||||
page.setVar("editedon", utils::toISODate(revision->timestamp));
|
page.setVar("editedon", utils::toISODateTime(revision->timestamp));
|
||||||
page.setVar("historyurl", this->urlProvider->pageHistory(pagename));
|
page.setVar("historyurl", this->urlProvider->pageHistory(pagename));
|
||||||
page.setVar("revision", revisionstr);
|
page.setVar("revision", revisionstr);
|
||||||
setPageVars(page, pagename);
|
setPageVars(page, pagename);
|
||||||
|
Loading…
Reference in New Issue
Block a user