forked from Icycoide/searxng
new preferences handling
Preferences class was introduced in order to handle user preferences. Right now it parses cookies and the form in preferences. Also it can retrieve settings based on the name of the setting. ATTENTION Please note that engine preferences are handled differently from now on. So it introduces incompatible changes. Every user who has saved preferences should reset and save his/her settings again. This change was needed, because everytime a default disabled engine was added saved user preferences would broke. Now engine setting tracking is fixed.
This commit is contained in:
parent
9331fc28a8
commit
fe691a0988
6 changed files with 315 additions and 167 deletions
|
@ -230,26 +230,3 @@ def list_get(a_list, index, default=None):
|
|||
return a_list[index]
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
def get_blocked_engines(engines, cookies):
|
||||
if 'blocked_engines' not in cookies:
|
||||
return [(engine_name, category) for engine_name in engines
|
||||
for category in engines[engine_name].categories if engines[engine_name].disabled]
|
||||
|
||||
blocked_engine_strings = cookies.get('blocked_engines', '').split(',')
|
||||
blocked_engines = []
|
||||
|
||||
if not blocked_engine_strings:
|
||||
return blocked_engines
|
||||
|
||||
for engine_string in blocked_engine_strings:
|
||||
if engine_string.find('__') > -1:
|
||||
engine, category = engine_string.split('__', 1)
|
||||
if engine in engines and category in engines[engine].categories:
|
||||
blocked_engines.append((engine, category))
|
||||
elif engine_string in engines:
|
||||
for category in engines[engine_string].categories:
|
||||
blocked_engines.append((engine_string, category))
|
||||
|
||||
return blocked_engines
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue