summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2022-08-11 18:37:12 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2022-08-11 19:04:36 +0200
commit3b0f9c07b2f007b0767787da80b49827f752f528 (patch)
tree9d98aad92c23312774ed449fee80a45174183169 /searx/webapp.py
parent2bfb269f0a2a2c35d3e4752cb839c38ddcaf805d (diff)
downloadsearxng-3b0f9c07b2f007b0767787da80b49827f752f528.tar.gz
searxng-3b0f9c07b2f007b0767787da80b49827f752f528.zip
[fix] improve OpenSearch description
Some HTTP-Clients do have issues with the ``opensearch.xml`` from SearXNG (related [1][2]) while other OpenSearch descriptions[3] (e.g. from qwant) work flawles. Inspired by the OpenSearch description from qwant and with informations from the specification[4] the ``opensearch.xml`` has been *improved*. - convert `<Url>` methods from lower case to upper case (`POST`|`GET`) - add `<moz:SearchForm>` and `xmlns:moz="http://www.mozilla.org/2006/browser/search/"` - add `<Query role="example" searchTerms="SearXNG" />` [4] OpenSearch description documents should include at least one Query element of `role="example"` that is expected to return search results. Search clients may use this example query to validate that the search engine is working properly. - modified `<LongName>` to SearXNG - modified `<Description>` the word 'hackable' scares uninitiated users and was removed - add the `type="image/png"` to `<Image>` Test can be done by:: make run Visit http://127.0.0.1:8888/ and add the search engine to your WEB-Browser / test with different WEB-Browser from desktop and Smartphones (are there any iOS user here, please test on Safari and Chrome). [1] https://app.element.io/#/room/#searxng:matrix.org/$xN_abdKhNqUlgXRBrb_9F3pqOxnSzGQ1TG0s0G9hQVw [2] https://github.com/searxng/searxng/issues/431 [3] https://developer.mozilla.org/en-US/docs/Web/OpenSearch [4] https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md#the-query-element Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-xsearx/webapp.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 83bbeac06..eb2b19d44 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -1282,19 +1282,17 @@ Disallow: /*?*q=*
@app.route('/opensearch.xml', methods=['GET'])
def opensearch():
- method = 'post'
-
- if request.preferences.get_value('method') == 'GET':
- method = 'get'
+ method = request.preferences.get_value('method')
+ autocomplete = request.preferences.get_value('autocomplete')
# chrome/chromium only supports HTTP GET....
if request.headers.get('User-Agent', '').lower().find('webkit') >= 0:
- method = 'get'
+ method = 'GET'
- autocomplete = request.preferences.get_value('autocomplete')
+ if method not in ('POST', 'GET'):
+ method = 'POST'
ret = render('opensearch.xml', opensearch_method=method, autocomplete=autocomplete)
-
resp = Response(response=ret, status=200, mimetype="application/opensearchdescription+xml")
return resp