mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-26 10:11:30 +00:00
Demo of error page translation
This commit demonstrates front-end-side translation of an error page for a URL like /viewer#INVALIDBOOK/whatever (where INVALIDBOOK should be a book name NOT present in the library). Known issues: - This change breaks a couple of subtests in the ServerTest.Http404HtmlError unit test. - Changing the UI language while an error page is displayed in the viewer doesn't retranslate it.
This commit is contained in:
committed by
Matthieu Gautier
parent
bceba4da06
commit
103a4516db
@ -1133,7 +1133,7 @@ std::unique_ptr<Response> InternalServer::handle_content(const RequestContext& r
|
||||
|
||||
if (archive == nullptr) {
|
||||
const std::string searchURL = m_root + "/search?pattern=" + kiwix::urlEncode(pattern);
|
||||
return UrlNotFoundResponse(request)
|
||||
return UrlNotFoundResponse(request, true)
|
||||
+ suggestSearchMsg(searchURL, kiwix::urlDecode(pattern));
|
||||
}
|
||||
|
||||
|
@ -334,16 +334,20 @@ HTTPErrorResponse::HTTPErrorResponse(const RequestContext& request,
|
||||
});
|
||||
}
|
||||
|
||||
HTTP404Response::HTTP404Response(const RequestContext& request)
|
||||
HTTP404Response::HTTP404Response(const RequestContext& request,
|
||||
bool includeKiwixResponseData)
|
||||
: HTTPErrorResponse(request,
|
||||
MHD_HTTP_NOT_FOUND,
|
||||
"404-page-title",
|
||||
"404-page-heading")
|
||||
"404-page-heading",
|
||||
std::string(),
|
||||
includeKiwixResponseData)
|
||||
{
|
||||
}
|
||||
|
||||
UrlNotFoundResponse::UrlNotFoundResponse(const RequestContext& request)
|
||||
: HTTP404Response(request)
|
||||
UrlNotFoundResponse::UrlNotFoundResponse(const RequestContext& request,
|
||||
bool includeKiwixResponseData)
|
||||
: HTTP404Response(request, includeKiwixResponseData)
|
||||
{
|
||||
const std::string requestUrl = urlDecode(m_request.get_full_url(), false);
|
||||
*this += ParameterizedMessage("url-not-found", {{"url", requestUrl}});
|
||||
|
@ -160,12 +160,14 @@ struct HTTPErrorResponse : ContentResponseBlueprint
|
||||
|
||||
struct HTTP404Response : HTTPErrorResponse
|
||||
{
|
||||
explicit HTTP404Response(const RequestContext& request);
|
||||
explicit HTTP404Response(const RequestContext& request,
|
||||
bool includeKiwixResponseData = false);
|
||||
};
|
||||
|
||||
struct UrlNotFoundResponse : HTTP404Response
|
||||
{
|
||||
explicit UrlNotFoundResponse(const RequestContext& request);
|
||||
explicit UrlNotFoundResponse(const RequestContext& request,
|
||||
bool includeKiwixResponseData = false);
|
||||
};
|
||||
|
||||
struct HTTP400Response : HTTPErrorResponse
|
||||
|
Reference in New Issue
Block a user