summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-11-04 00:18:07 +0100
committerasciimoo <asciimoo@gmail.com>2013-11-04 00:18:07 +0100
commit70278567ecacd1632dfdfdff6dbcc0f14a8fab02 (patch)
tree597914a910d327ce815271170aa95a89e98c8dfc /searx/webapp.py
parentd2a952ecdf5b4580fcb1ee21b1a2cb9a02873685 (diff)
[mod] searching by selected engines
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 86fd4dcfe..6dad9efc2 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -65,6 +65,9 @@ def index():
request_data = request.args
if not request_data.get('q'):
return render('index.html')
+
+ query = request_data['q'].encode('utf-8')
+
selected_categories = []
for pd_name,pd in request_data.items():
if pd_name.startswith('category_'):
@@ -77,8 +80,14 @@ def index():
for ccateg in cookie_categories:
if ccateg in categories:
selected_categories.append(ccateg)
- query = request_data['q'].encode('utf-8')
- results = search(query, request, selected_categories)
+ if not len(selected_categories):
+ selected_categories = ['general']
+
+ selected_engines = []
+ for categ in selected_categories:
+ selected_engines.extend({'category': categ, 'name': x.name} for x in categories[categ])
+
+ results = search(query, request, selected_engines)
for result in results:
if len(result['url']) > 74:
result['pretty_url'] = result['url'][:35] + '[..]' + result['url'][-35:]