Handlers: set page title
This commit is contained in:
والد
9bb1fa5a33
کامیت
c7a8b733ed
@ -36,6 +36,7 @@ void Handler::setGeneralVars(TemplatePage &page)
|
|||||||
Response Handler::errorResponse(std::string errortitle, std::string errormessage, int status)
|
Response Handler::errorResponse(std::string errortitle, std::string errormessage, int status)
|
||||||
{
|
{
|
||||||
TemplatePage &error = this->templ->getPage("error");
|
TemplatePage &error = this->templ->getPage("error");
|
||||||
|
error.setVar("title", createPageTitle(errortitle));
|
||||||
error.setVar("errortitle", errortitle);
|
error.setVar("errortitle", errortitle);
|
||||||
error.setVar("errormessage", errormessage);
|
error.setVar("errormessage", errormessage);
|
||||||
//TODO: log?
|
//TODO: log?
|
||||||
@ -43,6 +44,11 @@ Response Handler::errorResponse(std::string errortitle, std::string errormessage
|
|||||||
return { status, error.render()};
|
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 Handler::queryOption(const Request &r) const
|
||||||
{
|
{
|
||||||
QueryOption result;
|
QueryOption result;
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
void setGeneralVars(TemplatePage &page);
|
void setGeneralVars(TemplatePage &page);
|
||||||
virtual ~Handler() { }
|
virtual ~Handler() { }
|
||||||
Response errorResponse(std::string errortitle, std::string errormessage, int status = 200);
|
Response errorResponse(std::string errortitle, std::string errormessage, int status = 200);
|
||||||
|
std::string createPageTitle(std::string append);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HANDLER_H
|
#endif // HANDLER_H
|
||||||
|
@ -35,6 +35,7 @@ Response HandlerAllCategories::handleRequest(const Request &r)
|
|||||||
return this->urlProvider->category(str);
|
return this->urlProvider->category(str);
|
||||||
});
|
});
|
||||||
searchPage.setVar("categorylist", body);
|
searchPage.setVar("categorylist", body);
|
||||||
|
searchPage.setVar("title", createPageTitle("All categories"));
|
||||||
setGeneralVars(searchPage);
|
setGeneralVars(searchPage);
|
||||||
|
|
||||||
Response response;
|
Response response;
|
||||||
|
@ -35,6 +35,7 @@ Response HandlerAllPages::handleRequest(const Request &r)
|
|||||||
TemplatePage &searchPage = this->templ->getPage("allpages");
|
TemplatePage &searchPage = this->templ->getPage("allpages");
|
||||||
std::string body = this->templ->renderSearch(resultList);
|
std::string body = this->templ->renderSearch(resultList);
|
||||||
searchPage.setVar("pagelist", body);
|
searchPage.setVar("pagelist", body);
|
||||||
|
searchPage.setVar("title", createPageTitle("All pages"));
|
||||||
setGeneralVars(searchPage);
|
setGeneralVars(searchPage);
|
||||||
response.setBody(searchPage.render());
|
response.setBody(searchPage.render());
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
@ -39,6 +39,7 @@ Response HandlerCategory::handleRequest(const Request &r)
|
|||||||
searchPage.setVar("pagelist", body);
|
searchPage.setVar("pagelist", body);
|
||||||
searchPage.setVar("categoryname", categoryname);
|
searchPage.setVar("categoryname", categoryname);
|
||||||
setGeneralVars(searchPage);
|
setGeneralVars(searchPage);
|
||||||
|
searchPage.setVar("title", createPageTitle("Category: " + categoryname));
|
||||||
response.setBody(searchPage.render());
|
response.setBody(searchPage.render());
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
return response;
|
return response;
|
||||||
|
@ -27,13 +27,14 @@ Response HandlerHistory::handleRequest(const Request &r)
|
|||||||
{
|
{
|
||||||
QueryOption qo = queryOption(r);
|
QueryOption qo = queryOption(r);
|
||||||
std::string page = r.get("page");
|
std::string page = r.get("page");
|
||||||
|
std::string title;
|
||||||
if(page.empty())
|
if(page.empty())
|
||||||
{
|
{
|
||||||
if(!this->userSession->user.permissions.canSeeGlobalHistory())
|
if(!this->userSession->user.permissions.canSeeGlobalHistory())
|
||||||
{
|
{
|
||||||
return errorResponse("Permission denied", "You can't see the changes history on this wiki", 403);
|
return errorResponse("Permission denied", "You can't see the changes history on this wiki", 403);
|
||||||
}
|
}
|
||||||
|
title = "History";
|
||||||
}
|
}
|
||||||
else
|
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);
|
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 ;
|
unsigned int neworder = ( qo.order == DESCENDING ) ? ASCENDING : DESCENDING ;
|
||||||
historyPage.setVar("linkrecentsort", makeSortedLink(qo.limit, qo.offset, neworder));
|
historyPage.setVar("linkrecentsort", makeSortedLink(qo.limit, qo.offset, neworder));
|
||||||
historyPage.setVar("revisionlist", this->templ->renderRevisionList(resultList, page.empty()));
|
historyPage.setVar("revisionlist", this->templ->renderRevisionList(resultList, page.empty()));
|
||||||
|
historyPage.setVar("title", createPageTitle(title));
|
||||||
Response response;
|
Response response;
|
||||||
response.setBody(historyPage.render());
|
response.setBody(historyPage.render());
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
@ -124,6 +124,7 @@ Response HandlerLogin::handleRequest(const Request &r)
|
|||||||
TemplatePage &loginTemplatePage = this->templ->getPage("login");
|
TemplatePage &loginTemplatePage = this->templ->getPage("login");
|
||||||
setGeneralVars(loginTemplatePage);
|
setGeneralVars(loginTemplatePage);
|
||||||
loginTemplatePage.setVar("loginurl", urlProvider->login(page));
|
loginTemplatePage.setVar("loginurl", urlProvider->login(page));
|
||||||
|
loginTemplatePage.setVar("title", createPageTitle("Login"));
|
||||||
Response result;
|
Response result;
|
||||||
result.setStatus(200);
|
result.setStatus(200);
|
||||||
result.setBody(loginTemplatePage.render());
|
result.setBody(loginTemplatePage.render());
|
||||||
|
@ -87,6 +87,7 @@ void HandlerPage::setPageVars(TemplatePage &page, std::string pagename)
|
|||||||
|
|
||||||
page.setVar("headerlinks", headerlinks);
|
page.setVar("headerlinks", headerlinks);
|
||||||
page.setVar("page", pagename);
|
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");
|
TemplatePage delPage = this->templ->getPage("page_deletion");
|
||||||
delPage.setVar("deletionurl", this->urlProvider->pageDelete(pagename));
|
delPage.setVar("deletionurl", this->urlProvider->pageDelete(pagename));
|
||||||
setPageVars(delPage, pagename);
|
setPageVars(delPage, pagename);
|
||||||
|
delPage.setVar("title", createPageTitle("Delete:" + pagename));
|
||||||
Response r;
|
Response r;
|
||||||
r.setBody(delPage.render());
|
r.setBody(delPage.render());
|
||||||
return r;
|
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("preview_content", parser.parse(pageDao, *this->urlProvider, newContent) );
|
||||||
templatePage.setVar("content", newContent);
|
templatePage.setVar("content", newContent);
|
||||||
setPageVars(templatePage, pagename);
|
setPageVars(templatePage, pagename);
|
||||||
|
templatePage.setVar("title", createPageTitle("Preview: "+ pagename));
|
||||||
|
|
||||||
Response response;
|
Response response;
|
||||||
response.setBody(templatePage.render());
|
response.setBody(templatePage.render());
|
||||||
@ -129,6 +130,7 @@ Response HandlerPageEdit::handleRequest(PageDao &pageDao, std::string pagename,
|
|||||||
templatePage.setVar("actionurl", urlProvider->editPage(pagename));
|
templatePage.setVar("actionurl", urlProvider->editPage(pagename));
|
||||||
templatePage.setVar("content", body);
|
templatePage.setVar("content", body);
|
||||||
setPageVars(templatePage, pagename);
|
setPageVars(templatePage, pagename);
|
||||||
|
templatePage.setVar("title", createPageTitle("Edit: "+ pagename));
|
||||||
Response response;
|
Response response;
|
||||||
response.setBody(templatePage.render());
|
response.setBody(templatePage.render());
|
||||||
return response;
|
return response;
|
||||||
|
@ -49,6 +49,7 @@ Response HandlerSearch::handleRequest(const Request &r)
|
|||||||
searchPage.setVar("pagelist", body);
|
searchPage.setVar("pagelist", body);
|
||||||
searchPage.setVar("searchterm", q);
|
searchPage.setVar("searchterm", q);
|
||||||
setGeneralVars(searchPage);
|
setGeneralVars(searchPage);
|
||||||
|
searchPage.setVar("title", createPageTitle("Search"));
|
||||||
response.setBody(searchPage.render());
|
response.setBody(searchPage.render());
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
return response;
|
return response;
|
||||||
|
بارگذاری…
مرجع در شماره جدید
Block a user