RevisionRenderer: Add 'dynamicpostrenderer'
Αυτή η υποβολή περιλαμβάνεται σε:
γονέας
6a12070d0d
υποβολή
61f289625c
@ -1,9 +1,10 @@
|
||||
#include "revisionrenderer.h"
|
||||
#include "revisionrenderer.h"
|
||||
#include "templatepage.h"
|
||||
#include "dynamic/dynamiccontentpostlist.h"
|
||||
#include "dynamic/dynamiccontentincludepage.h"
|
||||
#include "dynamic/dynamiccontentgetvar.h"
|
||||
#include "dynamic/dynamiccontentsetvar.h"
|
||||
#include "dynamic/dynamicpostrenderer.h"
|
||||
#include "parser.h"
|
||||
#include "htmllink.h"
|
||||
|
||||
@ -17,9 +18,10 @@ std::string RevisionRenderer::dynamicCallback(std::string_view key, std::string_
|
||||
}
|
||||
if(key == "dynamic:includepage")
|
||||
{
|
||||
auto includePage = this->dynamicContentFactory.createDynamicContent<DynamicContentIncludePage>();
|
||||
auto includePage = this->dynamicContentFactory.createDynamicContent<DynamicContentIncludePage>();
|
||||
includePage->setArgument(std::string(value));
|
||||
return parser.parseDynamics(includePage->render(), std::bind(&RevisionRenderer::dynamicCallback, this, std::placeholders::_1, std::placeholders::_2));
|
||||
return parser.parseDynamics(includePage->render(), std::bind(&RevisionRenderer::dynamicCallback, this,
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
if(key == "dynamic:setvar")
|
||||
{
|
||||
@ -35,6 +37,12 @@ std::string RevisionRenderer::dynamicCallback(std::string_view key, std::string_
|
||||
getVar->setArgument(std::string(value));
|
||||
return getVar->render();
|
||||
}
|
||||
if(key == "dynamic:postrenderer")
|
||||
{
|
||||
auto renderer = this->dynamicContentFactory.createDynamicContent<DynamicPostRenderer>();
|
||||
renderer->setArgument(std::string(value));
|
||||
return renderer->render();
|
||||
}
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
@ -44,7 +52,8 @@ std::string RevisionRenderer::renderContent(std::string content)
|
||||
dynamicVarsMap["createdon"] = utils::toISODate(time(NULL));
|
||||
dynamicVarsMap["modifydatetime"] = utils::toISODateTime(time(NULL));
|
||||
|
||||
std::string resolvedContent = parser.parseDynamics(content, std::bind(&RevisionRenderer::dynamicCallback, this, std::placeholders::_1, std::placeholders::_2));
|
||||
std::string resolvedContent = parser.parseDynamics(
|
||||
content, std::bind(&RevisionRenderer::dynamicCallback, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
return parser.parse(*this->db->createPageDao(), *this->urlProvider, resolvedContent);
|
||||
}
|
||||
@ -55,15 +64,15 @@ std::string RevisionRenderer::renderContent(const Revision &r, std::string_view
|
||||
auto firstRevision = revisionDao->getRevisionForPage(r.page, 1);
|
||||
if(!firstRevision)
|
||||
{
|
||||
throw std::runtime_error("Could not get first revision for page, which is odd. Solar flares?");
|
||||
throw std::runtime_error("Could not get first revision for page, which is odd. Solar flares?");
|
||||
}
|
||||
|
||||
|
||||
dynamicVarsMap["createdon"] = utils::toISODate(firstRevision.value().timestamp);
|
||||
dynamicVarsMap["pagetitle"] = customTitle;
|
||||
dynamicVarsMap["modifydatetime"] = utils::toISODateTime(r.timestamp);
|
||||
|
||||
std::string resolvedContent = parser.parseDynamics(r.content, std::bind(&RevisionRenderer::dynamicCallback, this, std::placeholders::_1, std::placeholders::_2));
|
||||
std::string resolvedContent = parser.parseDynamics(
|
||||
r.content, std::bind(&RevisionRenderer::dynamicCallback, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
return parser.parse(*this->db->createPageDao(), *this->urlProvider, resolvedContent);
|
||||
}
|
||||
|
Φόρτωση…
Αναφορά σε νέο ζήτημα
Block a user