on master help sign in
[mod] move brand options from Makefile to settings.yml

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commit9485179064b4eb28f2813eba3c295edca3b0db7f authorMarkus Heiser <markus.heiser@darmarit.de> dateMon 21 Dec 2020, 00:37 (6 years ago) parentdbfd556
11 files changed+111−93
Makefile+2−32 docs/admin/installation.rst+1−1 docs/admin/settings.rst+24 docs/blog/lxcdev-202006.rst+2−2 docs/conf.py+20−18 docs/dev/makefile.rst+4−36 docs/utils/index.rst+2−2 searx/brand.py+3−1 searx/settings.yml+8 utils/brand.env+3−1 utils/build_env.py+42
Makefile+2−32
@@ -1,14 +1,6 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
22.DEFAULT_GOAL=help
33
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−
124include utils/makefile.include
135
146PYOBJECTS = searx
@@ -43,12 +35,6 @@ help-min:
4335 @echo ' docker - build Docker image'
4436 @echo ' node.env - download & install npm dependencies locally'
4537 @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 ''
5238 @$(MAKE) -e -s make-help
5339
5440help-all: help-min
@@ -118,24 +104,8 @@ useragents.update: pyenvinstall
118104 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
119105 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
120106
121−buildenv:
122− $(Q)echo "build searx/brand.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−
107+buildenv: pyenv
108+ $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
139109
140110# node / npm
141111# ----------
docs/admin/installation.rst+1−1
@@ -76,6 +76,6 @@ If all services are running fine, you can add it to your HTTP server:
7676.. tip::
7777
7878 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
8080 *stash* your instance's setup, `git stash`_ your clone's :origin:`Makefile`
8181 and :origin:`.config.sh` file .
docs/admin/settings.rst+24
@@ -40,11 +40,35 @@ Global Settings
4040 general:
4141 debug : False # Debug mode, only for development
4242 instance_name : "searx" # displayed name
43+ git_url: https://github.com/searx/searx
44+ git_branch: master
45+ issue_url: https://github.com/searx/searx/issues
46+ docs_url: https://searx.github.io/searx
47+ public_instances: https://searx.space
48+ contact_url: False # mailto:contact@example.com
49+ wiki_url: https://github.com/searx/searx/wiki
50+ twitter_url: https://twitter.com/Searx_engine
4351
4452``debug`` :
4553 Allow a more detailed log if you run searx directly. Display *detailed* error
4654 messages in the browser too, so this must be deactivated in production.
4755
56+``contact_url``:
57+ Contact mail address or WEB form.
58+
59+``git_url`` and ``git_branch``:
60+ Changes this, to point to your searx fork (branch).
61+
62+``docs_url``
63+ If you host your own documentation, change this URL.
64+
65+``wiki_url``:
66+ Link to your wiki (or ``False``)
67+
68+``twitter_url``:
69+ Link to your tweets (or ``False``)
70+
71+
4872.. code:: yaml
4973
5074 server:
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`:
259259- virtualenv in: ``/usr/local/searx/searx-pyenv``
260260- searx software in: ``/usr/local/searx/searx-src``
261261
262−The searx software is a clone of the ``GIT_URL`` (see :ref:`makefile setup`) and
263−the working tree is checked out from the ``GIT_BRANCH``. With the use of the
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
264264:ref:`searx.sh` the searx service was installed as :ref:`uWSGI application
265265<searx uwsgi>`. To maintain this service, we can use ``systemctl`` (compare
266266:ref:`service architectures on distributions <uwsgi configuration>`).
docs/conf.py+20−18
@@ -2,14 +2,10 @@
22
33import sys, os
44from sphinx_build_tools import load_sphinx_config
5−from searx.version import VERSION_STRING
65from pallets_sphinx_themes import ProjectLink
76
8−from searx.brand import GIT_URL
9−GIT_BRANCH = os.environ.get("GIT_BRANCH", "master")
10−from searx.brand import SEARX_URL
11−from searx.brand import DOCS_URL
12−
7+from searx import brand
8+from searx.version import VERSION_STRING
139
1410# Project --------------------------------------------------------------
1511
@@ -46,10 +42,10 @@ extlinks['wiki'] = ('https://github.com/searx/searx/wiki/%s', ' ')
4642extlinks['pull'] = ('https://github.com/searx/searx/pull/%s', 'PR ')
4743
4844# links to custom brand
49−extlinks['origin'] = (GIT_URL + '/blob/' + GIT_BRANCH + '/%s', 'git://')
50−extlinks['patch'] = (GIT_URL + '/commit/%s', '#')
51−extlinks['search'] = (SEARX_URL + '/%s', '#')
52−extlinks['docs'] = (DOCS_URL + '/%s', 'docs: ')
45+extlinks['origin'] = (brand.GIT_URL + '/blob/' + brand.GIT_BRANCH + '/%s', 'git://')
46+extlinks['patch'] = (brand.GIT_URL + '/commit/%s', '#')
47+extlinks['search'] = (brand.SEARX_URL + '/%s', '#')
48+extlinks['docs'] = (brand.DOCS_URL + '/%s', 'docs: ')
5349extlinks['pypi'] = ('https://pypi.org/project/%s', 'PyPi: ')
5450extlinks['man'] = ('https://manpages.debian.org/jump?q=%s', '')
5551#extlinks['role'] = (
@@ -104,14 +100,20 @@ imgmath_font_size = 14
104100# sphinx.ext.imgmath setup END
105101
106102html_theme_options = {"index_sidebar_logo": True}
107−html_context = {
108− "project_links": [
109− ProjectLink("Source", GIT_URL),
110− ProjectLink("Wiki", "https://github.com/searx/searx/wiki"),
111− ProjectLink("Public instances", "https://searx.space/"),
112− ProjectLink("Twitter", "https://twitter.com/Searx_engine"),
113− ]
114−}
103+html_context = {"project_links": [] }
104+if brand.GIT_URL:
105+ html_context["project_links"].append(ProjectLink("Source", brand.GIT_URL))
106+if brand.WIKI_URL:
107+ html_context["project_links"].append(ProjectLink("Wiki", brand.WIKI_URL))
108+if brand.PUBLIC_INSTANCES:
109+ html_context["project_links"].append(ProjectLink("Public instances", brand.PUBLIC_INSTANCES))
110+if brand.TWITTER_URL:
111+ html_context["project_links"].append(ProjectLink("Twitter", brand.TWITTER_URL))
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+
115117html_sidebars = {
116118 "**": ["project.html", "relations.html", "searchbox.html"],
117119}
docs/dev/makefile.rst+4−36
@@ -8,8 +8,7 @@ Makefile Targets
88
99.. sidebar:: build environment
1010
11− Before looking deeper at the targets, first read about :ref:`makefile setup`
12− and :ref:`make pyenv`.
11+ Before looking deeper at the targets, first read about :ref:`make pyenv`.
1312
1413 To install system requirements follow :ref:`buildhosts`.
1514
@@ -28,37 +27,6 @@ Calling the ``help`` target gives a first overview (``make help``):
2827 :local:
2928 :backlinks: entry
3029
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−
6230.. _make pyenv:
6331
6432Python environment
@@ -148,7 +116,7 @@ clean`` stop all processes using :ref:`make pyenv`.
148116We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
149117Documentation <contrib docs>` section. If you want to edit the documentation
150118read 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`.
152120
153121.. _make books:
154122
@@ -185,8 +153,8 @@ Use ``make docs-help`` to see which books available:
185153``make gh-pages``
186154=================
187155
188−To deploy on github.io first adjust your :ref:`Makefile setup <makefile
189−setup>`. For any further read :ref:`deploy on github.io`.
156+To deploy on github.io first adjust your :ref:`settings global`. For any
157+further read :ref:`deploy on github.io`.
190158
191159.. _make test:
192160
docs/utils/index.rst+2−2
@@ -47,8 +47,8 @@ Scripts to maintain services often dispose of common commands and environments.
4747Tooling box setup
4848=================
4949
50−The main setup is done in the :origin:`.config.sh` (read also :ref:`makefile
51−setup`).
50+The main setup is done in the :origin:`.config.sh` (read also :ref:`settings
51+global`).
5252
5353.. literalinclude:: ../../.config.sh
5454 :language: bash
searx/brand.py+3−1
@@ -1,7 +1,9 @@
1+SEARX_URL = ''
12GIT_URL = 'https://github.com/searx/searx'
23GIT_BRANCH = 'master'
34ISSUE_URL = 'https://github.com/searx/searx/issues'
4−SEARX_URL = 'https://searx.me'
55DOCS_URL = 'https://searx.github.io/searx'
66PUBLIC_INSTANCES = 'https://searx.space'
77CONTACT_URL = ''
8+WIKI_URL = 'https://github.com/searx/searx/wiki'
9+TWITTER_URL = 'https://twitter.com/Searx_engine'
searx/settings.yml+8
@@ -1,6 +1,14 @@
11general:
22 debug : False # Debug mode, only for development
33 instance_name : "searx" # displayed name
4+ git_url: https://github.com/searx/searx
5+ git_branch: master
6+ issue_url: https://github.com/searx/searx/issues
7+ docs_url: https://searx.github.io/searx
8+ public_instances: https://searx.space
9+ contact_url: False # mailto:contact@example.com
10+ wiki_url: https://github.com/searx/searx/wiki
11+ twitter_url: https://twitter.com/Searx_engine
412
513search:
614 safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict
utils/brand.env+3−1
@@ -1,7 +1,9 @@
1+export SEARX_URL=''
12export GIT_URL='https://github.com/searx/searx'
23export GIT_BRANCH='master'
34export ISSUE_URL='https://github.com/searx/searx/issues'
4−export SEARX_URL='https://searx.me'
55export DOCS_URL='https://searx.github.io/searx'
66export PUBLIC_INSTANCES='https://searx.space'
77export 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+42
@@ -0,0 +1,42 @@
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+from os.path import realpath, dirname, join, sep
8+repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
9+sys.path.insert(0, repo_root)
10+
11+from searx.settings_loader import load_settings
12+
13+settings, settings_load_message = load_settings()
14+print(settings_load_message)
15+
16+brand_env = 'utils' + sep + 'brand.env'
17+brand_py = 'searx' + sep + 'brand.py'
18+
19+def get_val(group, name, default=''):
20+ return settings[group].get(name, False) or ''
21+
22+name_val = [
23+ ('SEARX_URL' , get_val('server', 'base_url')),
24+ ('GIT_URL' , get_val('general','git_url')),
25+ ('GIT_BRANCH' , get_val('general','git_branch')),
26+ ('ISSUE_URL' , get_val('general','issue_url')),
27+ ('DOCS_URL' , get_val('general','docs_url')),
28+ ('PUBLIC_INSTANCES' , get_val('general','public_instances')),
29+ ('CONTACT_URL' , get_val('general','contact_url')),
30+ ('WIKI_URL' , get_val('general','wiki_url')),
31+ ('TWITTER_URL' , get_val('general','twitter_url')),
32+]
33+
34+print('build %s' % brand_env)
35+with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
36+ for name, val in name_val:
37+ print("export %s='%s'" % (name, val), file=f)
38+
39+print('build %s' % brand_py)
40+with open(repo_root + sep + brand_py, 'w', encoding='utf-8') as f:
41+ for name, val in name_val:
42+ print("%s = '%s'" % (name, val), file=f)