mirror of https://github.com/kiwix/libkiwix.git
Reduce complexity of handle_catalog.
This commit is contained in:
parent
d90f8b0f05
commit
fae0918f49
|
@ -702,11 +702,18 @@ Response InternalServer::handle_catalog(const RequestContext& request)
|
||||||
return build_404(request, "");
|
return build_404(request, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url != "searchdescription.xml" && url != "root.xml" && url != "search") {
|
||||||
|
return build_404(request, "");
|
||||||
|
}
|
||||||
|
|
||||||
auto response = get_default_response();
|
auto response = get_default_response();
|
||||||
|
response.set_compress(true);
|
||||||
if (url == "searchdescription.xml") {
|
if (url == "searchdescription.xml") {
|
||||||
response.set_template(RESOURCE::opensearchdescription_xml, get_default_data());
|
response.set_template(RESOURCE::opensearchdescription_xml, get_default_data());
|
||||||
response.set_mimeType("application/opensearchdescription+xml");
|
response.set_mimeType("application/opensearchdescription+xml");
|
||||||
} else {
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
zim::Uuid uuid;
|
zim::Uuid uuid;
|
||||||
kiwix::OPDSDumper opdsDumper;
|
kiwix::OPDSDumper opdsDumper;
|
||||||
opdsDumper.setRootLocation(m_root);
|
opdsDumper.setRootLocation(m_root);
|
||||||
|
@ -718,7 +725,6 @@ Response InternalServer::handle_catalog(const RequestContext& request)
|
||||||
if (url == "root.xml") {
|
if (url == "root.xml") {
|
||||||
opdsDumper.setTitle("All zims");
|
opdsDumper.setTitle("All zims");
|
||||||
uuid = zim::Uuid::generate(host);
|
uuid = zim::Uuid::generate(host);
|
||||||
|
|
||||||
bookIdsToDump = m_library.filter(kiwix::Filter().valid(true).local(true).remote(true));
|
bookIdsToDump = m_library.filter(kiwix::Filter().valid(true).local(true).remote(true));
|
||||||
} else if (url == "search") {
|
} else if (url == "search") {
|
||||||
std::string query;
|
std::string query;
|
||||||
|
@ -760,14 +766,9 @@ Response InternalServer::handle_catalog(const RequestContext& request)
|
||||||
bookIdsToDump.resize(count);
|
bookIdsToDump.resize(count);
|
||||||
}
|
}
|
||||||
opdsDumper.setOpenSearchInfo(totalResults, startIndex, bookIdsToDump.size());
|
opdsDumper.setOpenSearchInfo(totalResults, startIndex, bookIdsToDump.size());
|
||||||
} else {
|
|
||||||
return build_404(request, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.set_content(opdsDumper.dumpOPDSFeed(bookIdsToDump));
|
response.set_content(opdsDumper.dumpOPDSFeed(bookIdsToDump));
|
||||||
}
|
|
||||||
|
|
||||||
response.set_compress(true);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue