mirror of
https://github.com/searxng/searxng.git
synced 2024-12-20 16:26:33 +00:00
[enh] more flexible category selection
This commit is contained in:
parent
a288aa322e
commit
c23db1b2bf
1 changed files with 8 additions and 2 deletions
|
@ -151,12 +151,18 @@ def render(template_name, override_theme=None, **kwargs):
|
|||
|
||||
if not 'selected_categories' in kwargs:
|
||||
kwargs['selected_categories'] = []
|
||||
for arg in request.args:
|
||||
if arg.startswith('category_'):
|
||||
c = arg.split('_', 1)[1]
|
||||
if c in categories:
|
||||
kwargs['selected_categories'].append(c)
|
||||
if not kwargs['selected_categories']:
|
||||
cookie_categories = request.cookies.get('categories', '').split(',')
|
||||
for ccateg in cookie_categories:
|
||||
if ccateg in categories:
|
||||
kwargs['selected_categories'].append(ccateg)
|
||||
if not kwargs['selected_categories']:
|
||||
kwargs['selected_categories'] = ['general']
|
||||
if not kwargs['selected_categories']:
|
||||
kwargs['selected_categories'] = ['general']
|
||||
|
||||
if not 'autocomplete' in kwargs:
|
||||
kwargs['autocomplete'] = autocomplete
|
||||
|
|
Loading…
Reference in a new issue