From ad8ffd222cf9edbd9ce474473dfe231c1f6afda7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 4 Sep 2022 09:36:01 +0200 Subject: [PATCH] [mod] option 'ui: cache_url:' to configure internet cache or archive Signed-off-by: Markus Heiser --- docs/admin/engines/settings.rst | 10 ++++++++++ searx/settings.yml | 2 ++ searx/settings_defaults.py | 1 + searx/templates/simple/macros.html | 2 +- searx/webapp.py | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index f85c6a75f..b1853a11b 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -240,6 +240,7 @@ Global Settings query_in_title: false infinite_scroll: false center_alignment: false + cache_url: https://web.archive.org/web/ default_theme: simple theme_args: simple_style: auto @@ -267,6 +268,15 @@ Global Settings side of the screen. This setting only affects the *desktop layout* (:origin:`min-width: @tablet `) +.. cache_url: + +``cache_url`` : ``https://web.archive.org/web/`` + URL prefix of the internet archive or cache, don't forgett trailing slash (if + needed). The default is https://web.archive.org/web/ alternatives are: + + - https://webcache.googleusercontent.com/search?q=cache: + - https://archive.today/ + ``default_theme`` : Name of the theme you want to use by default on your SearXNG instance. diff --git a/searx/settings.yml b/searx/settings.yml index 5587ed51a..96ebd9715 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -95,6 +95,8 @@ ui: default_theme: simple # center the results ? center_alignment: false + # URL prefix of the internet archive, don't forgett trailing slash (if needed). + # cache_url: "https://webcache.googleusercontent.com/search?q=cache:" # Default interface locale - leave blank to detect from browser information or # use codes from the 'locales' config section default_locale: "" diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index 4e06fb023..330878c1f 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -190,6 +190,7 @@ SCHEMA = { 'advanced_search': SettingsValue(bool, False), 'query_in_title': SettingsValue(bool, False), 'infinite_scroll': SettingsValue(bool, False), + 'cache_url': SettingsValue(str, 'https://web.archive.org/web/'), }, 'preferences': { 'lock': SettingsValue(list, []), diff --git a/searx/templates/simple/macros.html b/searx/templates/simple/macros.html index e06157867..d9af3fbbb 100644 --- a/searx/templates/simple/macros.html +++ b/searx/templates/simple/macros.html @@ -42,7 +42,7 @@ {%- macro result_sub_footer(result, proxify) -%}
{% for engine in result.engines %}{{ engine }}{% endfor %} - {{ result_link("https://web.archive.org/web/" + result.url, icon_small('ellipsis-vertical-outline') + _('cached'), "cache_link") }}‎ {% if proxify and proxify_results %} {{ result_link(proxify(result.url), icon('link') + _('proxied'), "proxyfied_link") }} {% endif %} + {{ result_link(cache_url + result.url, icon_small('ellipsis-vertical-outline') + _('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 8c2046b5c..369b2d2db 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -464,6 +464,7 @@ def render(template_name: str, **kwargs): kwargs['image_proxify'] = image_proxify kwargs['proxify'] = morty_proxify if settings['result_proxy']['url'] is not None else None kwargs['proxify_results'] = settings['result_proxy']['proxify_results'] + kwargs['cache_url'] = settings['ui']['cache_url'] kwargs['get_result_template'] = get_result_template kwargs['opensearch_url'] = ( url_for('opensearch')