1
0
mirror of https://github.com/searxng/searxng.git synced 2024-10-05 19:10:10 +02:00

Merge pull request #213 from return42/drop-brand

[mod] drop searx.brand namespace
This commit is contained in:
Alexandre Flament 2021-07-21 14:27:49 +02:00 committed by GitHub
commit 4f0d232a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 126 additions and 117 deletions

View File

@ -73,9 +73,6 @@ Global Settings
``wiki_url``: ``wiki_url``:
Link to your wiki (or ``false``) Link to your wiki (or ``false``)
``twitter_url``:
Link to your tweets (or ``false``)
``server:`` ``server:``
----------- -----------

View File

@ -4,7 +4,7 @@
import sys, os import sys, os
from pallets_sphinx_themes import ProjectLink from pallets_sphinx_themes import ProjectLink
from searx import brand from searx import get_setting
from searx.version import VERSION_STRING from searx.version import VERSION_STRING
# Project -------------------------------------------------------------- # Project --------------------------------------------------------------
@ -14,6 +14,15 @@ copyright = u'2015-2020, Adam Tauber, Noémi Ványi'
author = u'Adam Tauber' author = u'Adam Tauber'
release, version = VERSION_STRING, VERSION_STRING 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 # hint: sphinx.ext.viewcode won't highlight when 'highlight_language' [1] is set
# to string 'none' [2] # 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 ') extlinks['pull-searx'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
# links to custom brand # links to custom brand
extlinks['origin'] = (brand.GIT_URL + '/blob/' + brand.GIT_BRANCH + '/%s', 'git://') extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
extlinks['patch'] = (brand.GIT_URL + '/commit/%s', '#') extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
extlinks['search'] = (brand.SEARX_URL + '/%s', '#') extlinks['search'] = (SEARX_URL + '/%s', '#')
extlinks['docs'] = (brand.DOCS_URL + '/%s', 'docs: ') extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ') extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '') extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
#extlinks['role'] = ( #extlinks['role'] = (
@ -108,18 +117,16 @@ imgmath_font_size = 14
html_theme_options = {"index_sidebar_logo": True} html_theme_options = {"index_sidebar_logo": True}
html_context = {"project_links": [] } html_context = {"project_links": [] }
if brand.GIT_URL: html_context["project_links"].append(ProjectLink("Source", GIT_URL + '/tree/' + GIT_BRANCH))
html_context["project_links"].append(ProjectLink("Source", brand.GIT_URL))
if brand.WIKI_URL: if WIKI_URL:
html_context["project_links"].append(ProjectLink("Wiki", brand.WIKI_URL)) html_context["project_links"].append(ProjectLink("Wiki", WIKI_URL))
if brand.PUBLIC_INSTANCES: if PUBLIC_INSTANCES:
html_context["project_links"].append(ProjectLink("Public instances", brand.PUBLIC_INSTANCES)) html_context["project_links"].append(ProjectLink("Public instances", PUBLIC_INSTANCES))
if brand.TWITTER_URL: if ISSUE_URL:
html_context["project_links"].append(ProjectLink("Twitter", brand.TWITTER_URL)) html_context["project_links"].append(ProjectLink("Issue Tracker", ISSUE_URL))
if brand.ISSUE_URL: if CONTACT_URL:
html_context["project_links"].append(ProjectLink("Issue Tracker", brand.ISSUE_URL)) html_context["project_links"].append(ProjectLink("Contact", CONTACT_URL))
if brand.CONTACT_URL:
html_context["project_links"].append(ProjectLink("Contact", brand.CONTACT_URL))
html_sidebars = { html_sidebars = {
"**": ["project.html", "relations.html", "searchbox.html"], "**": ["project.html", "relations.html", "searchbox.html"],

7
manage
View File

@ -177,6 +177,13 @@ docker.buildx() {
docker.build() { docker.build() {
pyenv.install 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 build_msg DOCKER build
# run installation in a subprocess and activate pyenv # run installation in a subprocess and activate pyenv

View File

@ -32,52 +32,24 @@ if max_request_timeout is None:
else: else:
logger.info('max_request_timeout=%i second(s)', max_request_timeout) 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=''): value = settings
return settings.get(group, {}).get(name) or default for a in name.split('.'):
if isinstance(value, dict):
value = value.get(a, _unset)
else:
value = _unset
@property if value is _unset:
def SEARX_URL(self): if default is _unset:
return self.get_val('server', 'base_url') raise KeyError(name)
value = default
break
@property return value
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()

View File

@ -130,6 +130,13 @@ SCHEMA = {
'contact_url': SettingsValue((None, False, str), None), 'contact_url': SettingsValue((None, False, str), None),
}, },
'brand': { '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': { 'search': {
'safe_search': SettingsValue((0,1,2), 0), 'safe_search': SettingsValue((0,1,2), 0),

View File

@ -2,6 +2,15 @@ general:
debug: false debug: false
instance_name: "searx_test" 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: search:
language: "all" language: "all"

View File

@ -11,7 +11,7 @@
<p>More about SearXNG ...</p> <p>More about SearXNG ...</p>
<ul> <ul>
<li><a href="{{ brand.GIT_URL }}">github</a></li> <li><a href="{{ get_setting('brand.git_url') }}">SearXNG sources</a></li>
<li><a href="https://www.transifex.com/projects/p/searx/">transifex</a></li> <li><a href="https://www.transifex.com/projects/p/searx/">transifex</a></li>
</ul> </ul>
@ -30,7 +30,8 @@
</li> </li>
<li> <li>
SearXNG is free software, the code is 100% open and you can help to make SearXNG is free software, the code is 100% open and you can help to make
it better. See more on <a href="{{ brand.GIT_URL }}">github</a>. it better. See more on <a href="{{ get_setting('brand.git_url')
}}">SearXNG sources</a>.
</li> </li>
</ul> </ul>
@ -80,10 +81,11 @@
<p> <p>
SearXNG appreciates your concern regarding logs, so take the code from SearXNG appreciates your concern regarding logs, so take the code from
the <a href="{{ brand.GIT_URL }}">SearXNG project</a> and run it yourself! the <a href="{{ get_setting('brand.git_url') }}">SearXNG project</a> and
run it yourself!
</p> </p>
<p> <p>
Add your instance to this <a href="{{ brand.PUBLIC_INSTANCES }}"> list of Add your instance to this <a href="{{ get_setting('brand.public_instances') }}"> list of
public instances</a> to help other people reclaim their privacy and make the public instances</a> to help other people reclaim their privacy and make the
Internet freer! The more decentralized the Internet is, the more freedom we Internet freer! The more decentralized the Internet is, the more freedom we
have! have!
@ -92,8 +94,8 @@
<h2>Where are the docs & code of this instance?</h2> <h2>Where are the docs & code of this instance?</h2>
<p> <p>
See the <a href="{{ brand.DOCS_URL }}">{{ brand.DOCS_URL }}</a> See the <a href="{{ get_setting('brand.docs_url') }}">SearXNG docs</a>
and <a href="{{ brand.GIT_URL }}">{{ brand.GIT_URL }}</a> and <a href="{{ get_setting('brand.git_url') }}">SearXNG sources</a>
</p> </p>
</div> </div>

View File

@ -1,5 +1,5 @@
{% macro new_issue(new_issue_url, engine_name, engine_reliability) %} {% macro new_issue(engine_name, engine_reliability) %}
<form action="{{ new_issue_url }}" method="GET"> <form action="{{ get_setting('brand.new_issue_url') }}" method="GET">
<input name="title" type="hidden" value="Bug: {{ engine_name }} engine"> <input name="title" type="hidden" value="Bug: {{ engine_name }} engine">
<input name="labels" type="hidden" value="bug"> <input name="labels" type="hidden" value="bug">
<input name="template" type="hidden" value="bug-report.md"> <input name="template" type="hidden" value="bug-report.md">
@ -52,6 +52,6 @@ or manually by executing the searx/webapp.py file? -->
{{-'\n '}}* {{ test_name }}: {% for result in results%}`{{ result }}`,{% endfor -%} {{-'\n '}}* {{ test_name }}: {% for result in results%}`{{ result }}`,{% endfor -%}
{%- endfor -%} {%- endfor -%}
</textarea> </textarea>
<button type="submit" class="github-issue-button" title="{{ new_issue_url }}">{{ _('Submit a new issue on Github including the above information') }}</button> <button type="submit" class="github-issue-button" title="{{ get_setting('brand.new_issue_url') }}">{{ _('Submit a new issue on Github including the above information') }}</button>
</form> </form>
{% endmacro %} {% endmacro %}

View File

@ -82,11 +82,11 @@
{% endblock %} {% endblock %}
<p class="text-muted"> <p class="text-muted">
<small> <small>
{{ _('Powered by') }} <a href="{{ brand.DOCS_URL }}">searxng</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/> {{ _('Powered by') }} <a href="{{ get_setting('brand.docs_url') }}">SearXNG</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
<a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> | <a href="{{ get_setting('brand.git_url') }}">{{ _('Source code') }}</a> |
<a href="{{ brand.ISSUE_URL }}">{{ _('Issue tracker') }}</a> | <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a> |
<a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>{% if brand.CONTACT_URL %} | <a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>{% if get_setting('general.contact_url') %} |
<a href="{{ brand.CONTACT_URL }}">{{ _('Contact instance maintainer') }}</a>{% endif %} <a href="{{ get_setting('general.contact_url') }}">{{ _('Contact instance maintainer') }}</a>{% endif %}
</small> </small>
</p> </p>
</div> </div>

View File

@ -10,7 +10,7 @@
</a> ){{- '' -}} </a> ){{- '' -}}
</p> </p>
{%- endfor -%} {%- endfor -%}
<p><small>{{ _('Please, try again later or find another searx instance.') }} (<a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>)</small></p> <p><small>{{ _('Please, try again later or find another searx instance.') }} (<a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>)</small></p>
</div> </div>
{% else %} {% else %}
<div class="alert alert-info fade in" role="alert"> <div class="alert alert-info fade in" role="alert">

View File

@ -1,5 +1,5 @@
{% extends 'oscar/base.html' %} {% extends 'oscar/base.html' %}
{% from '__common__/new_issue.html' import new_issue %} {% from '__common__/new_issue.html' import new_issue with context %}
{% block title %}{{ _('stats') }} - {% if selected_engine_name %} {{ selected_engine_name }} - {% endif %}{% endblock %} {% block title %}{{ _('stats') }} - {% if selected_engine_name %} {{ selected_engine_name }} - {% endif %}{% endblock %}
@ -148,7 +148,7 @@
{% endfor %} {% endfor %}
</table> </table>
{% endif %} {% endif %}
{{ new_issue(brand.NEW_ISSUE_URL, selected_engine_name, engine_reliabilities[selected_engine_name]) }} {{ new_issue(selected_engine_name, engine_reliabilities[selected_engine_name]) }}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@ -51,10 +51,10 @@
<footer> <footer>
<p> <p>
{{ _('Powered by') }} <a href="{{ url_for('about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, hackable metasearch engine') }}<br/> {{ _('Powered by') }} <a href="{{ url_for('about') }}">searxng</a> - {{ searx_version }} — {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
<a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> | <a href="{{ get_setting('brand.git_url') }}">{{ _('Source code') }}</a> |
<a href="{{ brand.ISSUE_URL }}">{{ _('Issue tracker') }}</a> | <a href="{{ get_setting('brand.issue_url') }}">{{ _('Issue tracker') }}</a> |
<a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>{% if brand.CONTACT_URL %} | <a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>{% if get_setting('general.contact_url') %} |
<a href="{{ brand.CONTACT_URL }}">{{ _('Contact instance maintainer') }}</a>{% endif %} <a href="{{ get_setting('general.contact_url') }}">{{ _('Contact instance maintainer') }}</a>{% endif %}
</p> </p>
</footer> </footer>
<!--[if gte IE 9]>--> <!--[if gte IE 9]>-->

View File

@ -11,7 +11,7 @@
</p> </p>
{%- endfor %} {%- endfor %}
<p><small>{{ _('Please, try again later or find another searx instance.') }} (<a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>) </small></p> <p><small>{{ _('Please, try again later or find another searx instance.') }} (<a href="{{ get_setting('brand.public_instances') }}">{{ _('Public instances') }}</a>) </small></p>
</div> </div>
{% else %} {% else %}
<div class="dialog-error" role="alert"> <div class="dialog-error" role="alert">

View File

@ -1,5 +1,5 @@
{% from 'simple/macros.html' import icon %} {% from 'simple/macros.html' import icon %}
{% from '__common__/new_issue.html' import new_issue %} {% from '__common__/new_issue.html' import new_issue with context %}
{% extends "simple/base.html" %} {% extends "simple/base.html" %}
@ -147,7 +147,7 @@
{% endfor %} {% endfor %}
</table> </table>
{% endif %} {% endif %}
{{ new_issue(brand.NEW_ISSUE_URL, selected_engine_name, engine_reliabilities[selected_engine_name]) }} {{ new_issue(selected_engine_name, engine_reliabilities[selected_engine_name]) }}
{% endif %} {% endif %}
</div> </div>

View File

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

View File

@ -8,7 +8,7 @@ import os
import sys import sys
from searx.version import VERSION_STRING from searx.version import VERSION_STRING
from searx import brand from searx import get_setting
with open('README.rst', encoding='utf-8') as f: with open('README.rst', encoding='utf-8') as f:
long_description = f.read() long_description = f.read()
@ -24,10 +24,10 @@ setup(
version=VERSION_STRING, version=VERSION_STRING,
description="A privacy-respecting, hackable metasearch engine", description="A privacy-respecting, hackable metasearch engine",
long_description=long_description, long_description=long_description,
url=brand.DOCS_URL, url=get_setting('brand.docs_url'),
project_urls={ project_urls={
"Code": brand.GIT_URL, "Code": get_setting('brand.git_url'),
"Issue tracker": brand.ISSUE_URL "Issue tracker": get_setting('brand.issue_url')
}, },
classifiers=[ classifiers=[
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",

View File

@ -6,4 +6,3 @@ export DOCS_URL='https://searxng.github.io/searxng'
export PUBLIC_INSTANCES='https://searx.space' export PUBLIC_INSTANCES='https://searx.space'
export CONTACT_URL='' export CONTACT_URL=''
export WIKI_URL='https://github.com/searxng/searxng/wiki' export WIKI_URL='https://github.com/searxng/searxng/wiki'
export TWITTER_URL=''

View File

@ -16,18 +16,25 @@ os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + '/settings.yml')
# from /etc/searx/settings.yml. # from /etc/searx/settings.yml.
os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml') os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
from searx import brand from searx import get_setting
def _env(*arg, **kwargs):
val = get_setting(*arg, **kwargs)
if val is True:
val = '1'
elif val is False:
val = ''
return val
name_val = [ name_val = [
('SEARX_URL' , brand.SEARX_URL), ('SEARX_URL' , _env('server.base_url','')),
('GIT_URL' , brand.GIT_URL), ('GIT_URL' , _env('brand.git_url', '')),
('GIT_BRANCH' , brand.GIT_BRANCH), ('GIT_BRANCH' , _env('brand.git_branch', '')),
('ISSUE_URL' , brand.ISSUE_URL), ('ISSUE_URL' , _env('brand.issue_url', '')),
('DOCS_URL' , brand.DOCS_URL), ('DOCS_URL' , _env('brand.docs_url', '')),
('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES), ('PUBLIC_INSTANCES' , _env('brand.public_instances', '')),
('CONTACT_URL' , brand.CONTACT_URL), ('CONTACT_URL' , _env('general.contact_url', '')),
('WIKI_URL' , brand.WIKI_URL), ('WIKI_URL' , _env('brand.wiki_url', '')),
('TWITTER_URL' , brand.TWITTER_URL),
] ]
brand_env = 'utils' + sep + 'brand.env' brand_env = 'utils' + sep + 'brand.env'

View File

@ -606,9 +606,13 @@ pyenv.OK() {
return 1 return 1
fi fi
pyenv.check \ if [ "$VERBOSE" = "1" ]; then
| "${PY_ENV_BIN}/python" 2>&1 \ pyenv.check \
| prefix_stdout "${_Blue}PYENV ${_creset}[check] " | "${PY_ENV_BIN}/python" 2>&1 \
| prefix_stdout "${_Blue}PYENV ${_creset}[check] "
else
pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null
fi
local err=${PIPESTATUS[1]} local err=${PIPESTATUS[1]}
if [ "$err" -ne "0" ]; then if [ "$err" -ne "0" ]; then
@ -616,7 +620,7 @@ pyenv.OK() {
return "$err" return "$err"
fi fi
build_msg PYENV "OK" [ "$VERBOSE" = "1" ] && build_msg PYENV "OK"
_pyenv_OK="OK" _pyenv_OK="OK"
return 0 return 0
} }

View File

@ -25,7 +25,7 @@ server:
secret_key: "ultrasecretkey" # change this! secret_key: "ultrasecretkey" # change this!
# Set custom base_url. Possible values: # Set custom base_url. Possible values:
# false or "https://your.custom.host/location/" # false or "https://your.custom.host/location/"
base_url: https://darmarit.org/searx # base_url: https://example.org/searx
# Proxying image results through searx # Proxying image results through searx
image_proxy: false image_proxy: false