on master help sign in
[enh][fix] opensearch separation ++ better chrome support
commit941e5fb2c4dc8f9c02709c87e5f096d2adef246a authorasciimoo <asciimoo@gmail.com> dateThu 30 Jan 2014, 13:30 (13 years ago) parent08136f5
2 files changed+15−16
searx/templates/opensearch.xml+14 searx/webapp.py+1−16
searx/templates/opensearch.xmlnew file+14
@@ -0,0 +1,14 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
3+ <ShortName>searx</ShortName>
4+ <Description>Search searx</Description>
5+ <InputEncoding>UTF-8</InputEncoding>
6+ <LongName>searx metasearch</LongName>
7+ {% if method == 'get' %}
8+ <Url type="text/html" method="get" template="{{ host }}?q={searchTerms}"/>
9+ {% else %}
10+ <Url type="text/html" method="post" template="{{ host }}">
11+ <Param name="q" value="{searchTerms}" />
12+ </Url>
13+ {% endif %}
14+</OpenSearchDescription>
searx/webapp.py+1−16
@@ -48,19 +48,6 @@ favicons = ['wikipedia', 'youtube', 'vimeo', 'soundcloud',
4848 'twitter', 'stackoverflow', 'github']
4949
5050
51−opensearch_xml = '''<?xml version="1.0" encoding="utf-8"?>
52−<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
53− <ShortName>searx</ShortName>
54− <Description>Search searx</Description>
55− <InputEncoding>UTF-8</InputEncoding>
56− <LongName>searx meta search engine</LongName>
57− <Url type="text/html" method="{method}" template="{host}">
58− <Param name="q" value="{{searchTerms}}" />
59− </Url>
60−</OpenSearchDescription>
61−'''
62−
63−
6451@babel.localeselector
6552def get_locale():
6653 locale = request.accept_languages.best_match(settings['locales'].keys())
@@ -298,13 +285,11 @@ Disallow: /engines
298285
299286@app.route('/opensearch.xml', methods=['GET'])
300287def opensearch():
301− global opensearch_xml
302288 method = 'post'
303289 # chrome/chromium only supports HTTP GET....
304290 if request.headers.get('User-Agent', '').lower().find('webkit') >= 0:
305291 method = 'get'
306− base_url = get_base_url()
307− ret = opensearch_xml.format(method=method, host=base_url)
292+ ret = render('opensearch.xml', method=method, host=get_base_url())
308293 resp = Response(response=ret,
309294 status=200,
310295 mimetype="application/xml")