mirror of https://github.com/kiwix/libkiwix.git
Got rid of withTaskbarInfo()
This commit is contained in:
parent
800cc5b68a
commit
f4059f3faf
|
@ -593,7 +593,8 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
data.set("pattern", encodeDiples(searchInfo.pattern));
|
data.set("pattern", encodeDiples(searchInfo.pattern));
|
||||||
auto response = ContentResponse::build(*this, RESOURCE::templates::no_search_result_html, data, "text/html; charset=utf-8");
|
auto response = ContentResponse::build(*this, RESOURCE::templates::no_search_result_html, data, "text/html; charset=utf-8");
|
||||||
response->set_code(MHD_HTTP_NOT_FOUND);
|
response->set_code(MHD_HTTP_NOT_FOUND);
|
||||||
return withTaskbarInfo(searchInfo.bookName, archive.get(), std::move(response));
|
response->set_taskbar(searchInfo.bookName, archive.get());
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -622,7 +623,8 @@ std::unique_ptr<Response> InternalServer::handle_search(const RequestContext& re
|
||||||
renderer.setSearchProtocolPrefix(m_root + "/search?");
|
renderer.setSearchProtocolPrefix(m_root + "/search?");
|
||||||
renderer.setPageLength(pageLength);
|
renderer.setPageLength(pageLength);
|
||||||
auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8");
|
auto response = ContentResponse::build(*this, renderer.getHtml(), "text/html; charset=utf-8");
|
||||||
return withTaskbarInfo(searchInfo.bookName, archive.get(), std::move(response));
|
response->set_taskbar(searchInfo.bookName, archive.get());
|
||||||
|
return response;
|
||||||
} catch (const std::invalid_argument& e) {
|
} catch (const std::invalid_argument& e) {
|
||||||
return HTTP400HtmlResponse(*this, request)
|
return HTTP400HtmlResponse(*this, request)
|
||||||
+ invalidUrlMsg
|
+ invalidUrlMsg
|
||||||
|
|
|
@ -91,9 +91,10 @@ std::unique_ptr<ContentResponse> ContentResponseBlueprint::generateResponseObjec
|
||||||
{
|
{
|
||||||
auto r = ContentResponse::build(m_server, m_template, m_data, m_mimeType);
|
auto r = ContentResponse::build(m_server, m_template, m_data, m_mimeType);
|
||||||
r->set_code(m_httpStatusCode);
|
r->set_code(m_httpStatusCode);
|
||||||
return m_taskbarInfo
|
if ( m_taskbarInfo ) {
|
||||||
? withTaskbarInfo(m_taskbarInfo->bookName, m_taskbarInfo->archive, std::move(r))
|
r->set_taskbar(m_taskbarInfo->bookName, m_taskbarInfo->archive);
|
||||||
: std::move(r);
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP404HtmlResponse::HTTP404HtmlResponse(const InternalServer& server,
|
HTTP404HtmlResponse::HTTP404HtmlResponse(const InternalServer& server,
|
||||||
|
@ -442,15 +443,6 @@ std::unique_ptr<ContentResponse> ContentResponse::build(
|
||||||
return ContentResponse::build(server, content, mimetype, isHomePage);
|
return ContentResponse::build(server, content, mimetype, isHomePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> withTaskbarInfo(
|
|
||||||
const std::string& bookName,
|
|
||||||
const zim::Archive* archive,
|
|
||||||
std::unique_ptr<ContentResponse> r)
|
|
||||||
{
|
|
||||||
r->set_taskbar(bookName, archive);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange) :
|
ItemResponse::ItemResponse(bool verbose, const zim::Item& item, const std::string& mimetype, const ByteRange& byterange) :
|
||||||
Response(verbose),
|
Response(verbose),
|
||||||
m_item(item),
|
m_item(item),
|
||||||
|
|
|
@ -136,10 +136,6 @@ struct TaskbarInfo
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<ContentResponse> withTaskbarInfo(const std::string& bookName,
|
|
||||||
const zim::Archive* archive,
|
|
||||||
std::unique_ptr<ContentResponse> r);
|
|
||||||
|
|
||||||
class ContentResponseBlueprint
|
class ContentResponseBlueprint
|
||||||
{
|
{
|
||||||
public: // functions
|
public: // functions
|
||||||
|
|
Loading…
Reference in New Issue