diff options
author | Adam Tauber <asciimoo@gmail.com> | 2015-05-12 08:21:39 +0200 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2015-05-12 08:21:39 +0200 |
commit | b6de23f540fc47099303eca82727128957136ea8 (patch) | |
tree | 99f5ac6ac02846e8113d10ff875955bd3aff41a9 /searx/search.py | |
parent | e34166168ccb3700d6e7b9b3c28870039d070e46 (diff) | |
download | searxng-b6de23f540fc47099303eca82727128957136ea8.tar.gz searxng-b6de23f540fc47099303eca82727128957136ea8.zip |
[enh] cleaner category/engine selection from GET/POST param - closes #289
Diffstat (limited to 'searx/search.py')
-rw-r--r-- | searx/search.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/searx/search.py b/searx/search.py index 862b17e33..1ec1c377d 100644 --- a/searx/search.py +++ b/searx/search.py @@ -382,9 +382,19 @@ class Search(object): # otherwise, using defined categories to # calculate which engines should be used else: - # set used categories + # set categories/engines + load_default_categories = True for pd_name, pd in self.request_data.items(): - if pd_name.startswith('category_'): + if pd_name == 'categories': + self.categories.extend(categ for categ in pd.split(',') if categ in categories) + elif pd_name == 'engines': + pd_engines = [{'category': engines[engine].categories[0], + 'name': engine} + for engine in pd.split(',') if engine in engines] + if pd_engines: + self.engines.extend(pd_engines) + load_default_categories = False + elif pd_name.startswith('category_'): category = pd_name[9:] # if category is not found in list, skip @@ -398,6 +408,9 @@ class Search(object): # remove category from list if property is set to 'off' self.categories.remove(category) + if not load_default_categories: + return + # if no category is specified for this search, # using user-defined default-configuration which # (is stored in cookie) |