logo

searx

My custom branche(s) on searx, a meta-search engine
commit: b6de23f540fc47099303eca82727128957136ea8
parent: e34166168ccb3700d6e7b9b3c28870039d070e46
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Tue, 12 May 2015 08:21:39 +0200

[enh] cleaner category/engine selection from GET/POST param - closes #289

Diffstat:

Msearx/search.py17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git 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)