From 9485179064b4eb28f2813eba3c295edca3b0db7f Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 21 Dec 2020 00:37:45 +0100 Subject: [mod] move brand options from Makefile to settings.yml Signed-off-by: Markus Heiser --- searx/brand.py | 4 +++- searx/settings.yml | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'searx') diff --git a/searx/brand.py b/searx/brand.py index 7fcab6fad..cede5a270 100644 --- a/searx/brand.py +++ b/searx/brand.py @@ -1,7 +1,9 @@ +SEARX_URL = '' GIT_URL = 'https://github.com/searx/searx' GIT_BRANCH = 'master' ISSUE_URL = 'https://github.com/searx/searx/issues' -SEARX_URL = 'https://searx.me' 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/searx/settings.yml b/searx/settings.yml index 0a569e59c..aff80fe55 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1,6 +1,14 @@ general: debug : False # Debug mode, only for development instance_name : "searx" # displayed name + 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: False # mailto:contact@example.com + wiki_url: https://github.com/searx/searx/wiki + twitter_url: https://twitter.com/Searx_engine search: safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict -- cgit v1.2.3 From 9e53470b4cf533b890a2f57debd2f2b4198b4dd1 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 27 Dec 2020 14:39:48 +0100 Subject: [mod] get rid of searx/brand.py Removes module searx/brand.py and creates a namespace at searx.brand. This patch is a first 'proof of concept'. Later we can decide to remove the brand namespace entirely or not. Signed-off-by: Markus Heiser --- searx/__init__.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ searx/brand.py | 9 --------- 2 files changed, 46 insertions(+), 9 deletions(-) delete mode 100644 searx/brand.py (limited to 'searx') 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' -- cgit v1.2.3 From d0338cb5041f409f94a971d767bc5d8b9b0f23a8 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 27 Dec 2020 15:53:08 +0100 Subject: [fix] add missing brand.CONTACT_URL to /config API endpoint Suggested-by: @dalf / https://github.com/searx/searx-stats2/issues/59#issuecomment-747961582 Signed-off-by: Markus Heiser --- searx/webapp.py | 1 + 1 file changed, 1 insertion(+) (limited to 'searx') diff --git a/searx/webapp.py b/searx/webapp.py index 49750d210..10f4ce78c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1071,6 +1071,7 @@ def config(): 'default_theme': settings['ui']['default_theme'], 'version': VERSION_STRING, 'brand': { + 'CONTACT_URL': brand.CONTACT_URL, 'GIT_URL': brand.GIT_URL, 'DOCS_URL': brand.DOCS_URL }, -- cgit v1.2.3 From 424e6abc7e26c3e3be71678d00f88cf09d6c0a7e Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 11 Jan 2021 11:49:06 +0100 Subject: [mod] settings.yml: move brand settings to a dedicated section --- searx/__init__.py | 24 ++++++++++++------------ searx/settings.yml | 4 +++- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'searx') diff --git a/searx/__init__.py b/searx/__init__.py index 7f76022e1..11adbba73 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -66,43 +66,43 @@ class _brand_namespace: @classmethod def get_val(cls, group, name, default=''): - return settings[group].get(name, False) or '' + return settings.get(group, {}).get(name) or default @property def SEARX_URL(self): return self.get_val('server', 'base_url') + @property + def CONTACT_URL(self): + return self.get_val('general', 'contact_url') + @property def GIT_URL(self): - return self.get_val('general', 'git_url') + return self.get_val('brand', 'git_url') @property def GIT_BRANCH(self): - return self.get_val('general', 'git_branch') + return self.get_val('brand', 'git_branch') @property def ISSUE_URL(self): - return self.get_val('general', 'issue_url') + return self.get_val('brand', 'issue_url') @property def DOCS_URL(self): - return self.get_val('general', 'docs_url') + return self.get_val('brand', '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') + return self.get_val('brand', 'public_instances') @property def WIKI_URL(self): - return self.get_val('general', 'wiki_url') + return self.get_val('brand', 'wiki_url') @property def TWITTER_URL(self): - return self.get_val('general', 'twitter_url') + return self.get_val('brand', 'twitter_url') brand = _brand_namespace() diff --git a/searx/settings.yml b/searx/settings.yml index aff80fe55..30afbf957 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1,12 +1,14 @@ general: debug : False # Debug mode, only for development instance_name : "searx" # displayed name + contact_url: False # mailto:contact@example.com + +brand: 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: False # mailto:contact@example.com wiki_url: https://github.com/searx/searx/wiki twitter_url: https://twitter.com/Searx_engine -- cgit v1.2.3