Commit 1cae4fa8 authored by Markus Heiser's avatar Markus Heiser

preferences.py: implement defaults if unset

Implemnts defaults for:

- search.default_lang, search.autocomplete, search.safe_search,
- ui.default_theme, ui.default_locale
- server.image_proxy

This fixes also:

  https://github.com/asciimoo/searx/pull/1860#issuecomment-590082955Signed-off-by: 's avatarMarkus Heiser <markus.heiser@darmarit.de>
parent 179be127
......@@ -326,43 +326,51 @@ class Preferences(object):
['general'], choices=categories + ['none']
),
'language': SearchLanguageSetting(
settings['search']['default_lang'],
settings['search'].get('default_lang', ''),
choices=list(LANGUAGE_CODES) + ['']
),
'locale': EnumStringSetting(
settings['ui']['default_locale'],
settings['ui'].get('default_locale', ''),
choices=list(settings['locales'].keys()) + ['']
),
'autocomplete': EnumStringSetting(
settings['search']['autocomplete'],
settings['search'].get('autocomplete', ''),
choices=list(autocomplete.backends.keys()) + ['']
),
'image_proxy': MapSetting(
settings['server']['image_proxy'],
map={ '': settings['server']['image_proxy'],
'0': False,
'1': True,
'True': True,
'False': False}
settings['server'].get('image_proxy', False),
map={
'': settings['server'].get('image_proxy', 0),
'0': False,
'1': True,
'True': True,
'False': False
}
),
'method': EnumStringSetting(
'POST',
choices=('GET', 'POST')
),
'safesearch': MapSetting(
settings['search']['safe_search'],
map={'0': 0,
'1': 1,
'2': 2}),
settings['search'].get('safe_search', 0),
map={
'0': 0,
'1': 1,
'2': 2
}
),
'theme': EnumStringSetting(
settings['ui']['default_theme'],
settings['ui'].get('default_theme', 'oscar'),
choices=themes
),
'results_on_new_tab': MapSetting(
False,
map ={'0': False, '1': True,
'False': False,
'True': True}
map={
'0': False,
'1': True,
'False': False,
'True': True
}
),
'doi_resolver': MultipleChoiceSetting(
['oadoi.org'], choices=DOI_RESOLVERS
......
......@@ -3,8 +3,6 @@ general:
instance_name : "searx_test"
search:
safe_search : 0
autocomplete : ""
language: "all"
server:
......@@ -12,14 +10,12 @@ server:
bind_address : 127.0.0.1
secret_key : "ultrasecretkey" # change this!
base_url : False
image_proxy : False
http_protocol_version : "1.0"
ui:
static_path : ""
templates_path : ""
default_theme : oscar
default_locale : ""
outgoing:
request_timeout : 1.0 # seconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment