HandlerSearch: Render a form when no q= given

Esse commit está contido em:
Albert S. 2021-10-26 23:05:52 +02:00
commit fdcef18861
2 arquivos alterados com 12 adições e 1 exclusões

Ver arquivo

@ -25,7 +25,10 @@ Response HandlerSearch::handleRequest(const Request &r)
std::string q = r.get("q");
if(q.empty())
{
return errorResponse("Missing search term", "No search term supplied");
TemplatePage searchForm = this->templ->getPage("searchform");
response.setBody(searchForm.render());
response.setStatus(200);
return response;
}
auto pageDao = this->database->createPageDao();

Ver arquivo

@ -0,0 +1,8 @@
{qswiki:include:general_header}
<main id="content">
<h2>Search</h2>
Search content of pages:
<form action="{qswiki:config:wikipath}" method="GET"><input type="hidden" name="action" value="search"/><input type="text" name="q" value="search here" onfocus="this.value=''"></form>
</main>
{qswiki:include:general_footer}