summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmanage.sh4
-rw-r--r--searx/__init__.py46
-rw-r--r--searx/brand.py9
-rw-r--r--setup.py6
-rw-r--r--utils/build_env.py36
5 files changed, 62 insertions, 39 deletions
diff --git a/manage.sh b/manage.sh
index bda74545c..bb86329f9 100755
--- a/manage.sh
+++ b/manage.sh
@@ -123,9 +123,9 @@ docker_build() {
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}')
# add the suffix "-dirty" if the repository has uncommited change
- # /!\ HACK for searx/searx: ignore searx/brand.py and utils/brand.env
+ # /!\ HACK for searx/searx: ignore utils/brand.env
git update-index -q --refresh
- if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'searx/brand.py' | grep -v 'utils/brand.env')" ]; then
+ if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
fi
diff --git a/searx/__init__.py b/searx/__init__.py
index 08e67f69d..7f76022e1 100644
--- a/searx/__init__.py
+++ b/searx/__init__.py
@@ -60,3 +60,49 @@ if 'SEARX_SECRET' in environ:
settings['server']['secret_key'] = environ['SEARX_SECRET']
if 'SEARX_BIND_ADDRESS' in environ:
settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
+
+
+class _brand_namespace:
+
+ @classmethod
+ def get_val(cls, group, name, default=''):
+ return settings[group].get(name, False) or ''
+
+ @property
+ def SEARX_URL(self):
+ return self.get_val('server', 'base_url')
+
+ @property
+ def GIT_URL(self):
+ return self.get_val('general', 'git_url')
+
+ @property
+ def GIT_BRANCH(self):
+ return self.get_val('general', 'git_branch')
+
+ @property
+ def ISSUE_URL(self):
+ return self.get_val('general', 'issue_url')
+
+ @property
+ def DOCS_URL(self):
+ return self.get_val('general', 'docs_url')
+
+ @property
+ def PUBLIC_INSTANCES(self):
+ return self.get_val('general', 'public_instances')
+
+ @property
+ def CONTACT_URL(self):
+ return self.get_val('general', 'contact_url')
+
+ @property
+ def WIKI_URL(self):
+ return self.get_val('general', 'wiki_url')
+
+ @property
+ def TWITTER_URL(self):
+ return self.get_val('general', 'twitter_url')
+
+
+brand = _brand_namespace()
diff --git a/searx/brand.py b/searx/brand.py
deleted file mode 100644
index cede5a270..000000000
--- a/searx/brand.py
+++ /dev/null
@@ -1,9 +0,0 @@
-SEARX_URL = ''
-GIT_URL = 'https://github.com/searx/searx'
-GIT_BRANCH = 'master'
-ISSUE_URL = 'https://github.com/searx/searx/issues'
-DOCS_URL = 'https://searx.github.io/searx'
-PUBLIC_INSTANCES = 'https://searx.space'
-CONTACT_URL = ''
-WIKI_URL = 'https://github.com/searx/searx/wiki'
-TWITTER_URL = 'https://twitter.com/Searx_engine'
diff --git a/setup.py b/setup.py
index 6a78f61b4..f89f16820 100644
--- a/setup.py
+++ b/setup.py
@@ -7,10 +7,8 @@ from setuptools import find_packages
import os
import sys
-# required to load VERSION_STRING constant
-sys.path.insert(0, './searx')
-from version import VERSION_STRING
-import brand
+from searx.version import VERSION_STRING
+from searx import brand
with open('README.rst', encoding='utf-8') as f:
long_description = f.read()
diff --git a/utils/build_env.py b/utils/build_env.py
index 0a210e8de..e7077dece 100644
--- a/utils/build_env.py
+++ b/utils/build_env.py
@@ -8,35 +8,23 @@ from os.path import realpath, dirname, join, sep
repo_root = realpath(dirname(realpath(__file__)) + sep + '..')
sys.path.insert(0, repo_root)
-from searx.settings_loader import load_settings
-
-settings, settings_load_message = load_settings()
-print(settings_load_message)
-
-brand_env = 'utils' + sep + 'brand.env'
-brand_py = 'searx' + sep + 'brand.py'
-
-def get_val(group, name, default=''):
- return settings[group].get(name, False) or ''
+from searx import brand
name_val = [
- ('SEARX_URL' , get_val('server', 'base_url')),
- ('GIT_URL' , get_val('general','git_url')),
- ('GIT_BRANCH' , get_val('general','git_branch')),
- ('ISSUE_URL' , get_val('general','issue_url')),
- ('DOCS_URL' , get_val('general','docs_url')),
- ('PUBLIC_INSTANCES' , get_val('general','public_instances')),
- ('CONTACT_URL' , get_val('general','contact_url')),
- ('WIKI_URL' , get_val('general','wiki_url')),
- ('TWITTER_URL' , get_val('general','twitter_url')),
+ ('SEARX_URL' , brand.SEARX_URL),
+ ('GIT_URL' , brand.GIT_URL),
+ ('GIT_BRANCH' , brand.GIT_BRANCH),
+ ('ISSUE_URL' , brand.ISSUE_URL),
+ ('DOCS_URL' , brand.DOCS_URL),
+ ('PUBLIC_INSTANCES' , brand.PUBLIC_INSTANCES),
+ ('CONTACT_URL' , brand.CONTACT_URL),
+ ('WIKI_URL' , brand.WIKI_URL),
+ ('TWITTER_URL' , brand.TWITTER_URL),
]
+brand_env = 'utils' + sep + 'brand.env'
+
print('build %s' % brand_env)
with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f:
for name, val in name_val:
print("export %s='%s'" % (name, val), file=f)
-
-print('build %s' % brand_py)
-with open(repo_root + sep + brand_py, 'w', encoding='utf-8') as f:
- for name, val in name_val:
- print("%s = '%s'" % (name, val), file=f)