diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 1fe083a97..7335b9a2a 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -73,9 +73,6 @@ Global Settings ``wiki_url``: Link to your wiki (or ``false``) -``twitter_url``: - Link to your tweets (or ``false``) - ``server:`` ----------- diff --git a/docs/conf.py b/docs/conf.py index 09cc22878..04c8aa205 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,7 +4,7 @@ import sys, os from pallets_sphinx_themes import ProjectLink -from searx import brand +from searx import get_setting from searx.version import VERSION_STRING # Project -------------------------------------------------------------- @@ -14,6 +14,15 @@ copyright = u'2015-2020, Adam Tauber, Noémi Ványi' author = u'Adam Tauber' release, version = VERSION_STRING, VERSION_STRING +SEARX_URL = get_setting('server.base_url') or 'https://example.org/searx' +GIT_URL = get_setting('brand.git_url') +GIT_BRANCH = get_setting('brand.git_branch') +ISSUE_URL = get_setting('brand.issue_url') +DOCS_URL = get_setting('brand.docs_url') +PUBLIC_INSTANCES = get_setting('brand.public_instances') +CONTACT_URL = get_setting('general.contact_url') +WIKI_URL = get_setting('brand.wiki_url') + # hint: sphinx.ext.viewcode won't highlight when 'highlight_language' [1] is set # to string 'none' [2] # @@ -49,10 +58,10 @@ extlinks['pull'] = ('https://github.com/searxng/searxng/pull/%s', 'PR ') extlinks['pull-searx'] = ('https://github.com/searx/searx/pull/%s', 'PR ') # links to custom brand -extlinks['origin'] = (brand.GIT_URL + '/blob/' + brand.GIT_BRANCH + '/%s', 'git://') -extlinks['patch'] = (brand.GIT_URL + '/commit/%s', '#') -extlinks['search'] = (brand.SEARX_URL + '/%s', '#') -extlinks['docs'] = (brand.DOCS_URL + '/%s', 'docs: ') +extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://') +extlinks['patch'] = (GIT_URL + '/commit/%s', '#') +extlinks['search'] = (SEARX_URL + '/%s', '#') +extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ') extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '') #extlinks['role'] = ( @@ -108,18 +117,16 @@ imgmath_font_size = 14 html_theme_options = {"index_sidebar_logo": True} html_context = {"project_links": [] } -if brand.GIT_URL: - html_context["project_links"].append(ProjectLink("Source", brand.GIT_URL)) -if brand.WIKI_URL: - html_context["project_links"].append(ProjectLink("Wiki", brand.WIKI_URL)) -if brand.PUBLIC_INSTANCES: - html_context["project_links"].append(ProjectLink("Public instances", brand.PUBLIC_INSTANCES)) -if brand.TWITTER_URL: - html_context["project_links"].append(ProjectLink("Twitter", brand.TWITTER_URL)) -if brand.ISSUE_URL: - html_context["project_links"].append(ProjectLink("Issue Tracker", brand.ISSUE_URL)) -if brand.CONTACT_URL: - html_context["project_links"].append(ProjectLink("Contact", brand.CONTACT_URL)) +html_context["project_links"].append(ProjectLink("Source", GIT_URL + '/tree/' + GIT_BRANCH)) + +if WIKI_URL: + html_context["project_links"].append(ProjectLink("Wiki", WIKI_URL)) +if PUBLIC_INSTANCES: + html_context["project_links"].append(ProjectLink("Public instances", PUBLIC_INSTANCES)) +if ISSUE_URL: + html_context["project_links"].append(ProjectLink("Issue Tracker", ISSUE_URL)) +if CONTACT_URL: + html_context["project_links"].append(ProjectLink("Contact", CONTACT_URL)) html_sidebars = { "**": ["project.html", "relations.html", "searchbox.html"], diff --git a/manage b/manage index 6cf562b22..f03343839 100755 --- a/manage +++ b/manage @@ -177,6 +177,13 @@ docker.buildx() { docker.build() { pyenv.install + local SEARX_GIT_VERSION + local VERSION_GITCOMMIT + local SEARX_PYTHON_VERSION + local GITHUB_USER + local SEARX_IMAGE_NAME + local BUILD + build_msg DOCKER build # run installation in a subprocess and activate pyenv diff --git a/searx/__init__.py b/searx/__init__.py index 8452dd7b4..0b73d5204 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -32,52 +32,24 @@ if max_request_timeout is None: else: logger.info('max_request_timeout=%i second(s)', max_request_timeout) +_unset = object() -class _brand_namespace: # pylint: disable=invalid-name +def get_setting(name, default=_unset): + """Returns the value to which ``name`` point. If there is no such name in the + settings and the ``default`` is unset, a :py:obj:`KeyError` is raised. - @classmethod - def get_val(cls, group, name, default=''): - return settings.get(group, {}).get(name) or default + """ + value = settings + for a in name.split('.'): + if isinstance(value, dict): + value = value.get(a, _unset) + else: + value = _unset - @property - def SEARX_URL(self): - return self.get_val('server', 'base_url') + if value is _unset: + if default is _unset: + raise KeyError(name) + value = default + break - @property - def CONTACT_URL(self): - return self.get_val('general', 'contact_url') - - @property - def GIT_URL(self): - return self.get_val('brand', 'git_url') - - @property - def GIT_BRANCH(self): - return self.get_val('brand', 'git_branch') - - @property - def ISSUE_URL(self): - return self.get_val('brand', 'issue_url') - - @property - def NEW_ISSUE_URL(self): - return self.get_val('brand', 'new_issue_url') - - @property - def DOCS_URL(self): - return self.get_val('brand', 'docs_url') - - @property - def PUBLIC_INSTANCES(self): - return self.get_val('brand', 'public_instances') - - @property - def WIKI_URL(self): - return self.get_val('brand', 'wiki_url') - - @property - def TWITTER_URL(self): - return self.get_val('brand', 'twitter_url') - - -brand = _brand_namespace() + return value diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index 8350d92ba..d034cb1cd 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -130,6 +130,13 @@ SCHEMA = { 'contact_url': SettingsValue((None, False, str), None), }, 'brand': { + 'git_url': SettingsValue(str), + 'git_branch': SettingsValue(str), + 'issue_url': SettingsValue(str, None), + 'new_issue_url': SettingsValue(str, None), + 'docs_url': SettingsValue(str, None), + 'public_instances': SettingsValue(str, None), + 'wiki_url': SettingsValue(str, None), }, 'search': { 'safe_search': SettingsValue((0,1,2), 0), diff --git a/searx/settings_robot.yml b/searx/settings_robot.yml index 00dcb8da8..ca65449f7 100644 --- a/searx/settings_robot.yml +++ b/searx/settings_robot.yml @@ -2,6 +2,15 @@ general: debug: false instance_name: "searx_test" +brand: + git_url: https://github.com/searxng/searxng + git_branch: master + issue_url: https://github.com/searxng/searxng/issues + new_issue_url: https://github.com/searxng/searxng/issues/new + docs_url: https://searxng.github.io/searxng + public_instances: https://searx.space + wiki_url: https://github.com/searxng/searxng/wiki + search: language: "all" 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 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 @@
- 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) %} - {% 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 %}
{{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})
+{{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})
{% else %}{{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})
+{{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})
{% else %}