diff options
author | Noémi Ványi <sitbackandwait@gmail.com> | 2020-03-30 23:24:30 +0200 |
---|---|---|
committer | Noémi Ványi <sitbackandwait@gmail.com> | 2020-06-03 21:33:14 +0200 |
commit | 640da73a9ea3203d96490d355c22c8cad63d6539 (patch) | |
tree | 6f1e8ac735471879ea1d930897fa8b7bcc008b66 /searx/webapp.py | |
parent | 08fdfc73fbbbe47811252ba89d8aeff8c1d07fcb (diff) | |
download | searxng-640da73a9ea3203d96490d355c22c8cad63d6539.tar.gz searxng-640da73a9ea3203d96490d355c22c8cad63d6539.zip |
make category order configurable using ui.categories_order
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index f3f5f21b8..46d4e949c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -355,17 +355,12 @@ def render(template_name, override_theme=None, **kwargs): if (engine_name, category) not in disabled_engines) if 'categories' not in kwargs: - kwargs['categories'] = ['general'] - kwargs['categories'].extend(x for x in - sorted(categories.keys()) - if x != 'general' - and x in enabled_categories) + kwargs['categories'] = [x for x in + _get_ordered_categories() + if x in enabled_categories] if 'all_categories' not in kwargs: - kwargs['all_categories'] = ['general'] - kwargs['all_categories'].extend(x for x in - sorted(categories.keys()) - if x != 'general') + kwargs['all_categories'] = _get_ordered_categories() if 'selected_categories' not in kwargs: kwargs['selected_categories'] = [] @@ -443,6 +438,17 @@ def render(template_name, override_theme=None, **kwargs): '{}/{}'.format(kwargs['theme'], template_name), **kwargs) +def _get_ordered_categories(): + ordered_categories = [] + if 'categories_order' not in settings['ui']: + ordered_categories = ['general'] + ordered_categories.extend(x for x in sorted(categories.keys()) if x != 'general') + return ordered_categories + ordered_categories = settings['ui']['categories_order'] + ordered_categories.extend(x for x in sorted(categories.keys()) if x not in ordered_categories) + return ordered_categories + + @app.before_request def pre_request(): request.start_time = time() |