From 31e206361fac911d84e1f19dcf3f0ce80883d625 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Tue, 28 Dec 2021 14:51:21 +0100 Subject: [PATCH] [enh] group engines in preference tabs --- searx/templates/oscar/preferences.html | 7 ++++++- searx/templates/simple/preferences.html | 7 ++++++- searx/webapp.py | 13 +++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index da88cd755..fe344a2ea 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -348,7 +348,11 @@ {{ _("Allow") }} {% endif %} - {% for search_engine in engines_by_category[categ] %} + {% for group, engines in engines_by_category[categ] | group_engines_in_tab %} + {% if loop.length > 1 %} + {{_(group)}} + {% endif %} + {% for search_engine in engines %} {% if not search_engine.private %} {% if not rtl %} @@ -382,6 +386,7 @@ {% endif %} {% endif %} + {% endfor %} {% endfor %} diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html index 5f289c580..1d565c238 100644 --- a/searx/templates/simple/preferences.html +++ b/searx/templates/simple/preferences.html @@ -289,7 +289,11 @@ {{ _("Max time") }} {{ _("Reliability") }} - {% for search_engine in engines_by_category[categ] %} + {% for group, engines in engines_by_category[categ] | group_engines_in_tab %} + {% if loop.length > 1 %} + {{_(group)}} + {% endif %} + {% for search_engine in engines %} {% if not search_engine.private %} {% set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') %} @@ -305,6 +309,7 @@ {% endif %} {% endfor %} + {% endfor %} {{ tab_footer() }} diff --git a/searx/webapp.py b/searx/webapp.py index f884c35ef..9ce7b9d5a 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -59,9 +59,11 @@ from searx.settings_defaults import OUTPUT_FORMATS from searx.settings_loader import get_default_settings_path from searx.exceptions import SearxParameterException from searx.engines import ( + DEFAULT_GROUP_NAME, categories, engines, engine_shortcuts, + group_engines_in_tab, ) from searx.webutils import ( UnicodeWriter, @@ -152,6 +154,7 @@ app = Flask(__name__, static_folder=settings['ui']['static_path'], template_fold app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True app.jinja_env.add_extension('jinja2.ext.loopcontrols') # pylint: disable=no-member +app.jinja_env.filters['group_engines_in_tab'] = group_engines_in_tab # pylint: disable=no-member app.secret_key = settings['server']['secret_key'] babel = Babel(app) @@ -169,6 +172,16 @@ _category_names = ( gettext('map'), gettext('onions'), gettext('science'), + # non-tab categories + gettext('apps'), + gettext('dictionaries'), + gettext('lyrics'), + gettext('packages'), + gettext('q&a'), + gettext('repos'), + gettext('software wikis'), + gettext('web'), + gettext(DEFAULT_GROUP_NAME), ) _simple_style = (gettext('auto'), gettext('light'), gettext('dark'))