mirror of https://github.com/kiwix/libkiwix.git
Last step of removing root from ContentResponse
This commit is contained in:
parent
6a651e04e5
commit
db3b76247f
|
@ -661,7 +661,7 @@ MustacheData InternalServer::get_default_data() const
|
||||||
|
|
||||||
std::unique_ptr<Response> InternalServer::build_homepage(const RequestContext& request)
|
std::unique_ptr<Response> InternalServer::build_homepage(const RequestContext& request)
|
||||||
{
|
{
|
||||||
return ContentResponse::build(m_root, m_indexTemplateString, get_default_data(), "text/html; charset=utf-8");
|
return ContentResponse::build(m_indexTemplateString, get_default_data(), "text/html; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -754,7 +754,7 @@ std::unique_ptr<Response> InternalServer::handle_viewer_settings(const RequestCo
|
||||||
{"enable_library_button", m_withLibraryButton ? "true" : "false" },
|
{"enable_library_button", m_withLibraryButton ? "true" : "false" },
|
||||||
{"default_user_language", request.get_user_language() }
|
{"default_user_language", request.get_user_language() }
|
||||||
};
|
};
|
||||||
return ContentResponse::build(m_root, RESOURCE::templates::viewer_settings_js, data, "application/javascript; charset=utf-8");
|
return ContentResponse::build(RESOURCE::templates::viewer_settings_js, data, "application/javascript; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InternalServer::getNoJSDownloadPageHTML(const std::string& bookId, const std::string& userLang) const
|
std::string InternalServer::getNoJSDownloadPageHTML(const std::string& bookId, const std::string& userLang) const
|
||||||
|
@ -871,7 +871,6 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
if ( startsWith(request.get_url(), "/search/") ) {
|
if ( startsWith(request.get_url(), "/search/") ) {
|
||||||
if (request.get_url() == "/search/searchdescription.xml") {
|
if (request.get_url() == "/search/searchdescription.xml") {
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
m_root,
|
|
||||||
RESOURCE::ft_opensearchdescription_xml,
|
RESOURCE::ft_opensearchdescription_xml,
|
||||||
get_default_data(),
|
get_default_data(),
|
||||||
"application/opensearchdescription+xml");
|
"application/opensearchdescription+xml");
|
||||||
|
@ -1021,7 +1020,7 @@ std::unique_ptr<Response> InternalServer::handle_captured_external(const Request
|
||||||
|
|
||||||
auto data = get_default_data();
|
auto data = get_default_data();
|
||||||
data.set("source", source);
|
data.set("source", source);
|
||||||
return ContentResponse::build(m_root, RESOURCE::templates::captured_external_html, data, "text/html; charset=utf-8");
|
return ContentResponse::build(RESOURCE::templates::captured_external_html, data, "text/html; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Response> InternalServer::handle_catch(const RequestContext& request)
|
std::unique_ptr<Response> InternalServer::handle_catch(const RequestContext& request)
|
||||||
|
|
|
@ -75,7 +75,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog(const RequestContext& r
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url == "searchdescription.xml") {
|
if (url == "searchdescription.xml") {
|
||||||
auto response = ContentResponse::build(m_root, RESOURCE::opensearchdescription_xml, get_default_data(), "application/opensearchdescription+xml");
|
auto response = ContentResponse::build(RESOURCE::opensearchdescription_xml, get_default_data(), "application/opensearchdescription+xml");
|
||||||
return std::move(response);
|
return std::move(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2(const RequestContext
|
||||||
return handle_catalog_v2_root(request);
|
return handle_catalog_v2_root(request);
|
||||||
} else if (url == "searchdescription.xml") {
|
} else if (url == "searchdescription.xml") {
|
||||||
const std::string endpoint_root = m_root + "/catalog/v2";
|
const std::string endpoint_root = m_root + "/catalog/v2";
|
||||||
return ContentResponse::build(m_root,
|
return ContentResponse::build(
|
||||||
RESOURCE::catalog_v2_searchdescription_xml,
|
RESOURCE::catalog_v2_searchdescription_xml,
|
||||||
kainjow::mustache::object({{"endpoint_root", endpoint_root}}),
|
kainjow::mustache::object({{"endpoint_root", endpoint_root}}),
|
||||||
"application/opensearchdescription+xml"
|
"application/opensearchdescription+xml"
|
||||||
|
@ -142,7 +142,6 @@ std::unique_ptr<Response> InternalServer::handle_catalog_v2_root(const RequestCo
|
||||||
{
|
{
|
||||||
const std::string libraryId = getLibraryId();
|
const std::string libraryId = getLibraryId();
|
||||||
return ContentResponse::build(
|
return ContentResponse::build(
|
||||||
m_root,
|
|
||||||
RESOURCE::templates::catalog_v2_root_xml,
|
RESOURCE::templates::catalog_v2_root_xml,
|
||||||
kainjow::mustache::object{
|
kainjow::mustache::object{
|
||||||
{"date", gen_date_str()},
|
{"date", gen_date_str()},
|
||||||
|
|
|
@ -158,7 +158,7 @@ std::string ContentResponseBlueprint::getMessage(const std::string& msgId) const
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> ContentResponseBlueprint::generateResponseObject() const
|
std::unique_ptr<ContentResponse> ContentResponseBlueprint::generateResponseObject() const
|
||||||
{
|
{
|
||||||
auto r = ContentResponse::build(m_root, m_template, m_data, m_mimeType);
|
auto r = ContentResponse::build(m_template, m_data, m_mimeType);
|
||||||
r->set_code(m_httpStatusCode);
|
r->set_code(m_httpStatusCode);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ HTTP500Response::HTTP500Response(const std::string& root,
|
||||||
std::unique_ptr<ContentResponse> HTTP500Response::generateResponseObject() const
|
std::unique_ptr<ContentResponse> HTTP500Response::generateResponseObject() const
|
||||||
{
|
{
|
||||||
const std::string mimeType = "text/html;charset=utf-8";
|
const std::string mimeType = "text/html;charset=utf-8";
|
||||||
auto r = ContentResponse::build(m_root, m_template, m_data, mimeType);
|
auto r = ContentResponse::build(m_template, m_data, mimeType);
|
||||||
r->set_code(m_httpStatusCode);
|
r->set_code(m_httpStatusCode);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,6 @@ std::unique_ptr<ContentResponse> ContentResponse::build(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> ContentResponse::build(
|
std::unique_ptr<ContentResponse> ContentResponse::build(
|
||||||
const std::string& root,
|
|
||||||
const std::string& template_str,
|
const std::string& template_str,
|
||||||
kainjow::mustache::data data,
|
kainjow::mustache::data data,
|
||||||
const std::string& mimetype)
|
const std::string& mimetype)
|
||||||
|
|
|
@ -97,7 +97,6 @@ class ContentResponse : public Response {
|
||||||
const std::string& mimetype);
|
const std::string& mimetype);
|
||||||
|
|
||||||
static std::unique_ptr<ContentResponse> build(
|
static std::unique_ptr<ContentResponse> build(
|
||||||
const std::string& root,
|
|
||||||
const std::string& template_str,
|
const std::string& template_str,
|
||||||
kainjow::mustache::data data,
|
kainjow::mustache::data data,
|
||||||
const std::string& mimetype);
|
const std::string& mimetype);
|
||||||
|
|
Loading…
Reference in New Issue