on master help sign in
Merge pull request #2408 from return42/rm-brand-make
9c55d77Alexandre Flament
Makefile+2−32
@@ -1,14 +1,6 @@
1# -*- coding: utf-8; mode: makefile-gmake -*-
1# -*- coding: utf-8; mode: makefile-gmake -*-
2.DEFAULT_GOAL=help
2.DEFAULT_GOAL=help
3
3
4−# START Makefile setup
5−export GIT_URL=https://github.com/searx/searx
6−export GIT_BRANCH=master
7−export SEARX_URL=https://searx.me
8−export DOCS_URL=https://searx.github.io/searx
9−# export CONTACT_URL=mailto:contact@example.com
10−# END Makefile setup
11−
12include utils/makefile.include
4include utils/makefile.include
13
5
14PYOBJECTS = searx
6PYOBJECTS = searx
@@ -43,12 +35,6 @@ help-min:
43 @echo ' docker - build Docker image'
35 @echo ' docker - build Docker image'
44 @echo ' node.env - download & install npm dependencies locally'
36 @echo ' node.env - download & install npm dependencies locally'
45 @echo ''
37 @echo ''
46− @echo 'environment'
47− @echo ' SEARX_URL = $(SEARX_URL)'
48− @echo ' GIT_URL = $(GIT_URL)'
49− @echo ' DOCS_URL = $(DOCS_URL)'
50− @echo ' CONTACT_URL = $(CONTACT_URL)'
51− @echo ''
52 @$(MAKE) -e -s make-help
38 @$(MAKE) -e -s make-help
53
39
54help-all: help-min
40help-all: help-min
@@ -118,24 +104,8 @@ useragents.update: pyenvinstall
118 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
104 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
119 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
105 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
120
106
121−buildenv:
107+buildenv: pyenv
122− $(Q)echo "build searx/brand.py"
108+ $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
123− $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
124− $(Q)echo "GIT_BRANCH = '$(GIT_BRANCH)'" >> searx/brand.py
125− $(Q)echo "ISSUE_URL = 'https://github.com/searx/searx/issues'" >> searx/brand.py
126− $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
127− $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
128− $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
129− $(Q)echo "CONTACT_URL = '$(CONTACT_URL)'" >> searx/brand.py
130− $(Q)echo "build utils/brand.env"
131− $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
132− $(Q)echo "export GIT_BRANCH='$(GIT_BRANCH)'" >> utils/brand.env
133− $(Q)echo "export ISSUE_URL='https://github.com/searx/searx/issues'" >> utils/brand.env
134− $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
135− $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
136− $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
137− $(Q)echo "export CONTACT_URL='$(CONTACT_URL)'" >> utils/brand.env
138−
139
109
140# node / npm
110# node / npm
141# ----------
111# ----------
docs/admin/installation-searx.rst+10−3
@@ -70,13 +70,20 @@ from the login (*~/.profile*):
70Configuration
70Configuration
71=============
71=============
72
72
73+.. sidebar:: ``use_default_settings: True``
74+
75+ - :ref:`settings global`
76+ - :ref:`settings location`
77+ - :ref:`settings use_default_settings`
78+ - :origin:`/etc/searx/settings.yml <utils/templates/etc/searx/use_default_settings.yml>`
79+
73To create a initial ``/etc/searx/settings.yml`` you can start with a copy of the
80To create a initial ``/etc/searx/settings.yml`` you can start with a copy of the
74file :origin:`utils/templates/etc/searx/use_default_settings.yml`. This setup
81file :origin:`utils/templates/etc/searx/use_default_settings.yml`. This setup
75−:option:ref:`use default settings <settings use_default_settings>` from
82+:ref:`use default settings <settings use_default_settings>` from
76:origin:`searx/settings.yml` and is recommended since :pull:`2291` is merged.
83:origin:`searx/settings.yml` and is recommended since :pull:`2291` is merged.
77
84
78−For minimal Setup, configure like shown below – replace ``searx@\$(uname -n)``
85+For a *minimal setup*, configure like shown below – replace ``searx@$(uname
79−with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
86+-n)`` with a name of your choice, set ``ultrasecretkey`` -- *and/or* edit
80``/etc/searx/settings.yml`` to your needs.
87``/etc/searx/settings.yml`` to your needs.
81
88
82.. kernel-include:: $DOCS_BUILD/includes/searx.rst
89.. kernel-include:: $DOCS_BUILD/includes/searx.rst
docs/admin/installation.rst+1−1
@@ -76,6 +76,6 @@ If all services are running fine, you can add it to your HTTP server:
76.. tip::
76.. tip::
77
77
78 About script's installation options have a look at chapter :ref:`toolboxing
78 About script's installation options have a look at chapter :ref:`toolboxing
79− setup`. How to brand your instance see chapter :ref:`makefile setup`. To
79+ setup`. How to brand your instance see chapter :ref:`settings global`. To
80 *stash* your instance's setup, `git stash`_ your clone's :origin:`Makefile`
80 *stash* your instance's setup, `git stash`_ your clone's :origin:`Makefile`
81 and :origin:`.config.sh` file .
81 and :origin:`.config.sh` file .
docs/admin/settings.rst+110−58
@@ -27,7 +27,8 @@ First, searx will try to load settings.yml from these locations:
271. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
271. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable.
282. ``/etc/searx/settings.yml``
282. ``/etc/searx/settings.yml``
29
29
30−If these files don't exist (or are empty or can't be read), searx uses the :origin:`searx/settings.yml` file.
30+If these files don't exist (or are empty or can't be read), searx uses the
31+:origin:`searx/settings.yml` file.
31
32
32
33
33.. _settings global:
34.. _settings global:
@@ -35,16 +36,46 @@ If these files don't exist (or are empty or can't be read), searx uses the :orig
35Global Settings
36Global Settings
36===============
37===============
37
38
39+``general:``
40+------------
41+
38.. code:: yaml
42.. code:: yaml
39
43
40 general:
44 general:
41 debug : False # Debug mode, only for development
45 debug : False # Debug mode, only for development
42 instance_name : "searx" # displayed name
46 instance_name : "searx" # displayed name
47+ git_url: https://github.com/searx/searx
48+ git_branch: master
49+ issue_url: https://github.com/searx/searx/issues
50+ docs_url: https://searx.github.io/searx
51+ public_instances: https://searx.space
52+ contact_url: False # mailto:contact@example.com
53+ wiki_url: https://github.com/searx/searx/wiki
54+ twitter_url: https://twitter.com/Searx_engine
43
55
44``debug`` :
56``debug`` :
45 Allow a more detailed log if you run searx directly. Display *detailed* error
57 Allow a more detailed log if you run searx directly. Display *detailed* error
46 messages in the browser too, so this must be deactivated in production.
58 messages in the browser too, so this must be deactivated in production.
47
59
60+``contact_url``:
61+ Contact ``mailto:`` address or WEB form.
62+
63+``git_url`` and ``git_branch``:
64+ Changes this, to point to your searx fork (branch).
65+
66+``docs_url``
67+ If you host your own documentation, change this URL.
68+
69+``wiki_url``:
70+ Link to your wiki (or ``False``)
71+
72+``twitter_url``:
73+ Link to your tweets (or ``False``)
74+
75+
76+``server:``
77+-----------
78+
48.. code:: yaml
79.. code:: yaml
49
80
50 server:
81 server:
@@ -90,6 +121,8 @@ Global Settings
90``default_http_headers``:
121``default_http_headers``:
91 Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
122 Set additional HTTP headers, see `#755 <https://github.com/searx/searx/issues/715>`__
92
123
124+``outgoing:``
125+-------------
93
126
94.. code:: yaml
127.. code:: yaml
95
128
@@ -139,6 +172,10 @@ Global Settings
139 If you use multiple network interfaces, define from which IP the requests must
172 If you use multiple network interfaces, define from which IP the requests must
140 be made. This parameter is ignored when ``proxies`` is set.
173 be made. This parameter is ignored when ``proxies`` is set.
141
174
175+
176+``locales:``
177+------------
178+
142.. code:: yaml
179.. code:: yaml
143
180
144 locales:
181 locales:
@@ -244,61 +281,76 @@ Engine settings
244use_default_settings
281use_default_settings
245====================
282====================
246
283
247−.. note::
284+.. sidebar:: ``use_default_settings: True``
248−
249− If searx is cloned from a git repository, most probably there is no need to have an user settings.
250−
251−The user defined settings.yml can relied on the default configuration :origin:`searx/settings.yml` using ``use_default_settings: True``.
252
285
286+ - :ref:`settings location`
287+ - :ref:`use_default_settings.yml`
288+ - :origin:`/etc/searx/settings.yml <utils/templates/etc/searx/use_default_settings.yml>`
289+
290+The user defined ``settings.yml`` is loaded from the :ref:`settings location`
291+and can relied on the default configuration :origin:`searx/settings.yml` using:
292+
293+ ``use_default_settings: True``
294+
295+``server:``
253−In the following example, the actual settings are the default settings defined in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and the ``bind_address``:
296+ In the following example, the actual settings are the default settings defined
254−
297+ in :origin:`searx/settings.yml` with the exception of the ``secret_key`` and
298+ the ``bind_address``:
299+
255−.. code-block:: yaml
300+ .. code-block:: yaml
256−
301+
257− use_default_settings: True
302+ use_default_settings: True
258− server:
303+ server:
259− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
304+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
260− bind_address: "0.0.0.0"
305+ bind_address: "0.0.0.0"
261−
306+
307+``engines:``
262−With ``use_default_settings: True``, each settings can be override in a similar way, the ``engines`` section is merged according to the engine ``name``.
308+ With ``use_default_settings: True``, each settings can be override in a
263−
309+ similar way, the ``engines`` section is merged according to the engine
264−In this example, searx will load all the engine and the arch linux wiki engine has a :ref:`token<private engines>`:
310+ ``name``. In this example, searx will load all the engine and the arch linux
265−
311+ wiki engine has a :ref:`token<private engines>`:
312+
266−.. code-block:: yaml
313+ .. code-block:: yaml
267−
314+
268− use_default_settings: True
315+ use_default_settings: True
269− server:
316+ server:
270− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
317+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
271− engines:
318+ engines:
272− - name: arch linux wiki
319+ - name: arch linux wiki
273− tokens: ['$ecretValue']
320+ tokens: ['$ecretValue']
274−
321+
322+``engines:`` / ``remove:``
275−It is possible to remove some engines from the default settings. The following example is similar to the above one, but searx doesn't load the the google engine:
323+ It is possible to remove some engines from the default settings. The following
276−
324+ example is similar to the above one, but searx doesn't load the the google
325+ engine:
326+
277−.. code-block:: yaml
327+ .. code-block:: yaml
278−
328+
279− use_default_settings:
329+ use_default_settings:
280− engines:
330+ engines:
281− remove:
331+ remove:
282− - google
332+ - google
283− server:
333+ server:
284− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
334+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
285− engines:
335+ engines:
286− - name: arch linux wiki
336+ - name: arch linux wiki
287− tokens: ['$ecretValue']
337+ tokens: ['$ecretValue']
288−
338+
339+``engines:`` / ``keep_only:``
289−As an alternative, it is possible to specify the engines to keep. In the following example, searx has only two engines:
340+ As an alternative, it is possible to specify the engines to keep. In the
290−
341+ following example, searx has only two engines:
342+
291−.. code-block:: yaml
343+ .. code-block:: yaml
292−
344+
293− use_default_settings:
345+ use_default_settings:
294− engines:
346+ engines:
295− keep_only:
347+ keep_only:
296− - google
348+ - google
297− - duckduckgo
349+ - duckduckgo
298− server:
350+ server:
299− secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
351+ secret_key: "uvys6bRhKHUdFF5CqbJonSDSRN8H0sCBziNSrDGNVdpz7IeZhveVart3yvghoKHA"
300− engines:
352+ engines:
301− - name: google
353+ - name: google
302− tokens: ['$ecretValue']
354+ tokens: ['$ecretValue']
303− - name: duckduckgo
355+ - name: duckduckgo
304− tokens: ['$ecretValue']
356+ tokens: ['$ecretValue']
docs/blog/lxcdev-202006.rst+2−2
@@ -259,8 +259,8 @@ suite. For this, we have to keep an eye on the :ref:`installation basic`:
259- virtualenv in: ``/usr/local/searx/searx-pyenv``
259- virtualenv in: ``/usr/local/searx/searx-pyenv``
260- searx software in: ``/usr/local/searx/searx-src``
260- searx software in: ``/usr/local/searx/searx-src``
261
261
262−The searx software is a clone of the ``GIT_URL`` (see :ref:`makefile setup`) and
262+The searx software is a clone of the ``git_url`` (see :ref:`settings global`) and
263−the working tree is checked out from the ``GIT_BRANCH``. With the use of the
263+the working tree is checked out from the ``git_branch``. With the use of the
264:ref:`searx.sh` the searx service was installed as :ref:`uWSGI application
264:ref:`searx.sh` the searx service was installed as :ref:`uWSGI application
265<searx uwsgi>`. To maintain this service, we can use ``systemctl`` (compare
265<searx uwsgi>`. To maintain this service, we can use ``systemctl`` (compare
266:ref:`service architectures on distributions <uwsgi configuration>`).
266:ref:`service architectures on distributions <uwsgi configuration>`).
docs/conf.py+20−18
@@ -2,14 +2,10 @@
2
2
3import sys, os
3import sys, os
4from sphinx_build_tools import load_sphinx_config
4from sphinx_build_tools import load_sphinx_config
5−from searx.version import VERSION_STRING
6from pallets_sphinx_themes import ProjectLink
5from pallets_sphinx_themes import ProjectLink
7
6
8−from searx.brand import GIT_URL
7+from searx import brand
9−GIT_BRANCH = os.environ.get("GIT_BRANCH", "master")
10−from searx.brand import SEARX_URL
11−from searx.brand import DOCS_URL
8+from searx.version import VERSION_STRING
12−
13
9
14# Project --------------------------------------------------------------
10# Project --------------------------------------------------------------
15
11
@@ -46,10 +42,10 @@ extlinks['wiki'] = ('https://github.com/searx/searx/wiki/%s', ' ')
46extlinks['pull'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
42extlinks['pull'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
47
43
48# links to custom brand
44# links to custom brand
49−extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
45+extlinks['origin'] = (brand.GIT_URL + '/blob/' + brand.GIT_BRANCH + '/%s', 'git://')
50−extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
46+extlinks['patch'] = (brand.GIT_URL + '/commit/%s', '#')
51−extlinks['search'] = (SEARX_URL + '/%s', '#')
47+extlinks['search'] = (brand.SEARX_URL + '/%s', '#')
52−extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
48+extlinks['docs'] = (brand.DOCS_URL + '/%s', 'docs: ')
53extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
49extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
54extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
50extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
55#extlinks['role'] = (
51#extlinks['role'] = (
@@ -104,14 +100,20 @@ imgmath_font_size = 14
104# sphinx.ext.imgmath setup END
100# sphinx.ext.imgmath setup END
105
101
106html_theme_options = {"index_sidebar_logo": True}
102html_theme_options = {"index_sidebar_logo": True}
107−html_context = {
108− "project_links": [
103+html_context = {"project_links": [] }
104+if brand.GIT_URL:
109− ProjectLink("Source", GIT_URL),
105+ html_context["project_links"].append(ProjectLink("Source", brand.GIT_URL))
110− ProjectLink("Wiki", "https://github.com/searx/searx/wiki"),
106+if brand.WIKI_URL:
107+ html_context["project_links"].append(ProjectLink("Wiki", brand.WIKI_URL))
108+if brand.PUBLIC_INSTANCES:
111− ProjectLink("Public instances", "https://searx.space/"),
109+ html_context["project_links"].append(ProjectLink("Public instances", brand.PUBLIC_INSTANCES))
112− ProjectLink("Twitter", "https://twitter.com/Searx_engine"),
110+if brand.TWITTER_URL:
113− ]
111+ html_context["project_links"].append(ProjectLink("Twitter", brand.TWITTER_URL))
114−}
112+if brand.ISSUE_URL:
113+ html_context["project_links"].append(ProjectLink("Issue Tracker", brand.ISSUE_URL))
114+if brand.CONTACT_URL:
115+ html_context["project_links"].append(ProjectLink("Contact", brand.CONTACT_URL))
116+
115html_sidebars = {
117html_sidebars = {
116 "**": ["project.html", "relations.html", "searchbox.html"],
118 "**": ["project.html", "relations.html", "searchbox.html"],
117}
119}
docs/dev/makefile.rst+4−36
@@ -8,8 +8,7 @@ Makefile Targets
8
8
9.. sidebar:: build environment
9.. sidebar:: build environment
10
10
11− Before looking deeper at the targets, first read about :ref:`makefile setup`
11+ Before looking deeper at the targets, first read about :ref:`make pyenv`.
12− and :ref:`make pyenv`.
13
12
14 To install system requirements follow :ref:`buildhosts`.
13 To install system requirements follow :ref:`buildhosts`.
15
14
@@ -28,37 +27,6 @@ Calling the ``help`` target gives a first overview (``make help``):
28 :local:
27 :local:
29 :backlinks: entry
28 :backlinks: entry
30
29
31−
32−.. _makefile setup:
33−
34−Makefile setup
35−==============
36−
37−.. _git stash: https://git-scm.com/docs/git-stash
38−
39−.. sidebar:: fork & upstream
40−
41− Commit changes in your (local) branch, fork or whatever, but do not push them
42− upstream / `git stash`_ is your friend.
43−
44−The main setup is done in the :origin:`Makefile`.
45−
46−.. literalinclude:: ../../Makefile
47− :start-after: START Makefile setup
48− :end-before: END Makefile setup
49−
50−:GIT_URL: Changes this, to point to your searx fork.
51−:GIT_BRANCH: Changes this, to point to your searx branch.
52−:SEARX_URL: Changes this, to point to your searx instance.
53−:DOCS_URL: If you host your own (*brand*) documentation, change this URL.
54−
55−If you change any of this build environment variables, you have to run ``make
56−buildenv``::
57−
58− $ make buildenv
59− build searx/brand.py
60− build utils/brand.env
61−
62.. _make pyenv:
30.. _make pyenv:
63
31
64Python environment
32Python environment
@@ -148,7 +116,7 @@ clean`` stop all processes using :ref:`make pyenv`.
148We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
116We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
149Documentation <contrib docs>` section. If you want to edit the documentation
117Documentation <contrib docs>` section. If you want to edit the documentation
150read our :ref:`make docs-live` section. If you are working in your own brand,
118read our :ref:`make docs-live` section. If you are working in your own brand,
151−adjust your :ref:`Makefile setup <makefile setup>`.
119+adjust your :ref:`settings global`.
152
120
153.. _make books:
121.. _make books:
154
122
@@ -185,8 +153,8 @@ Use ``make docs-help`` to see which books available:
185``make gh-pages``
153``make gh-pages``
186=================
154=================
187
155
188−To deploy on github.io first adjust your :ref:`Makefile setup <makefile
156+To deploy on github.io first adjust your :ref:`settings global`. For any
189−setup>`. For any further read :ref:`deploy on github.io`.
157+further read :ref:`deploy on github.io`.
190
158
191.. _make test:
159.. _make test:
192
160
docs/utils/index.rst+2−2
@@ -47,8 +47,8 @@ Scripts to maintain services often dispose of common commands and environments.
47Tooling box setup
47Tooling box setup
48=================
48=================
49
49
50−The main setup is done in the :origin:`.config.sh` (read also :ref:`makefile
50+The main setup is done in the :origin:`.config.sh` (read also :ref:`settings
51−setup`).
51+global`).
52
52
53.. literalinclude:: ../../.config.sh
53.. literalinclude:: ../../.config.sh
54 :language: bash
54 :language: bash
manage.sh+2−2
@@ -123,9 +123,9 @@ docker_build() {
123 SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
123 SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); } print}')
124
124
125 # add the suffix "-dirty" if the repository has uncommited change
125 # add the suffix "-dirty" if the repository has uncommited change
126− # /!\ HACK for searx/searx: ignore searx/brand.py and utils/brand.env
126+ # /!\ HACK for searx/searx: ignore utils/brand.env
127 git update-index -q --refresh
127 git update-index -q --refresh
128− if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'searx/brand.py' | grep -v 'utils/brand.env')" ]; then
128+ if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
129 SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
129 SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
130 fi
130 fi
131
131
searx/__init__.py+46
@@ -60,3 +60,49 @@ if 'SEARX_SECRET' in environ:
60 settings['server']['secret_key'] = environ['SEARX_SECRET']
60 settings['server']['secret_key'] = environ['SEARX_SECRET']
61if 'SEARX_BIND_ADDRESS' in environ:
61if 'SEARX_BIND_ADDRESS' in environ:
62 settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
62 settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
63+
64+
65+class _brand_namespace:
66+
67+ @classmethod
68+ def get_val(cls, group, name, default=''):
69+ return settings.get(group, {}).get(name) or default
70+
71+ @property
72+ def SEARX_URL(self):
73+ return self.get_val('server', 'base_url')
74+
75+ @property
76+ def CONTACT_URL(self):
77+ return self.get_val('general', 'contact_url')
78+
79+ @property
80+ def GIT_URL(self):
81+ return self.get_val('brand', 'git_url')
82+
83+ @property
84+ def GIT_BRANCH(self):
85+ return self.get_val('brand', 'git_branch')
86+
87+ @property
88+ def ISSUE_URL(self):
89+ return self.get_val('brand', 'issue_url')
90+
91+ @property
92+ def DOCS_URL(self):
93+ return self.get_val('brand', 'docs_url')
94+
95+ @property
96+ def PUBLIC_INSTANCES(self):
97+ return self.get_val('brand', 'public_instances')
98+
99+ @property
100+ def WIKI_URL(self):
101+ return self.get_val('brand', 'wiki_url')
102+
103+ @property
104+ def TWITTER_URL(self):
105+ return self.get_val('brand', 'twitter_url')
106+
107+
108+brand = _brand_namespace()
searx/brand.pydeleted−7
@@ -1,7 +0,0 @@
1−GIT_URL = 'https://github.com/searx/searx'
2−GIT_BRANCH = 'master'
3−ISSUE_URL = 'https://github.com/searx/searx/issues'
4−SEARX_URL = 'https://searx.me'
5−DOCS_URL = 'https://searx.github.io/searx'
6−PUBLIC_INSTANCES = 'https://searx.space'
7−CONTACT_URL = ''
searx/settings.yml+10
@@ -1,6 +1,16 @@
1general:
1general:
2 debug : False # Debug mode, only for development
2 debug : False # Debug mode, only for development
3 instance_name : "searx" # displayed name
3 instance_name : "searx" # displayed name
4+ contact_url: False # mailto:contact@example.com
5+
6+brand:
7+ git_url: https://github.com/searx/searx
8+ git_branch: master
9+ issue_url: https://github.com/searx/searx/issues
10+ docs_url: https://searx.github.io/searx
11+ public_instances: https://searx.space
12+ wiki_url: https://github.com/searx/searx/wiki
13+ twitter_url: https://twitter.com/Searx_engine
4
14
5search:
15search:
6 safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
16 safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
searx/webapp.py+1
@@ -1071,6 +1071,7 @@ def config():
1071 'default_theme': settings['ui']['default_theme'],
1071 'default_theme': settings['ui']['default_theme'],
1072 'version': VERSION_STRING,
1072 'version': VERSION_STRING,
1073 'brand': {
1073 'brand': {
1074+ 'CONTACT_URL': brand.CONTACT_URL,
1074 'GIT_URL': brand.GIT_URL,
1075 'GIT_URL': brand.GIT_URL,
1075 'DOCS_URL': brand.DOCS_URL
1076 'DOCS_URL': brand.DOCS_URL
1076 },
1077 },
setup.py+2−4
@@ -7,10 +7,8 @@ from setuptools import find_packages
7import os
7import os
8import sys
8import sys
9
9
10−# required to load VERSION_STRING constant
11−sys.path.insert(0, './searx')
12−from version import VERSION_STRING
10+from searx.version import VERSION_STRING
13−import brand
11+from searx import brand
14
12
15with open('README.rst', encoding='utf-8') as f:
13with open('README.rst', encoding='utf-8') as f:
16 long_description = f.read()
14 long_description = f.read()
utils/brand.env+3−1
@@ -1,7 +1,9 @@
1+export SEARX_URL=''
1export GIT_URL='https://github.com/searx/searx'
2export GIT_URL='https://github.com/searx/searx'
2export GIT_BRANCH='master'
3export GIT_BRANCH='master'
3export ISSUE_URL='https://github.com/searx/searx/issues'
4export ISSUE_URL='https://github.com/searx/searx/issues'
4−export SEARX_URL='https://searx.me'
5export DOCS_URL='https://searx.github.io/searx'
5export DOCS_URL='https://searx.github.io/searx'
6export PUBLIC_INSTANCES='https://searx.space'
6export PUBLIC_INSTANCES='https://searx.space'
7export CONTACT_URL=''
7export CONTACT_URL=''
8+export WIKI_URL='https://github.com/searx/searx/wiki'
9+export TWITTER_URL='https://twitter.com/Searx_engine'
utils/build_env.pynew file+38
@@ -0,0 +1,38 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
2+"""build environment used by shell scripts
3+"""
4+
5+# set path
6+import sys
7+import os
8+from os.path import realpath, dirname, join, sep, abspath
9+
10+repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
11+sys.path.insert(0, repo_root)
12+os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + '/settings.yml')
13+
14+# Under the assumption that a brand is always a fork assure that the settings
15+# file from reposetorie's working tree is used to generate the build_env, not
16+# from /etc/searx/settings.yml.
17+os.environ['SEARX_SETTINGS_PATH'] = abspath(dirname(__file__) + sep + 'settings.yml')
18+
19+from searx import brand
20+
21+name_val = [
22+ ('SEARX_URL' , brand.SEARX_URL),
23+ ('GIT_URL' , brand.GIT_URL),
24+ ('GIT_BRANCH' , brand.GIT_BRANCH),
25+ ('ISSUE_URL' , brand.ISSUE_URL),
26+ ('DOCS_URL' , brand.DOCS_URL),
27+ ('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
28+ ('CONTACT_URL' , brand.CONTACT_URL),
29+ ('WIKI_URL' , brand.WIKI_URL),
30+ ('TWITTER_URL' , brand.TWITTER_URL),
31+]
32+
33+brand_env = 'utils' + sep + 'brand.env'
34+
35+print('build %s' % brand_env)
36+with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
37+ for name, val in name_val:
38+ print("export %s='%s'" % (name, val), file=f)