Added an optional CSS link to error.html

This commit is contained in:
Veloman Yunkan 2022-01-30 17:09:20 +04:00
parent c1823b8ee4
commit dbcbdff275
4 changed files with 12 additions and 5 deletions

View File

@ -101,7 +101,8 @@ HTTPErrorHtmlResponse::HTTPErrorHtmlResponse(const InternalServer& server,
const RequestContext& request,
int httpStatusCode,
const std::string& pageTitleMsg,
const std::string& headingMsg)
const std::string& headingMsg,
const std::string& cssUrl)
: ContentResponseBlueprint(&server,
&request,
httpStatusCode,
@ -110,6 +111,7 @@ HTTPErrorHtmlResponse::HTTPErrorHtmlResponse(const InternalServer& server,
{
kainjow::mustache::list emptyList;
this->m_data = kainjow::mustache::object{
{"CSS_URL", onlyAsNonEmptyMustacheValue(cssUrl) },
{"PAGE_TITLE", pageTitleMsg},
{"PAGE_HEADING", headingMsg},
{"details", emptyList}

View File

@ -184,7 +184,8 @@ struct HTTPErrorHtmlResponse : ContentResponseBlueprint
const RequestContext& request,
int httpStatusCode,
const std::string& pageTitleMsg,
const std::string& headingMsg);
const std::string& headingMsg,
const std::string& cssUrl = "");
using ContentResponseBlueprint::operator+;
HTTPErrorHtmlResponse& operator+(const std::string& msg);

View File

@ -3,6 +3,9 @@
<head>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>{{PAGE_TITLE}}</title>
{{#CSS_URL}}
<link type="text/css" href="{{{CSS_URL}}}" rel="Stylesheet" />
{{/CSS_URL}}
</head>
<body>
<h1>{{PAGE_HEADING}}</h1>

View File

@ -430,7 +430,8 @@ std::string TestContentIn404HtmlResponse::expectedResponse() const
R"FRAG(</title>
)FRAG",
R"FRAG( <link type="root" href="/ROOT"><link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
R"FRAG(
<link type="root" href="/ROOT"><link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.min.css" rel="Stylesheet" />
<link type="text/css" href="/ROOT/skin/jquery-ui/jquery-ui.theme.min.css" rel="Stylesheet" />
<link type="text/css" href="/ROOT/skin/taskbar.css" rel="Stylesheet" />
<script type="text/javascript" src="/ROOT/skin/jquery-ui/external/jquery/jquery.js" defer></script>
@ -497,8 +498,7 @@ std::string TestContentIn404HtmlResponse::pageCssLink() const
return R"( <link type="text/css" href=")"
+ expectedCssUrl
+ R"(" rel="Stylesheet" />
)";
+ R"(" rel="Stylesheet" />)";
}
std::string TestContentIn404HtmlResponse::hiddenBookNameInput() const
@ -769,6 +769,7 @@ TEST_F(ServerTest, 500)
<head>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>Internal Server Error</title>
</head>
<body>
<h1>Internal Server Error</h1>