From 13a6863183b4f798cc9cefd8a573fcab772b6bdb Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 17 Jan 2024 16:49:02 +0400 Subject: [PATCH] Enabled frontend-side translation of 500 error page --- src/server/response.cpp | 4 +++- test/server.cpp | 5 ++++- test/server_testing_tools.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server/response.cpp b/src/server/response.cpp index b8605b681..8e4d9c71d 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -431,7 +431,9 @@ HTTP500Response::HTTP500Response(const RequestContext& request) : HTTPErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, "500-page-title", - "500-page-heading") + "500-page-heading", + std::string(), + /*includeKiwixResponseData=*/true) { *this += nonParameterizedMessage("500-page-text"); } diff --git a/test/server.cpp b/test/server.cpp index 5e7f11b65..fa57aee4e 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -1036,7 +1036,10 @@ TEST_F(ServerTest, 500) Internal Server Error - +

Internal Server Error

diff --git a/test/server_testing_tools.h b/test/server_testing_tools.h index 3ea10ab57..c7adbc565 100644 --- a/test/server_testing_tools.h +++ b/test/server_testing_tools.h @@ -190,3 +190,5 @@ protected: 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")";