From 3f638ed196cdd98d933d6e70dffe374e2d2456dc Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 18 Jul 2021 15:38:52 +0200 Subject: [PATCH] [mod] drop usage of the searx.brand namespace (templates & /config) In the templates and the /config (JSON) the usage of the 'brand.*' name space is replaced by 'searx.get_setting' function. - new_issue_url --> get_setting('brand.new_issue_url') - brand.GIT_URL --> get_setting('brand.git_url') - brand.PUBLIC_INSTANCES --> get_setting('brand.public_instances') - brand.DOCS_URL --> get_setting('brand.docs_url') - brand.ISSUE_URL --> get_setting('brand.issue_url') - brand.CONTACT_URL --> get_setting('general.contact_url', '') The macro 'new_issue' from searx/templates/*/messages/no_results.html is now imported with context:: {% from '__common__/new_issue.html' import new_issue with context %} To get *public instances URL* from context's 'get_setting()' function:: get_setting('brand.public_instances','') Macro's prototype does no longer need the 'new_issue_url' argument and has been changed to:: macro new_issue(engine_name, engine_reliability) Signed-off-by: Markus Heiser --- searx/templates/__common__/about.html | 14 ++++++++------ searx/templates/__common__/new_issue.html | 6 +++--- searx/templates/oscar/base.html | 10 +++++----- searx/templates/oscar/messages/no_results.html | 2 +- searx/templates/oscar/stats.html | 4 ++-- searx/templates/simple/base.html | 8 ++++---- searx/templates/simple/messages/no_results.html | 2 +- searx/templates/simple/stats.html | 4 ++-- searx/webapp.py | 14 ++++++-------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/searx/templates/__common__/about.html b/searx/templates/__common__/about.html index 72c7b133f..96ebab28a 100644 --- a/searx/templates/__common__/about.html +++ b/searx/templates/__common__/about.html @@ -11,7 +11,7 @@

More about SearXNG ...

@@ -30,7 +30,8 @@
  • SearXNG is free software, the code is 100% open and you can help to make - it better. See more on github. + it better. See more on SearXNG sources.
  • @@ -80,10 +81,11 @@

    SearXNG appreciates your concern regarding logs, so take the code from - the SearXNG project and run it yourself! + the SearXNG project and + run it yourself!

    - Add your instance to this list of + Add your instance to this list of public instances to help other people reclaim their privacy and make the Internet freer! The more decentralized the Internet is, the more freedom we have! @@ -92,8 +94,8 @@

    Where are the docs & code of this instance?

    - See the {{ brand.DOCS_URL }} - and {{ brand.GIT_URL }} + See the SearXNG docs + and SearXNG sources

    diff --git a/searx/templates/__common__/new_issue.html b/searx/templates/__common__/new_issue.html index 1b28804af..c741a049f 100644 --- a/searx/templates/__common__/new_issue.html +++ b/searx/templates/__common__/new_issue.html @@ -1,5 +1,5 @@ -{% macro new_issue(new_issue_url, engine_name, engine_reliability) %} -
    +{% macro new_issue(engine_name, engine_reliability) %} + @@ -52,6 +52,6 @@ or manually by executing the searx/webapp.py file? --> {{-'\n '}}* {{ test_name }}: {% for result in results%}`{{ result }}`,{% endfor -%} {%- endfor -%} - +
    {% endmacro %} diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index b85f69fa9..cc716e62b 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -82,11 +82,11 @@ {% endblock %}

    - {{ _('Powered by') }} searxng - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}
    - {{ _('Source code') }} | - {{ _('Issue tracker') }} | - {{ _('Public instances') }}{% if brand.CONTACT_URL %} | - {{ _('Contact instance maintainer') }}{% endif %} + {{ _('Powered by') }} SearXNG - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}
    + {{ _('Source code') }} | + {{ _('Issue tracker') }} | + {{ _('Public instances') }}{% if get_setting('general.contact_url') %} | + {{ _('Contact instance maintainer') }}{% endif %}

    diff --git a/searx/templates/oscar/messages/no_results.html b/searx/templates/oscar/messages/no_results.html index 7ad6423c5..fe8e39d33 100644 --- a/searx/templates/oscar/messages/no_results.html +++ b/searx/templates/oscar/messages/no_results.html @@ -10,7 +10,7 @@ ){{- '' -}}

    {%- endfor -%} -

    {{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})

    +

    {{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})

    {% else %} diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index 50cea045a..edf0eb6eb 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -51,10 +51,10 @@ diff --git a/searx/templates/simple/messages/no_results.html b/searx/templates/simple/messages/no_results.html index b7f02167e..845f3e21a 100644 --- a/searx/templates/simple/messages/no_results.html +++ b/searx/templates/simple/messages/no_results.html @@ -11,7 +11,7 @@

    {%- endfor %} -

    {{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})

    +

    {{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})

    {% else %} diff --git a/searx/webapp.py b/searx/webapp.py index 4d838062b..09c0643be 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -50,7 +50,7 @@ from flask_babel import ( ) from searx import logger -from searx import brand +from searx import get_setting from searx import ( settings, searx_debug, @@ -473,11 +473,9 @@ def render(template_name, override_theme=None, **kwargs): kwargs['search_formats'] = [ x for x in settings['search']['formats'] if x != 'html' ] - - # brand - kwargs['instance_name'] = settings['general']['instance_name'] + kwargs['instance_name'] = get_setting('general.instance_name') kwargs['searx_version'] = VERSION_STRING - kwargs['brand'] = brand + kwargs['get_setting'] = get_setting # helpers to create links to other pages kwargs['url_for'] = url_for_theme # override url_for function in templates @@ -1323,9 +1321,9 @@ def config(): 'default_theme': settings['ui']['default_theme'], 'version': VERSION_STRING, 'brand': { - 'CONTACT_URL': brand.CONTACT_URL, - 'GIT_URL': brand.GIT_URL, - 'DOCS_URL': brand.DOCS_URL + 'CONTACT_URL': get_setting('general.contact_url'), + 'GIT_URL': get_setting('brand.git_url'), + 'DOCS_URL': get_setting('brand.docs_url'), }, 'doi_resolvers': list(settings['doi_resolvers'].keys()), 'default_doi_resolver': settings['default_doi_resolver'],