Added KIWIX_RESPONSE_DATA to error response

Now the data used to generate an error response can be made to be
embedded in the response as a JS object KIWIX_RESPONSE_DATA.
This commit is contained in:
Veloman Yunkan
2024-01-09 21:59:53 +04:00
parent 8b8a2eede7
commit b151a2a480
4 changed files with 65 additions and 8 deletions

View File

@ -29,7 +29,8 @@ TEST(HTTPErrorResponse, shouldBeInEnglishByDefault) {
HTTPErrorResponse errResp(req, MHD_HTTP_NOT_FOUND,
"404-page-title",
"404-page-heading",
"/css/error.css");
"/css/error.css",
/*includeKiwixResponseData=*/true);
EXPECT_EQ(getResponseContent(errResp),
R"(<!DOCTYPE html>
@ -38,6 +39,9 @@ R"(<!DOCTYPE html>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>Content not found</title>
<link type="text/css" href="/css/error.css" rel="Stylesheet" />
<script>
const KIWIX_RESPONSE_DATA = { "CSS_URL" : "/css/error.css", "PAGE_HEADING" : { "msgid" : "404-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "404-page-title", "params" : { } }, "details" : [ ] };
</script>
</head>
<body>
<h1>Not Found</h1>
@ -56,7 +60,8 @@ TEST(HTTPErrorResponse, shouldBeTranslatable) {
HTTPErrorResponse errResp(req, MHD_HTTP_NOT_FOUND,
"404-page-title",
"404-page-heading",
"/css/error.css");
"/css/error.css",
/*includeKiwixResponseData=*/true);
EXPECT_EQ(getResponseContent(errResp),
R"(<!DOCTYPE html>
@ -65,6 +70,9 @@ R"(<!DOCTYPE html>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>[I18N TESTING] Not Found - Try Again</title>
<link type="text/css" href="/css/error.css" rel="Stylesheet" />
<script>
const KIWIX_RESPONSE_DATA = { "CSS_URL" : "/css/error.css", "PAGE_HEADING" : { "msgid" : "404-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "404-page-title", "params" : { } }, "details" : [ ] };
</script>
</head>
<body>
<h1>[I18N TESTING] Content not found, but at least the server is alive</h1>