HandlerPage: Support lookup by title
This commit is contained in:
parent
e876b15c5d
commit
15e4f081cc
@ -27,7 +27,18 @@ Response HandlerPage::handle(const Request &r)
|
|||||||
auto pageDao = this->database->createPageDao();
|
auto pageDao = this->database->createPageDao();
|
||||||
if(pagename.empty())
|
if(pagename.empty())
|
||||||
{
|
{
|
||||||
return errorResponse("No page given", "No page given to request");
|
std::string title = r.get("title");
|
||||||
|
if(title.empty())
|
||||||
|
{
|
||||||
|
return errorResponse("No page given", "No page given to request");
|
||||||
|
}
|
||||||
|
title = utils::strreplace(title, "-", " ");
|
||||||
|
auto page = pageDao->findByTitle(title);
|
||||||
|
if(!page)
|
||||||
|
{
|
||||||
|
return errorResponse("No page by such title", "No page with such title exists");
|
||||||
|
}
|
||||||
|
pagename = page->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pageMustExist() && !pageDao->exists(pagename))
|
if(pageMustExist() && !pageDao->exists(pagename))
|
||||||
|
Loading…
Reference in New Issue
Block a user