mirror of
https://github.com/searxng/searxng
synced 2024-01-01 18:24:07 +00:00
initial implemention of autocompletion in opensearch.xml
This commit is contained in:
parent
360543dec4
commit
cc7f3cb617
@ -6,9 +6,18 @@
|
|||||||
<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}"/>
|
||||||
|
<Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
|
||||||
|
<Param name="format" value="x-suggestions" />
|
||||||
|
<Param name="q" value="{searchTerms}" />
|
||||||
|
</Url>
|
||||||
{% 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>
|
||||||
|
<!-- TODO, POST REQUEST doesn't work -->
|
||||||
|
<Url type="application/x-suggestions+json" method="get" template="{{ host }}autocompleter">
|
||||||
|
<Param name="format" value="x-suggestions" />
|
||||||
|
<Param name="q" value="{searchTerms}" />
|
||||||
</Url>
|
</Url>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</OpenSearchDescription>
|
</OpenSearchDescription>
|
||||||
|
@ -233,10 +233,17 @@ def autocompleter():
|
|||||||
|
|
||||||
# TODO fix XSS-vulnerability, remove test code
|
# TODO fix XSS-vulnerability, remove test code
|
||||||
autocompleter.querry = request_data.get('q')
|
autocompleter.querry = request_data.get('q')
|
||||||
autocompleter.results = [autocompleter.querry]
|
autocompleter.results = []
|
||||||
|
|
||||||
return Response(json.dumps(autocompleter.results),
|
if autocompleter.querry:
|
||||||
mimetype='application/json')
|
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'])
|
@app.route('/preferences', methods=['GET', 'POST'])
|
||||||
|
Loading…
Reference in New Issue
Block a user