Handlers: set page title
This commit is contained in:
förälder
9bb1fa5a33
incheckning
c7a8b733ed
@ -36,6 +36,7 @@ void Handler::setGeneralVars(TemplatePage &page)
|
||||
Response Handler::errorResponse(std::string errortitle, std::string errormessage, int status)
|
||||
{
|
||||
TemplatePage &error = this->templ->getPage("error");
|
||||
error.setVar("title", createPageTitle(errortitle));
|
||||
error.setVar("errortitle", errortitle);
|
||||
error.setVar("errormessage", errormessage);
|
||||
//TODO: log?
|
||||
@ -43,6 +44,11 @@ Response Handler::errorResponse(std::string errortitle, std::string errormessage
|
||||
return { status, error.render()};
|
||||
}
|
||||
|
||||
std::string Handler::createPageTitle(std::string append)
|
||||
{
|
||||
return this->handlersConfig->wikiname + " - " + append; //TODO: we might wanna make the format configurable
|
||||
}
|
||||
|
||||
QueryOption Handler::queryOption(const Request &r) const
|
||||
{
|
||||
QueryOption result;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void setGeneralVars(TemplatePage &page);
|
||||
virtual ~Handler() { }
|
||||
Response errorResponse(std::string errortitle, std::string errormessage, int status = 200);
|
||||
std::string createPageTitle(std::string append);
|
||||
};
|
||||
|
||||
#endif // HANDLER_H
|
||||
|
@ -35,6 +35,7 @@ Response HandlerAllCategories::handleRequest(const Request &r)
|
||||
return this->urlProvider->category(str);
|
||||
});
|
||||
searchPage.setVar("categorylist", body);
|
||||
searchPage.setVar("title", createPageTitle("All categories"));
|
||||
setGeneralVars(searchPage);
|
||||
|
||||
Response response;
|
||||
|
@ -35,6 +35,7 @@ Response HandlerAllPages::handleRequest(const Request &r)
|
||||
TemplatePage &searchPage = this->templ->getPage("allpages");
|
||||
std::string body = this->templ->renderSearch(resultList);
|
||||
searchPage.setVar("pagelist", body);
|
||||
searchPage.setVar("title", createPageTitle("All pages"));
|
||||
setGeneralVars(searchPage);
|
||||
response.setBody(searchPage.render());
|
||||
response.setStatus(200);
|
||||
|
@ -39,6 +39,7 @@ Response HandlerCategory::handleRequest(const Request &r)
|
||||
searchPage.setVar("pagelist", body);
|
||||
searchPage.setVar("categoryname", categoryname);
|
||||
setGeneralVars(searchPage);
|
||||
searchPage.setVar("title", createPageTitle("Category: " + categoryname));
|
||||
response.setBody(searchPage.render());
|
||||
response.setStatus(200);
|
||||
return response;
|
||||
|
@ -27,13 +27,14 @@ Response HandlerHistory::handleRequest(const Request &r)
|
||||
{
|
||||
QueryOption qo = queryOption(r);
|
||||
std::string page = r.get("page");
|
||||
|
||||
std::string title;
|
||||
if(page.empty())
|
||||
{
|
||||
if(!this->userSession->user.permissions.canSeeGlobalHistory())
|
||||
{
|
||||
return errorResponse("Permission denied", "You can't see the changes history on this wiki", 403);
|
||||
}
|
||||
title = "History";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -42,6 +43,7 @@ Response HandlerHistory::handleRequest(const Request &r)
|
||||
{
|
||||
return errorResponse("Permission denied", "You cannot see the changes history of this page", 403);
|
||||
}
|
||||
title = "History: " + page;
|
||||
}
|
||||
|
||||
|
||||
@ -116,6 +118,7 @@ Response HandlerHistory::handleRequest(const Request &r)
|
||||
unsigned int neworder = ( qo.order == DESCENDING ) ? ASCENDING : DESCENDING ;
|
||||
historyPage.setVar("linkrecentsort", makeSortedLink(qo.limit, qo.offset, neworder));
|
||||
historyPage.setVar("revisionlist", this->templ->renderRevisionList(resultList, page.empty()));
|
||||
historyPage.setVar("title", createPageTitle(title));
|
||||
Response response;
|
||||
response.setBody(historyPage.render());
|
||||
response.setStatus(200);
|
||||
|
@ -124,6 +124,7 @@ Response HandlerLogin::handleRequest(const Request &r)
|
||||
TemplatePage &loginTemplatePage = this->templ->getPage("login");
|
||||
setGeneralVars(loginTemplatePage);
|
||||
loginTemplatePage.setVar("loginurl", urlProvider->login(page));
|
||||
loginTemplatePage.setVar("title", createPageTitle("Login"));
|
||||
Response result;
|
||||
result.setStatus(200);
|
||||
result.setBody(loginTemplatePage.render());
|
||||
|
@ -87,6 +87,7 @@ void HandlerPage::setPageVars(TemplatePage &page, std::string pagename)
|
||||
|
||||
page.setVar("headerlinks", headerlinks);
|
||||
page.setVar("page", pagename);
|
||||
page.setVar("title", createPageTitle(pagename));
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,7 @@ Response HandlerPageDelete::handleRequest(PageDao &pageDao, std::string pagename
|
||||
TemplatePage delPage = this->templ->getPage("page_deletion");
|
||||
delPage.setVar("deletionurl", this->urlProvider->pageDelete(pagename));
|
||||
setPageVars(delPage, pagename);
|
||||
delPage.setVar("title", createPageTitle("Delete:" + pagename));
|
||||
Response r;
|
||||
r.setBody(delPage.render());
|
||||
return r;
|
||||
|
@ -117,6 +117,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
|
||||
templatePage.setVar("preview_content", parser.parse(pageDao, *this->urlProvider, newContent) );
|
||||
templatePage.setVar("content", newContent);
|
||||
setPageVars(templatePage, pagename);
|
||||
templatePage.setVar("title", createPageTitle("Preview: "+ pagename));
|
||||
|
||||
Response response;
|
||||
response.setBody(templatePage.render());
|
||||
@ -129,6 +130,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
|
||||
templatePage.setVar("actionurl", urlProvider->editPage(pagename));
|
||||
templatePage.setVar("content", body);
|
||||
setPageVars(templatePage, pagename);
|
||||
templatePage.setVar("title", createPageTitle("Edit: "+ pagename));
|
||||
Response response;
|
||||
response.setBody(templatePage.render());
|
||||
return response;
|
||||
|
@ -49,6 +49,7 @@ Response HandlerSearch::handleRequest(const Request &r)
|
||||
searchPage.setVar("pagelist", body);
|
||||
searchPage.setVar("searchterm", q);
|
||||
setGeneralVars(searchPage);
|
||||
searchPage.setVar("title", createPageTitle("Search"));
|
||||
response.setBody(searchPage.render());
|
||||
response.setStatus(200);
|
||||
return response;
|
||||
|
Laddar…
Referens i nytt ärende
Block a user