From cc7f3cb61798463036a886ae5f0ccd06aca5e625 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Thu, 20 Mar 2014 15:39:17 +0100 Subject: [PATCH] initial implemention of autocompletion in opensearch.xml --- searx/templates/opensearch.xml | 11 ++++++++++- searx/webapp.py | 15 +++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/searx/templates/opensearch.xml b/searx/templates/opensearch.xml index 68b030b3a..b99a9bb24 100644 --- a/searx/templates/opensearch.xml +++ b/searx/templates/opensearch.xml @@ -6,9 +6,18 @@ searx metasearch {% if method == 'get' %} + + + + {% else %} - + + + + + + {% endif %} diff --git a/searx/webapp.py b/searx/webapp.py index e818ae710..3034b2153 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -233,10 +233,17 @@ def autocompleter(): # TODO fix XSS-vulnerability, remove test code autocompleter.querry = request_data.get('q') - autocompleter.results = [autocompleter.querry] - - return Response(json.dumps(autocompleter.results), - mimetype='application/json') + autocompleter.results = [] + + if autocompleter.querry: + autocompleter.results = [autocompleter.querry + "-searx",autocompleter.querry + " asfded",autocompleter.querry + " asdf"] + + if request_data.get('format') == 'x-suggestions': + return Response(json.dumps([autocompleter.querry,autocompleter.results]), + mimetype='application/json') + else: + return Response(json.dumps(autocompleter.results), + mimetype='application/json') @app.route('/preferences', methods=['GET', 'POST'])