mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 03:52:35 -04:00
Merge pull request #266 from kiwix/filter_by_tag
Allow to search the catalog by tags.
This commit is contained in:
commit
790bd03bd7
@ -698,6 +698,7 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
|
|||||||
} else if (url == "search") {
|
} else if (url == "search") {
|
||||||
std::string query;
|
std::string query;
|
||||||
std::string language;
|
std::string language;
|
||||||
|
std::vector<std::string> tags;
|
||||||
size_t count(10);
|
size_t count(10);
|
||||||
size_t startIndex(0);
|
size_t startIndex(0);
|
||||||
try {
|
try {
|
||||||
@ -712,13 +713,19 @@ static struct MHD_Response* handle_catalog(RequestContext* request)
|
|||||||
try {
|
try {
|
||||||
startIndex = stoul(request->get_argument("start"));
|
startIndex = stoul(request->get_argument("start"));
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
|
try {
|
||||||
|
tags.push_back(request->get_argument("tag"));
|
||||||
|
} catch (...) {}
|
||||||
opdsDumper.setTitle("Search result for " + query);
|
opdsDumper.setTitle("Search result for " + query);
|
||||||
uuid = zim::Uuid::generate();
|
uuid = zim::Uuid::generate();
|
||||||
bookIdsToDump = library.listBooksIds(
|
bookIdsToDump = library.listBooksIds(
|
||||||
kiwix::VALID|kiwix::LOCAL|kiwix::REMOTE,
|
kiwix::VALID|kiwix::LOCAL|kiwix::REMOTE,
|
||||||
kiwix::UNSORTED,
|
kiwix::UNSORTED,
|
||||||
query,
|
query,
|
||||||
language);
|
language,
|
||||||
|
"", // creator
|
||||||
|
"", // publisher
|
||||||
|
tags);
|
||||||
auto totalResults = bookIdsToDump.size();
|
auto totalResults = bookIdsToDump.size();
|
||||||
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex);
|
bookIdsToDump.erase(bookIdsToDump.begin(), bookIdsToDump.begin()+startIndex);
|
||||||
if (count>0 && bookIdsToDump.size() > count) {
|
if (count>0 && bookIdsToDump.size() > count) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user