forked from zaclys/searxng
[fix] opensearch.xml URL contains method and autocomplete parameters
When the user add searx as a search engine, the browser loads the /opensearch.xml URL without the cookies. Without the query parameters, the user preferences are ignored (method and autocomplete). In addition, opensearch.xml is modified to support automatic updates, see https://developer.mozilla.org/en-US/docs/Web/OpenSearch
This commit is contained in:
parent
584760cf54
commit
bfdad7bc0f
|
@ -15,4 +15,8 @@
|
||||||
{% if autocomplete %}
|
{% if autocomplete %}
|
||||||
<Url rel="suggestions" type="application/x-suggestions+json" template="{{ host }}autocompleter?q={searchTerms}"/>
|
<Url rel="suggestions" type="application/x-suggestions+json" template="{{ host }}autocompleter?q={searchTerms}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<Url type="application/opensearchdescription+xml"
|
||||||
|
rel="self"
|
||||||
|
template="{{ opensearch_url }}" />
|
||||||
</OpenSearchDescription>
|
</OpenSearchDescription>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<opensearch:totalResults>{{ number_of_results }}</opensearch:totalResults>
|
<opensearch:totalResults>{{ number_of_results }}</opensearch:totalResults>
|
||||||
<opensearch:startIndex>1</opensearch:startIndex>
|
<opensearch:startIndex>1</opensearch:startIndex>
|
||||||
<opensearch:itemsPerPage>{{ number_of_results }}</opensearch:itemsPerPage>
|
<opensearch:itemsPerPage>{{ number_of_results }}</opensearch:itemsPerPage>
|
||||||
<atom:link rel="search" type="application/opensearchdescription+xml" href="{{ base_url }}opensearch.xml"/>
|
<atom:link rel="search" type="application/opensearchdescription+xml" href="{{ opensearch_url }}"/>
|
||||||
<opensearch:Query role="request" searchTerms="{{ q|e }}" startPage="1" />
|
<opensearch:Query role="request" searchTerms="{{ q|e }}" startPage="1" />
|
||||||
{% if error_message %}
|
{% if error_message %}
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block meta %}{% endblock %}
|
{% block meta %}{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
|
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
searx = {};
|
searx = {};
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block meta %}{% endblock %}
|
{% block meta %}{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
|
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body class="{{ endpoint }}_endpoint" >
|
<body class="{{ endpoint }}_endpoint" >
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
|
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/>
|
||||||
<noscript>
|
<noscript>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.tab-content > .active_if_nojs, .active_if_nojs {display: block !important; visibility: visible !important;}
|
.tab-content > .active_if_nojs, .active_if_nojs {display: block !important; visibility: visible !important;}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
data-no-item-found="{{ _('No item found') }}"></script>
|
data-no-item-found="{{ _('No item found') }}"></script>
|
||||||
<!--<![endif]-->
|
<!--<![endif]-->
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ url_for('opensearch') }}"/>
|
<link title="{{ instance_name }}" type="application/opensearchdescription+xml" rel="search" href="{{ opensearch_url }}"/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
|
<link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}" />
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -386,6 +386,9 @@ def render(template_name, override_theme=None, **kwargs):
|
||||||
|
|
||||||
kwargs['proxify'] = proxify if settings.get('result_proxy', {}).get('url') else None
|
kwargs['proxify'] = proxify if settings.get('result_proxy', {}).get('url') else None
|
||||||
|
|
||||||
|
kwargs['opensearch_url'] = url_for('opensearch') + '?' \
|
||||||
|
+ urlencode({'method': kwargs['method'], 'autocomplete': kwargs['autocomplete']})
|
||||||
|
|
||||||
kwargs['get_result_template'] = get_result_template
|
kwargs['get_result_template'] = get_result_template
|
||||||
|
|
||||||
kwargs['theme'] = get_current_theme_name(override=override_theme)
|
kwargs['theme'] = get_current_theme_name(override=override_theme)
|
||||||
|
|
Loading…
Reference in New Issue