From 5253df946b8eb45903ed6ea7e724ec6b5000b2cf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 4 May 2021 09:57:14 +0000 Subject: [PATCH] [mod] option to enable or disable "proxy" button next to each result (#54) * [mod] option to enable or disable "proxy" button next to each result Closes: https://github.com/searxng/searxng/issues/51 Signed-off-by: Markus Heiser Co-authored-by: Alexandre Flament --- searx/settings.yml | 1 + searx/templates/oscar/macros.html | 8 ++++---- searx/templates/simple/macros.html | 2 +- searx/webapp.py | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/searx/settings.yml b/searx/settings.yml index 135048673..435a638e8 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -65,6 +65,7 @@ ui: #result_proxy: # url : http://127.0.0.1:3000/ # key : !!binary "your_morty_proxy_key" +# proxify_results : True # [True|False] enable the "proxy" button next to each result outgoing: # communication with search engines request_timeout : 3.0 # default timeout in seconds, can be override by engine diff --git a/searx/templates/oscar/macros.html b/searx/templates/oscar/macros.html index fbf181518..2b27cfd28 100644 --- a/searx/templates/oscar/macros.html +++ b/searx/templates/oscar/macros.html @@ -39,7 +39,7 @@ {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }} {%- endif -%} {%- endif -%} - {%- if proxify -%} + {%- if proxify and proxify_results -%} {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }} {%- endif -%} @@ -55,7 +55,7 @@ {%- for engine in result.engines -%} {{ engine }} {%- endfor -%} - {%- if proxify -%} + {%- if proxify and proxify_results -%} {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }} {%- endif -%} {{- "" -}} @@ -75,7 +75,7 @@ {{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }} {%- endif -%} {%- endif -%} - {%- if proxify -%} + {%- if proxify and proxify_results -%} {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }} {%- endif -%} {%- if result.pretty_url -%} @@ -89,7 +89,7 @@ {%- for engine in result.engines -%} {{ engine }} {%- endfor -%} - {%- if proxify -%} + {%- if proxify and proxify_results -%} {{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }} {%- endif -%} diff --git a/searx/templates/simple/macros.html b/searx/templates/simple/macros.html index 7d456b350..4368ecb85 100644 --- a/searx/templates/simple/macros.html +++ b/searx/templates/simple/macros.html @@ -41,7 +41,7 @@ {%- macro result_sub_footer(result, proxify) -%}
{% for engine in result.engines %}{{ engine }}{% endfor %}
{{- '' -}} -

{{ result.pretty_url }}{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}‎ {% if proxify %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}

{{- '' -}} +

{{ result.pretty_url }}{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}‎ {% if proxify and proxify_results %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}

{{- '' -}}
{{- '' -}} {%- endmacro -%} diff --git a/searx/webapp.py b/searx/webapp.py index b8bc60ec5..dd1557c99 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -444,6 +444,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['image_proxify'] = image_proxify kwargs['proxify'] = proxify if settings.get('result_proxy', {}).get('url') else None + kwargs['proxify_results'] = settings.get('result_proxy', {}).get('proxify_results', True) kwargs['opensearch_url'] = url_for('opensearch') + '?' \ + urlencode({'method': kwargs['method'], 'autocomplete': kwargs['autocomplete']})