mirror of https://github.com/kiwix/libkiwix.git
Made 404.html error template a little more generic
The fact that an info message was moved into C++ code is temporary since it will be moved to a message resource file soon.
This commit is contained in:
parent
8cfcf2ea86
commit
ae60ba806b
|
@ -86,13 +86,15 @@ std::unique_ptr<Response> Response::build_304(const InternalServer& server, cons
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& server, const std::string& url, const std::string& details)
|
std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& server, const std::string& url, const std::string& details)
|
||||||
{
|
{
|
||||||
MustacheData data;
|
kainjow::mustache::list pList;
|
||||||
if ( !url.empty() ) {
|
if ( !url.empty() ) {
|
||||||
data.set("url", url);
|
kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)");
|
||||||
|
const auto urlNotFoundMsg = msgTmpl.render({"url", url});
|
||||||
|
pList.push_back({"p", urlNotFoundMsg});
|
||||||
}
|
}
|
||||||
data.set("details", details);
|
pList.push_back({"p", details});
|
||||||
|
|
||||||
return build_404(server, data);
|
return build_404(server, {"details", pList});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& server, const kainjow::mustache::data& data)
|
std::unique_ptr<ContentResponse> Response::build_404(const InternalServer& server, const kainjow::mustache::data& data)
|
||||||
|
|
|
@ -6,15 +6,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Not Found</h1>
|
<h1>Not Found</h1>
|
||||||
{{#url}}
|
{{#details}}
|
||||||
<p>
|
<p>
|
||||||
The requested URL "{{url}}" was not found on this server.
|
{{{p}}}
|
||||||
</p>
|
</p>
|
||||||
{{/url}}
|
{{/details}}
|
||||||
{{#details}}
|
|
||||||
<p>
|
|
||||||
{{{details}}}
|
|
||||||
</p>
|
|
||||||
{{/details}}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -530,7 +530,6 @@ TEST_F(ServerTest, 404WithBodyTesting)
|
||||||
{ /* url */ "/ROOT/random?content=non-existent-book",
|
{ /* url */ "/ROOT/random?content=non-existent-book",
|
||||||
expected_body==R"(
|
expected_body==R"(
|
||||||
<h1>Not Found</h1>
|
<h1>Not Found</h1>
|
||||||
//EOLWHITESPACEMARKER
|
|
||||||
<p>
|
<p>
|
||||||
No such book: non-existent-book
|
No such book: non-existent-book
|
||||||
</p>
|
</p>
|
||||||
|
@ -539,7 +538,6 @@ TEST_F(ServerTest, 404WithBodyTesting)
|
||||||
{ /* url */ "/ROOT/suggest?content=no-such-book&term=whatever",
|
{ /* url */ "/ROOT/suggest?content=no-such-book&term=whatever",
|
||||||
expected_body==R"(
|
expected_body==R"(
|
||||||
<h1>Not Found</h1>
|
<h1>Not Found</h1>
|
||||||
//EOLWHITESPACEMARKER
|
|
||||||
<p>
|
<p>
|
||||||
No such book: no-such-book
|
No such book: no-such-book
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue