diff --git a/searx/settings.yml b/searx/settings.yml
index 070c30ea..e9ba2179 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -5,6 +5,9 @@ server:
request_timeout : 2.0 # seconds
base_url : False
+client:
+ autocompleter : False # only for developers, no real results yet
+
engines:
- name : wikipedia
engine : wikipedia
diff --git a/searx/static/js/searx.js b/searx/static/js/searx.js
index 8687a906..2b2e0c98 100644
--- a/searx/static/js/searx.js
+++ b/searx/static/js/searx.js
@@ -1,18 +1,20 @@
-window.addEvent('domready', function() {
- new Autocompleter.Request.JSON('q', '/autocompleter', {
- postVar:'q',
- postData:{
- 'format': 'json'
- },
- ajaxOptions:{
- timeout: 5 // Correct option?
- },
- 'minLength': 4,
- 'selectMode': 'type-ahead',
- cache: true,
- delay: 300
- });
-});
+if(searx.autocompleter) {
+ window.addEvent('domready', function() {
+ new Autocompleter.Request.JSON('q', '/autocompleter', {
+ postVar:'q',
+ postData:{
+ 'format': 'json'
+ },
+ ajaxOptions:{
+ timeout: 5 // Correct option?
+ },
+ 'minLength': 4,
+ 'selectMode': 'type-ahead',
+ cache: true,
+ delay: 300
+ });
+ });
+}
(function (w, d) {
'use strict';
diff --git a/searx/templates/base.html b/searx/templates/base.html
index 2823c684..d86982a5 100644
--- a/searx/templates/base.html
+++ b/searx/templates/base.html
@@ -13,13 +13,19 @@
{% block head %}
{% endblock %}
+
{% block content %}
{% endblock %}
+{% if client.autocompleter %}
+{% endif %}
diff --git a/searx/templates/opensearch.xml b/searx/templates/opensearch.xml
index b99a9bb2..403d18bb 100644
--- a/searx/templates/opensearch.xml
+++ b/searx/templates/opensearch.xml
@@ -6,18 +6,22 @@
searx metasearch
{% if method == 'get' %}
+ {% if client.autocompleter %}
+ {% endif %}
{% else %}
+ {% if client.autocompleter %}
+ {% endif %}
{% endif %}
diff --git a/searx/webapp.py b/searx/webapp.py
index 3034b215..b60b889e 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -120,12 +120,18 @@ def index():
"""
if not request.args and not request.form:
- return render('index.html')
+ return render(
+ 'index.html',
+ client=settings['client']
+ )
try:
search = Search(request)
except:
- return render('index.html')
+ return render(
+ 'index.html',
+ client=settings['client']
+ )
# TODO moar refactor - do_search integration into Search class
search.results, search.suggestions = do_search(search.query,
@@ -206,6 +212,7 @@ def index():
return render(
'results.html',
results=search.results,
+ client=settings['client'],
q=search.request_data['q'],
selected_categories=search.categories,
paging=search.paging,
@@ -231,12 +238,14 @@ def autocompleter():
else:
request_data = request.args
- # TODO fix XSS-vulnerability, remove test code
+ # TODO fix XSS-vulnerability
autocompleter.querry = request_data.get('q')
autocompleter.results = []
- if autocompleter.querry:
- autocompleter.results = [autocompleter.querry + "-searx",autocompleter.querry + " asfded",autocompleter.querry + " asdf"]
+ if settings['client']['autocompleter']:
+ #TODO remove test code and add real autocompletion
+ if autocompleter.querry:
+ autocompleter.results = [autocompleter.querry + " result-1",autocompleter.querry + " result-2",autocompleter.querry + " result-3",autocompleter.querry + " result-4"]
if request_data.get('format') == 'x-suggestions':
return Response(json.dumps([autocompleter.querry,autocompleter.results]),
@@ -344,7 +353,7 @@ def opensearch():
# chrome/chromium only supports HTTP GET....
if request.headers.get('User-Agent', '').lower().find('webkit') >= 0:
method = 'get'
- ret = render('opensearch.xml', method=method, host=get_base_url())
+ ret = render('opensearch.xml', method=method, host=get_base_url(),client=settings['client'])
resp = Response(response=ret,
status=200,
mimetype="application/xml")