handlers: HandlerPageEdit: Use RevisionRenderer

This commit is contained in:
Albert S. 2022-08-20 12:30:28 +02:00
rodzic ecd45a61c8
commit d18c0669ce

Wyświetl plik

@ -23,6 +23,7 @@ SOFTWARE.
#include "../request.h"
#include "../parser.h"
#include "../revisionrenderer.h"
bool HandlerPageEdit::canAccess([[maybe_unused]] std::string page)
{
return effectivePermissions(page).canEdit();
@ -115,12 +116,16 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
{
std::string newContent = r.post("content");
Parser parser;
std::string title = parser.extractCommand("pagetitle", newContent);
TemplatePage templatePage = this->templ->getPage("page_creation_preview");
templatePage.setVar("actionurl", urlProvider->editPage(pagename));
templatePage.setVar("preview_content", parser.parse(pageDao, *this->urlProvider, newContent));
RevisionRenderer revisionRenderer { *this->templ, *this->database, *this->urlProvider };
templatePage.setVar("preview_content", revisionRenderer.renderContent(newContent));
templatePage.setVar("content", newContent);
setPageVars(templatePage, pagename);
templatePage.setVar("title", createPageTitle("Preview: " + pagename));
templatePage.setVar("title", createPageTitle("Preview: " + title));
templatePage.setVar("comment", r.post("comment"));
Response response;
response.setBody(templatePage.render());