mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-06-27 21:39:37 +00:00
Dedicated 'category' parameter in catalog search
This commit is contained in:
@ -391,6 +391,7 @@ enum filterTypes {
|
||||
MAXSIZE = FLAG(11),
|
||||
QUERY = FLAG(12),
|
||||
NAME = FLAG(13),
|
||||
CATEGORY = FLAG(14),
|
||||
};
|
||||
|
||||
Filter& Filter::local(bool accept)
|
||||
@ -443,6 +444,13 @@ Filter& Filter::rejectTags(std::vector<std::string> tags)
|
||||
return *this;
|
||||
}
|
||||
|
||||
Filter& Filter::category(std::string category)
|
||||
{
|
||||
_category = category;
|
||||
activeFilters |= CATEGORY;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Filter& Filter::lang(std::string lang)
|
||||
{
|
||||
_lang = lang;
|
||||
@ -502,6 +510,7 @@ bool Filter::accept(const Book& book) const
|
||||
FILTER(_NOREMOTE, !remote)
|
||||
|
||||
FILTER(MAXSIZE, book.getSize() <= _maxSize)
|
||||
FILTER(CATEGORY, book.getCategory() == _category)
|
||||
FILTER(LANG, book.getLanguage() == _lang)
|
||||
FILTER(_PUBLISHER, book.getPublisher() == _publisher)
|
||||
FILTER(_CREATOR, book.getCreator() == _creator)
|
||||
|
@ -698,6 +698,9 @@ InternalServer::search_catalog(const RequestContext& request,
|
||||
try {
|
||||
filter.name(request.get_argument("name"));
|
||||
} catch (const std::out_of_range&) {}
|
||||
try {
|
||||
filter.category(request.get_argument("category"));
|
||||
} catch (const std::out_of_range&) {}
|
||||
try {
|
||||
filter.lang(request.get_argument("lang"));
|
||||
} catch (const std::out_of_range&) {}
|
||||
|
Reference in New Issue
Block a user