Repository: searxng/searxng
Pull request: [mod] option to enable or disable "proxy" button next to each result
## What does this PR do?

Add option to enable or disable "proxy" button next to each result.

## Why is this change important?

The ability to disable the "proxy" button next to each result.

## Related issues

Closes: https://github.com/searxng/searxng/issues/51


Problem statement:
Add ability to remove "proxy" button
<!-- PLEASE FILL THESE FIELDS, IT REALLY HELPS THE MAINTAINERS OF SEARX -->

**Is your feature request related to a problem? Please describe.**
I don't want people to use the proxy ability to browse on the web using my IPs, but I still want to proxy the resources like the images.

**Describe the solution you'd like**
The ability to disable the "proxy" button next to each result.

**Describe alternatives you've considered**
Override the macros file of each theme.

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

Hints from issue discussion:

Commit message: [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>

Patch to review:
diff --git a/searx/settings.yml b/searx/settings.yml
index 13504867361..d282ccd05d4 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"
+#    button : 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 fbf181518a6..4a423dd6ab7 100644
--- a/searx/templates/oscar/macros.html
+++ b/searx/templates/oscar/macros.html
@@ -39,7 +39,7 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
             <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
             {%- endif -%}
         {%- endif -%}
-        {%- if proxify -%}
+        {%- if proxify and proxify_button -%}
         <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
         {%- endif -%}
     </div>
@@ -55,7 +55,7 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
     {%- for engine in result.engines -%}
         <span class="label label-default">{{ engine }}</span>
     {%- endfor -%}
-    {%- if proxify -%}
+    {%- if proxify and proxify_button -%}
     <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
     {%- endif -%}
 </div>{{- "" -}}
@@ -75,7 +75,7 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
         <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info", id) }}</small>
         {%- endif -%}
     {%- endif -%}
-    {%- if proxify -%}
+    {%- if proxify and proxify_button -%}
     <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info", id) }}</small>
     {%- endif -%}
     {%- if result.pretty_url -%}
@@ -89,7 +89,7 @@ <h4 class="result_header" id="result-{{id}}">{% if result.engine~".png" in favic
     {%- for engine in result.engines -%}
         <span class="label label-default">{{ engine }}</span>
     {%- endfor -%}
-    {%- if proxify -%}
+    {%- if proxify and proxify_button -%}
     <small>{{ result_link(proxify(result.url), icon('sort') + _('proxied'), "text-info") }}</small>
     {%- endif -%}
     <div class="external-link">{{ result.pretty_url }}</div>
diff --git a/searx/templates/simple/macros.html b/searx/templates/simple/macros.html
index 7d456b35086..e8ef6702ab3 100644
--- a/searx/templates/simple/macros.html
+++ b/searx/templates/simple/macros.html
@@ -41,7 +41,7 @@ <h3>{{ result_link(result.url, result.title|safe) }}</h3>
 <!-- Draw result sub footer -->
 {%- macro result_sub_footer(result, proxify) -%}
 <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_button %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %}</p>{{- '' -}}
 <div class="break"></div>{{- '' -}}
 {%- endmacro -%}
 
diff --git a/searx/webapp.py b/searx/webapp.py
index b8bc60ec52a..6ecb2f83e8b 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_button'] = settings.get('result_proxy', {}).get('button', True)
 
     kwargs['opensearch_url'] = url_for('opensearch') + '?' \
         + urlencode({'method': kwargs['method'], 'autocomplete': kwargs['autocomplete']})


Code review comments:
diff_hunk: @@ -65,6 +65,7 @@ ui:
 #result_proxy:
 #    url : http://127.0.0.1:3000/
 #    key : !!binary "your_morty_proxy_key"
+#    button : True  # [True|False] enable the "proxy" button next to each result
path: searx/settings.yml
text: @user1:
Instead of `button` (where is this button ?), I suggest `result_proxy`  ... but actually it is already the name of the section (line 65).

So may be `html_proxy` or `proxied_link` ?

---

If we break the compatibility with searx, it could be :
```
morty:
    url : http://127.0.0.1:3000/
    key : !!binary "your_morty_proxy_key"
    proxify_images: true
    proxify_results: false
```



@user1:
I have a push the commit cf9518b1a0bef31b0184e25d3b8b115e70031ce9

```
#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
```

@author:
> I have a push the commit cf9518b

@user1 thanks! ... I do not have much time ATM .. feel free to squash & rebase ... if you want to merge.