[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 <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2022-07-24 12:06:49 +02:00
parent cfa62cc45f
commit 2dc4549a27
5 changed files with 40 additions and 15 deletions

View File

@ -6,25 +6,37 @@ Configured Engines
.. sidebar:: Further reading .. .. sidebar:: Further reading ..
- :ref:`settings categories_as_tabs`
- :ref:`engines-dev` - :ref:`engines-dev`
- :ref:`settings engine` - :ref:`settings engine`
- :ref:`general engine configuration`
Explanation of the :ref:`general engine configuration` shown in the table
:ref:`configured engines`.
.. jinja:: searx .. 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 <settings
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() %} {% 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 %} {% if loop.length > 1 %}
{{group}} {% if group_bang %}group ``{{group_bang}}``{% else %}{{group}}{% endif %}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{% endif %} {% endif %}
@ -36,7 +48,7 @@ Explanation of the :ref:`general engine configuration` shown in the table
- :cspan:`3` :ref:`Supported features <engine file>` - :cspan:`3` :ref:`Supported features <engine file>`
* - Name * - Name
- Shortcut - bang
- Module - Module
- Disabled - Disabled
- Timeout - Timeout

View File

@ -113,8 +113,8 @@
--color-toolkit-engine-tooltip-background: #fff; --color-toolkit-engine-tooltip-background: #fff;
--color-toolkit-loader-border: rgba(0, 0, 0, 0.2); --color-toolkit-loader-border: rgba(0, 0, 0, 0.2);
--color-toolkit-loader-borderleft: rgba(255, 255, 255, 0); --color-toolkit-loader-borderleft: rgba(255, 255, 255, 0);
--color-doc-code: #300; --color-doc-code: #003;
--color-doc-code-background: #fdd; --color-doc-code-background: #ddeaff;
} }
.dark-themes() { .dark-themes() {
@ -225,8 +225,8 @@
--color-toolkit-engine-tooltip-background: #222; --color-toolkit-engine-tooltip-background: #222;
--color-toolkit-loader-border: rgba(255, 255, 255, 0.2); --color-toolkit-loader-border: rgba(255, 255, 255, 0.2);
--color-toolkit-loader-borderleft: rgba(0, 0, 0, 0); --color-toolkit-loader-borderleft: rgba(0, 0, 0, 0);
--color-doc-code: #fdd; --color-doc-code: #003;
--color-doc-code-background: #300; --color-doc-code-background: #bdcadf;
} }
/// Dark Theme (autoswitch based on device pref) /// Dark Theme (autoswitch based on device pref)

View File

@ -121,6 +121,15 @@
.ltr-text-align-left(); .ltr-text-align-left();
font-weight: normal; font-weight: normal;
background: var(--color-settings-engine-group-background); 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, .name,

View File

@ -314,9 +314,9 @@
<th>{{ _("Max time") }}</th>{{- "" -}} <th>{{ _("Max time") }}</th>{{- "" -}}
<th>{{ _("Reliability") }}</th>{{- "" -}} <th>{{ _("Reliability") }}</th>{{- "" -}}
</tr> </tr>
{% 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 %} {% if loop.length > 1 %}
<tr><th colspan="9" class="engine-group">{{_(group)}}</th></tr> <tr><th colspan="9" class="engine-group">{{_(group)}}{% if group_bang %}<span class="group-bang">{{group_bang}}</span>{% endif %}</th></tr>{{- "" -}}
{% endif %} {% endif %}
{% for search_engine in engines %} {% for search_engine in engines %}
{% if not search_engine.private %} {% if not search_engine.private %}

View File

@ -175,4 +175,8 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[
def engine_sort_key(engine): def engine_sort_key(engine):
return (engine.about.get('language', ''), engine.name) 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