deactivate autocompleter by default
This commit is contained in:
		
							parent
							
								
									cc7f3cb617
								
							
						
					
					
						commit
						c8cf95aa56
					
				@ -5,6 +5,9 @@ server:
 | 
				
			|||||||
    request_timeout : 2.0 # seconds
 | 
					    request_timeout : 2.0 # seconds
 | 
				
			||||||
    base_url : False
 | 
					    base_url : False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					client:
 | 
				
			||||||
 | 
					    autocompleter : False # only for developers, no real results yet
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
engines:
 | 
					engines:
 | 
				
			||||||
  - name : wikipedia
 | 
					  - name : wikipedia
 | 
				
			||||||
    engine : wikipedia
 | 
					    engine : wikipedia
 | 
				
			||||||
 | 
				
			|||||||
@ -1,18 +1,20 @@
 | 
				
			|||||||
window.addEvent('domready', function() {
 | 
					if(searx.autocompleter) {
 | 
				
			||||||
	new Autocompleter.Request.JSON('q', '/autocompleter', {
 | 
					    window.addEvent('domready', function() {
 | 
				
			||||||
		postVar:'q',
 | 
						    new Autocompleter.Request.JSON('q', '/autocompleter', {
 | 
				
			||||||
		postData:{
 | 
							    postVar:'q',
 | 
				
			||||||
			'format': 'json'
 | 
							    postData:{
 | 
				
			||||||
		},
 | 
								    'format': 'json'
 | 
				
			||||||
		ajaxOptions:{
 | 
							    },
 | 
				
			||||||
		    timeout: 5   // Correct option?
 | 
							    ajaxOptions:{
 | 
				
			||||||
		},
 | 
							        timeout: 5   // Correct option?
 | 
				
			||||||
		'minLength': 4,
 | 
							    },
 | 
				
			||||||
		'selectMode': 'type-ahead',
 | 
							    'minLength': 4,
 | 
				
			||||||
		cache: true,
 | 
							    'selectMode': 'type-ahead',
 | 
				
			||||||
		delay: 300
 | 
							    cache: true,
 | 
				
			||||||
	});
 | 
							    delay: 300
 | 
				
			||||||
});
 | 
						    });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(function (w, d) {
 | 
					(function (w, d) {
 | 
				
			||||||
    'use strict';
 | 
					    'use strict';
 | 
				
			||||||
 | 
				
			|||||||
@ -13,13 +13,19 @@
 | 
				
			|||||||
    {% block head %}
 | 
					    {% block head %}
 | 
				
			||||||
    <link title="searx" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
 | 
					    <link title="searx" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
 | 
				
			||||||
    {% endblock %}
 | 
					    {% endblock %}
 | 
				
			||||||
 | 
					    <script type="text/javascript">
 | 
				
			||||||
 | 
					        searx = {};
 | 
				
			||||||
 | 
					        searx.autocompleter = {% if client.autocompleter %}true{% else %}false{% endif %};
 | 
				
			||||||
 | 
					    </script>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
<div id="container">
 | 
					<div id="container">
 | 
				
			||||||
{% block content %}
 | 
					{% block content %}
 | 
				
			||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					{% if client.autocompleter %}
 | 
				
			||||||
<script src="{{ url_for('static', filename='js/mootools-core-1.4.5-min.js') }}" ></script>
 | 
					<script src="{{ url_for('static', filename='js/mootools-core-1.4.5-min.js') }}" ></script>
 | 
				
			||||||
<script src="{{ url_for('static', filename='js/mootools-autocompleter-1.1.2-min.js') }}" ></script>
 | 
					<script src="{{ url_for('static', filename='js/mootools-autocompleter-1.1.2-min.js') }}" ></script>
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
<script src="{{ url_for('static', filename='js/searx.js') }}" ></script>
 | 
					<script src="{{ url_for('static', filename='js/searx.js') }}" ></script>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
 | 
				
			|||||||
@ -6,18 +6,22 @@
 | 
				
			|||||||
  <LongName>searx metasearch</LongName>
 | 
					  <LongName>searx metasearch</LongName>
 | 
				
			||||||
  {% if method == 'get' %}
 | 
					  {% if method == 'get' %}
 | 
				
			||||||
    <Url type="text/html" method="get" template="{{ host }}?q={searchTerms}"/>
 | 
					    <Url type="text/html" method="get" template="{{ host }}?q={searchTerms}"/>
 | 
				
			||||||
 | 
					    {% if client.autocompleter %}
 | 
				
			||||||
    <Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
 | 
					    <Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
 | 
				
			||||||
        <Param name="format" value="x-suggestions" />
 | 
					        <Param name="format" value="x-suggestions" />
 | 
				
			||||||
        <Param name="q" value="{searchTerms}" />
 | 
					        <Param name="q" value="{searchTerms}" />
 | 
				
			||||||
    </Url>
 | 
					    </Url>
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
  {% else %}
 | 
					  {% else %}
 | 
				
			||||||
    <Url type="text/html" method="post" template="{{ host }}">
 | 
					    <Url type="text/html" method="post" template="{{ host }}">
 | 
				
			||||||
        <Param name="q" value="{searchTerms}" />
 | 
					        <Param name="q" value="{searchTerms}" />
 | 
				
			||||||
    </Url>
 | 
					    </Url>
 | 
				
			||||||
 | 
					    {% if client.autocompleter %}
 | 
				
			||||||
    <!-- TODO, POST REQUEST doesn't work -->
 | 
					    <!-- TODO, POST REQUEST doesn't work -->
 | 
				
			||||||
    <Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
 | 
					    <Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
 | 
				
			||||||
        <Param name="format" value="x-suggestions" />
 | 
					        <Param name="format" value="x-suggestions" />
 | 
				
			||||||
        <Param name="q" value="{searchTerms}" />
 | 
					        <Param name="q" value="{searchTerms}" />
 | 
				
			||||||
    </Url>
 | 
					    </Url>
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
  {% endif %}
 | 
					  {% endif %}
 | 
				
			||||||
</OpenSearchDescription>
 | 
					</OpenSearchDescription>
 | 
				
			||||||
 | 
				
			|||||||
@ -120,12 +120,18 @@ def index():
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if not request.args and not request.form:
 | 
					    if not request.args and not request.form:
 | 
				
			||||||
        return render('index.html')
 | 
					        return render(
 | 
				
			||||||
 | 
					            'index.html',
 | 
				
			||||||
 | 
					            client=settings['client']
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        search = Search(request)
 | 
					        search = Search(request)
 | 
				
			||||||
    except:
 | 
					    except:
 | 
				
			||||||
        return render('index.html')
 | 
					        return render(
 | 
				
			||||||
 | 
					            'index.html',
 | 
				
			||||||
 | 
					            client=settings['client']
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # TODO moar refactor - do_search integration into Search class
 | 
					    # TODO moar refactor - do_search integration into Search class
 | 
				
			||||||
    search.results, search.suggestions = do_search(search.query,
 | 
					    search.results, search.suggestions = do_search(search.query,
 | 
				
			||||||
@ -206,6 +212,7 @@ def index():
 | 
				
			|||||||
    return render(
 | 
					    return render(
 | 
				
			||||||
        'results.html',
 | 
					        'results.html',
 | 
				
			||||||
        results=search.results,
 | 
					        results=search.results,
 | 
				
			||||||
 | 
					        client=settings['client'],
 | 
				
			||||||
        q=search.request_data['q'],
 | 
					        q=search.request_data['q'],
 | 
				
			||||||
        selected_categories=search.categories,
 | 
					        selected_categories=search.categories,
 | 
				
			||||||
        paging=search.paging,
 | 
					        paging=search.paging,
 | 
				
			||||||
@ -231,12 +238,14 @@ def autocompleter():
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        request_data = request.args
 | 
					        request_data = request.args
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    # TODO fix XSS-vulnerability, remove test code
 | 
					    # TODO fix XSS-vulnerability
 | 
				
			||||||
    autocompleter.querry = request_data.get('q')
 | 
					    autocompleter.querry = request_data.get('q')
 | 
				
			||||||
    autocompleter.results = []
 | 
					    autocompleter.results = []
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if autocompleter.querry:
 | 
					    if settings['client']['autocompleter']:
 | 
				
			||||||
        autocompleter.results = [autocompleter.querry + "-searx",autocompleter.querry + " asfded",autocompleter.querry + " asdf"]
 | 
					        #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':
 | 
					    if request_data.get('format') == 'x-suggestions':
 | 
				
			||||||
        return Response(json.dumps([autocompleter.querry,autocompleter.results]),
 | 
					        return Response(json.dumps([autocompleter.querry,autocompleter.results]),
 | 
				
			||||||
@ -344,7 +353,7 @@ def opensearch():
 | 
				
			|||||||
    # chrome/chromium only supports HTTP GET....
 | 
					    # chrome/chromium only supports HTTP GET....
 | 
				
			||||||
    if request.headers.get('User-Agent', '').lower().find('webkit') >= 0:
 | 
					    if request.headers.get('User-Agent', '').lower().find('webkit') >= 0:
 | 
				
			||||||
        method = 'get'
 | 
					        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,
 | 
					    resp = Response(response=ret,
 | 
				
			||||||
                    status=200,
 | 
					                    status=200,
 | 
				
			||||||
                    mimetype="application/xml")
 | 
					                    mimetype="application/xml")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user