From 2dc4549a2752e26799aade0a625394195c227eed Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 24 Jul 2022 12:06:49 +0200 Subject: [PATCH] [mod] show !bang of (secondary) categories in the preference The name of the *secondary* categories in the preferences are translated, to use this categories the user needs to know by which !bang the category can be selected. Related to "Make 'non tab category' bangs discoverable" in [#690]. [#690] https://github.com/searxng/searxng/issues/690 Signed-off-by: Markus Heiser --- docs/admin/engines/configured_engines.rst | 28 +++++++++++++------ .../themes/simple/src/less/definitions.less | 8 +++--- .../themes/simple/src/less/preferences.less | 9 ++++++ searx/templates/simple/preferences.html | 4 +-- searx/webutils.py | 6 +++- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/admin/engines/configured_engines.rst b/docs/admin/engines/configured_engines.rst index c7b6a1f52..8599e227f 100644 --- a/docs/admin/engines/configured_engines.rst +++ b/docs/admin/engines/configured_engines.rst @@ -6,25 +6,37 @@ Configured Engines .. sidebar:: Further reading .. + - :ref:`settings categories_as_tabs` - :ref:`engines-dev` - :ref:`settings engine` - -Explanation of the :ref:`general engine configuration` shown in the table -:ref:`configured engines`. + - :ref:`general engine configuration` .. jinja:: searx - SearXNG supports {{engines | length}} search engines (of which {{enabled_engine_count}} are enabled by default). + SearXNG supports {{engines | length}} search engines (of which + {{enabled_engine_count}} are enabled by default). The UI displays the tabs + that are configured in :ref:`categories_as_tabs `. In addition to these main categories (aka *tabs*), + engines can be added to *secondary* categories (aka *groups*). A *tab*, + *group* or *engine* can be selected with a `!` (*bang*) in the + :ref:`search-syntax`. + +.. contents:: Contents + :depth: 2 + :local: + :backlinks: entry + +.. jinja:: searx {% for category, engines in categories_as_tabs.items() %} - {{category}} search engines + tab ``!{{category.replace(' ', '_')}}`` --------------------------------------- - {% for group, engines in engines | group_engines_in_tab %} + {% for group, group_bang, engines in engines | group_engines_in_tab %} {% if loop.length > 1 %} - {{group}} + {% if group_bang %}group ``{{group_bang}}``{% else %}{{group}}{% endif %} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {% endif %} @@ -36,7 +48,7 @@ Explanation of the :ref:`general engine configuration` shown in the table - :cspan:`3` :ref:`Supported features ` * - Name - - Shortcut + - bang - Module - Disabled - Timeout diff --git a/searx/static/themes/simple/src/less/definitions.less b/searx/static/themes/simple/src/less/definitions.less index ef6b02b2c..aa50eff50 100644 --- a/searx/static/themes/simple/src/less/definitions.less +++ b/searx/static/themes/simple/src/less/definitions.less @@ -113,8 +113,8 @@ --color-toolkit-engine-tooltip-background: #fff; --color-toolkit-loader-border: rgba(0, 0, 0, 0.2); --color-toolkit-loader-borderleft: rgba(255, 255, 255, 0); - --color-doc-code: #300; - --color-doc-code-background: #fdd; + --color-doc-code: #003; + --color-doc-code-background: #ddeaff; } .dark-themes() { @@ -225,8 +225,8 @@ --color-toolkit-engine-tooltip-background: #222; --color-toolkit-loader-border: rgba(255, 255, 255, 0.2); --color-toolkit-loader-borderleft: rgba(0, 0, 0, 0); - --color-doc-code: #fdd; - --color-doc-code-background: #300; + --color-doc-code: #003; + --color-doc-code-background: #bdcadf; } /// Dark Theme (autoswitch based on device pref) diff --git a/searx/static/themes/simple/src/less/preferences.less b/searx/static/themes/simple/src/less/preferences.less index 6913bbb90..c4c32a460 100644 --- a/searx/static/themes/simple/src/less/preferences.less +++ b/searx/static/themes/simple/src/less/preferences.less @@ -121,6 +121,15 @@ .ltr-text-align-left(); font-weight: normal; background: var(--color-settings-engine-group-background); + + .group-bang { + .ltr-margin-left(1rem); + .rounded-corners-tiny; + background: var(--color-doc-code-background); + color: var(--color-doc-code); + padding: 0.2rem; + border: 0 none; + } } .name, diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html index 7f9be5693..414966289 100644 --- a/searx/templates/simple/preferences.html +++ b/searx/templates/simple/preferences.html @@ -314,9 +314,9 @@ {{ _("Max time") }}{{- "" -}} {{ _("Reliability") }}{{- "" -}} - {% for group, engines in engines_by_category[categ] | group_engines_in_tab %} + {% for group, group_bang, engines in engines_by_category[categ] | group_engines_in_tab %} {% if loop.length > 1 %} - {{_(group)}} + {{_(group)}}{% if group_bang %}{{group_bang}}{% endif %}{{- "" -}} {% endif %} {% for search_engine in engines %} {% if not search_engine.private %} diff --git a/searx/webutils.py b/searx/webutils.py index a7fe22741..1c2ca6b33 100644 --- a/searx/webutils.py +++ b/searx/webutils.py @@ -175,4 +175,8 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[ def engine_sort_key(engine): return (engine.about.get('language', ''), engine.name) - return [(groupname, sorted(engines, key=engine_sort_key)) for groupname, engines in sorted_groups] + ret_val = [] + for groupname, engines in sorted_groups: + group_bang = '!' + groupname.replace(' ', '_') if groupname != DEFAULT_GROUP_NAME else '' + ret_val.append((groupname, group_bang, sorted(engines, key=engine_sort_key))) + return ret_val