mirror of https://github.com/kiwix/libkiwix.git
Enabled frontend-side translation of 500 error page
This commit is contained in:
parent
bb1a730253
commit
13a6863183
|
@ -431,7 +431,9 @@ HTTP500Response::HTTP500Response(const RequestContext& request)
|
||||||
: HTTPErrorResponse(request,
|
: HTTPErrorResponse(request,
|
||||||
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"500-page-title",
|
"500-page-title",
|
||||||
"500-page-heading")
|
"500-page-heading",
|
||||||
|
std::string(),
|
||||||
|
/*includeKiwixResponseData=*/true)
|
||||||
{
|
{
|
||||||
*this += nonParameterizedMessage("500-page-text");
|
*this += nonParameterizedMessage("500-page-text");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1036,7 +1036,10 @@ TEST_F(ServerTest, 500)
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
|
||||||
<title>Internal Server Error</title>
|
<title>Internal Server Error</title>
|
||||||
|
<script>
|
||||||
|
window.KIWIX_RESPONSE_TEMPLATE = )" + ERROR_HTML_TEMPLATE_JS_STRING + R"(;
|
||||||
|
window.KIWIX_RESPONSE_DATA = { "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "500-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "500-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "500-page-text", "params" : { } } }, { "p" : { "msgid" : "non-translated-text", "params" : { "MSG" : "Entry redirect_loop.html is a redirect entry." } } } ] };
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Internal Server Error</h1>
|
<h1>Internal Server Error</h1>
|
||||||
|
|
|
@ -190,3 +190,5 @@ protected:
|
||||||
zfs1_.reset();
|
zfs1_.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const std::string ERROR_HTML_TEMPLATE_JS_STRING = R"("<!DOCTYPE html>\n<html xmlns="http://www.w3.org/1999/xhtml">\n <head>\n <meta content="text/html;charset=UTF-8" http-equiv="content-type" />\n <title>{{PAGE_TITLE}}</title>\n{{#CSS_URL}}\n <link type="text/css" href="{{{CSS_URL}}}" rel="Stylesheet" />\n{{/CSS_URL}}{{#KIWIX_RESPONSE_DATA}} <script>\n window.KIWIX_RESPONSE_TEMPLATE = "{{KIWIX_RESPONSE_TEMPLATE}}";\n window.KIWIX_RESPONSE_DATA = {{{KIWIX_RESPONSE_DATA}}};\n </script>{{/KIWIX_RESPONSE_DATA}}\n </head>\n <body>\n <h1>{{PAGE_HEADING}}</h1>\n{{#details}}\n <p>\n {{{p}}}\n </p>\n{{/details}}\n </body>\n</html>\n")";
|
||||||
|
|
Loading…
Reference in New Issue