From f8f239fe1fb0439635086713e9fd2a14d35a70ed Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 2 Jul 2022 11:29:21 +0200 Subject: [PATCH] Donation link: default value to searxng.org, can be hidden or custom Add a new setting: general.donation_url By default the value is https://docs.searxng.org/donate.html When the value is false, the link is hidden When the value is true, the link goes to the infopage donation, the administrator can create a custom page. --- searx/infopage/en/donate.md | 3 --- searx/settings.yml | 18 +++++++++++++----- searx/settings_defaults.py | 1 + searx/templates/simple/base.html | 4 +++- searx/webapp.py | 6 ++++++ 5 files changed, 23 insertions(+), 9 deletions(-) delete mode 100644 searx/infopage/en/donate.md diff --git a/searx/infopage/en/donate.md b/searx/infopage/en/donate.md deleted file mode 100644 index d2e0dbddb..000000000 --- a/searx/infopage/en/donate.md +++ /dev/null @@ -1,3 +0,0 @@ -# Donate to searxng.org - -You can support the SearXNG project by clicking on the donation page: [https://docs.searxng.org/donate.html](https://docs.searxng.org/donate.html) diff --git a/searx/settings.yml b/searx/settings.yml index 5757a4160..3ecad0df5 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1,9 +1,17 @@ general: - debug: false # Debug mode, only for development - instance_name: "SearXNG" # displayed name - privacypolicy_url: false # https://example.com/privacy - contact_url: false # mailto:contact@example.com - enable_metrics: true # record stats + # Debug mode, only for development + debug: false + # displayed name + instance_name: "SearXNG" + # For example: https://example.com/privacy + privacypolicy_url: false + # use true to use your own donation page written in searx/info/en/donate.md + # use false to disable the donation link + donation_url: https://docs.searxng.org/donate.html + # mailto:contact@example.com + contact_url: false + # record stats + enable_metrics: true brand: new_issue_url: https://github.com/searxng/searxng/issues/new diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index ccbbbf287..d951624cd 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -142,6 +142,7 @@ SCHEMA = { 'instance_name': SettingsValue(str, 'SearXNG'), 'privacypolicy_url': SettingsValue((None, False, str), None), 'contact_url': SettingsValue((None, False, str), None), + 'donation_url': SettingsValue((bool, str), "https://docs.searxng.org/donate.html"), 'enable_metrics': SettingsValue(bool, True), }, 'brand': { diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index fbb60cc26..b9867c42f 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -46,7 +46,9 @@ {{ icon_big('information-circle-outline') }}{{ _('About') }} {%- endblock -%} {%- block linkto_donate -%} - {{ icon_big('heart-outline') }}{{ _('Donate') }} + {%- if donation_url -%} + {{ icon_big('heart-outline') }}{{ _('Donate') }} + {%- endif -%} {%- endblock -%} {%- block linkto_preferences -%} {{ icon_big('menu-outline') }}{{ _('Preferences') }} diff --git a/searx/webapp.py b/searx/webapp.py index d4fb1c7dc..151eb5cc6 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -453,6 +453,12 @@ def render(template_name: str, **kwargs): kwargs['get_setting'] = get_setting kwargs['get_pretty_url'] = get_pretty_url + # values from settings: donation_url + donation_url = get_setting('general.donation_url') + if donation_url is True: + donation_url = custom_url_for('info', pagename='donate') + kwargs['donation_url'] = donation_url + # helpers to create links to other pages kwargs['url_for'] = custom_url_for # override url_for function in templates kwargs['image_proxify'] = image_proxify