[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 <markus.heiser@darmarit.de>
Co-authored-by: Alexandre Flament <alex@al-f.net>
This commit is contained in:
Markus Heiser 2021-05-04 09:57:14 +00:00 committed by GitHub
parent b646050f6e
commit 5253df946b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View file

@ -65,6 +65,7 @@ ui:
#result_proxy: #result_proxy:
# url : http://127.0.0.1:3000/ # url : http://127.0.0.1:3000/
# key : !!binary "your_morty_proxy_key" # key : !!binary "your_morty_proxy_key"
# proxify_results : True # [True|False] enable the "proxy" button next to each result
outgoing: # communication with search engines outgoing: # communication with search engines
request_timeout : 3.0 # default timeout in seconds, can be override by engine request_timeout : 3.0 # default timeout in seconds, can be override by engine

View file

@ -39,7 +39,7 @@
<small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small> <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- if proxify -%} {%- if proxify and proxify_results -%}
<small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small> <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
{%- endif -%} {%- endif -%}
</div> </div>
@ -55,7 +55,7 @@
{%- for engine in result.engines -%} {%- for engine in result.engines -%}
<span class="label label-default">{{ engine }}</span> <span class="label label-default">{{ engine }}</span>
{%- endfor -%} {%- endfor -%}
{%- if proxify -%} {%- if proxify and proxify_results -%}
<small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small> <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
{%- endif -%} {%- endif -%}
</div>{{- "" -}} </div>{{- "" -}}
@ -75,7 +75,7 @@
<small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small> <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- if proxify -%} {%- if proxify and proxify_results -%}
<small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small> <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
{%- endif -%} {%- endif -%}
{%- if result.pretty_url -%} {%- if result.pretty_url -%}
@ -89,7 +89,7 @@
{%- for engine in result.engines -%} {%- for engine in result.engines -%}
<span class="label label-default">{{ engine }}</span> <span class="label label-default">{{ engine }}</span>
{%- endfor -%} {%- endfor -%}
{%- if proxify -%} {%- if proxify and proxify_results -%}
<small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small> <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
{%- endif -%} {%- endif -%}
<div class="external-link">{{ result.pretty_url }}</div> <div class="external-link">{{ result.pretty_url }}</div>

View file

@ -41,7 +41,7 @@
<!-- Draw result sub footer --> <!-- Draw result sub footer -->
{%- macro result_sub_footer(result, proxify) -%} {%- macro result_sub_footer(result, proxify) -%}
<div class="engines">{% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}</div>{{- '' -}} <div class="engines">{% for engine in result.engines %}<span>{{ engine }}</span>{% endfor %}</div>{{- '' -}}
<p class="url"><span class="url">{{ result.pretty_url }}</span>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}&lrm; {% if proxify %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}</p>{{- '' -}} <p class="url"><span class="url">{{ result.pretty_url }}</span>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "cache_link") }}&lrm; {% if proxify and proxify_results %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}</p>{{- '' -}}
<div class="break"></div>{{- '' -}} <div class="break"></div>{{- '' -}}
{%- endmacro -%} {%- endmacro -%}

View file

@ -444,6 +444,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['image_proxify'] = image_proxify kwargs['image_proxify'] = image_proxify
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['proxify_results'] = settings.get('result_proxy', {}).get('proxify_results', True)
kwargs['opensearch_url'] = url_for('opensearch') + '?' \ kwargs['opensearch_url'] = url_for('opensearch') + '?' \
+ urlencode({'method': kwargs['method'], 'autocomplete': kwargs['autocomplete']}) + urlencode({'method': kwargs['method'], 'autocomplete': kwargs['autocomplete']})