HandlerSearch: Render a form when no q= given

This commit is contained in:
Albert S. 2021-10-26 23:05:52 +02:00
parent 75268e0073
commit fdcef18861
2 changed files with 12 additions and 1 deletions

View File

@ -25,7 +25,10 @@ Response HandlerSearch::handleRequest(const Request &r)
std::string q = r.get("q"); std::string q = r.get("q");
if(q.empty()) 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(); auto pageDao = this->database->createPageDao();

View File

@ -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}