From f117f969d85566c4a9df6c8a41ec441756b1bfa8 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 24 Jul 2022 12:06:49 +0200 Subject: [PATCH] [mod] in the preference page, show !bang of subgrouping categories The names of the subgrouping categories in the preference page 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]. Related: - [#690] https://github.com/searxng/searxng/issues/690 - https://github.com/searxng/searxng/issues/1604 - https://github.com/searxng/searxng/pull/1545 Signed-off-by: Markus Heiser --- docs/admin/engines/configured_engines.rst | 38 +++++++++++++------ .../themes/simple/src/less/definitions.less | 8 ++-- searx/static/themes/simple/src/less/info.less | 7 ++-- .../themes/simple/src/less/preferences.less | 13 +++++++ searx/templates/simple/preferences.html | 16 +++++--- searx/webutils.py | 7 +++- 6 files changed, 63 insertions(+), 26 deletions(-) diff --git a/docs/admin/engines/configured_engines.rst b/docs/admin/engines/configured_engines.rst index fa1e5a4b0..9507c77df 100644 --- a/docs/admin/engines/configured_engines.rst +++ b/docs/admin/engines/configured_engines.rst @@ -6,49 +6,66 @@ 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. + + Engines can be assigned to multiple :ref:`categories `. + The UI displays the tabs that are configured in :ref:`categories_as_tabs + `. In addition to these UI categories (also + called *tabs*), engines can be queried by their name or the categories they + belong to, by using a :ref:`\!bing 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 %} .. flat-table:: :header-rows: 2 :stub-columns: 1 + :widths: 10 1 10 1 1 1 1 1 1 1 * - :cspan:`5` Engines configured by default (in :ref:`settings.yml `) - :cspan:`3` :ref:`Supported features ` * - Name - - Shortcut + - !bang - Module - Disabled - Timeout - Weight - Paging - - Language, Region + - Locale - Safe search - Time range {% for mod in engines %} * - `{{mod.name}} <{{mod.about and mod.about.website}}>`_ + {%- if mod.about and mod.about.language %} + ({{mod.about.language | upper}}) + {%- endif %} - ``!{{mod.shortcut}}`` - {%- if 'searx.engines.' + mod.__name__ in documented_modules %} :py:mod:`~searx.engines.{{mod.__name__}}` @@ -56,9 +73,6 @@ Explanation of the :ref:`general engine configuration` shown in the table :origin:`{{mod.__name__}} ` {%- endif %} - {{(mod.disabled and "y") or ""}} - {%- if mod.about and mod.about.language %} - ({{mod.about.language | upper}}) - {%- endif %} - {{mod.timeout}} - {{mod.weight or 1 }} {% if mod.engine_type == 'online' %} diff --git a/searx/static/themes/simple/src/less/definitions.less b/searx/static/themes/simple/src/less/definitions.less index ef6b02b2c..e5a11ff2b 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: #ddd; + --color-doc-code-background: #4d5a6f; } /// Dark Theme (autoswitch based on device pref) diff --git a/searx/static/themes/simple/src/less/info.less b/searx/static/themes/simple/src/less/info.less index 8c83c379d..f354135d2 100644 --- a/searx/static/themes/simple/src/less/info.less +++ b/searx/static/themes/simple/src/less/info.less @@ -1,9 +1,10 @@ .info-page { code { font-family: monospace; - color: var(--color-doc-code); + .rounded-corners-tiny; background-color: var(--color-doc-code-background); - padding: 2px 5px; - .rounded-corners(5px); + color: var(--color-doc-code); + padding: 0.2rem; + border: 0 none; } } diff --git a/searx/static/themes/simple/src/less/preferences.less b/searx/static/themes/simple/src/less/preferences.less index 6913bbb90..4f446245a 100644 --- a/searx/static/themes/simple/src/less/preferences.less +++ b/searx/static/themes/simple/src/less/preferences.less @@ -72,6 +72,15 @@ font-size: 90%; } + .bang { + .ltr-text-align-left(); + .rounded-corners-tiny; + background-color: var(--color-doc-code-background); + color: var(--color-doc-code); + padding: 0.2rem; + border: 0 none; + } + table { border-collapse: collapse; } @@ -114,6 +123,10 @@ .engine-description { margin-top: 0.5rem; } + + .bang { + margin: 0.3rem; + } } } diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html index 70c150581..170dffa39 100644 --- a/searx/templates/simple/preferences.html +++ b/searx/templates/simple/preferences.html @@ -32,7 +32,8 @@ {{ _('View error logs and submit a bug report') -}} {%- endif -%} - +

{{ _("!bang for this engine") }}{% for bang in [search_engine.name] + [search_engine.shortcut] %} {{ '!' + bang.replace(' ', '_') }}{% endfor %}

+

{{ _("!bang for its categories") }}{% for bang in search_engine.categories %} {{ '!' + bang.replace(' ', '_') }}{% endfor %}

{%- endif -%} {%- endmacro %} @@ -309,7 +310,7 @@ {{- "" -}} {{ _("Allow") }}{{- "" -}} {{ _("Engine name") }}{{- "" -}} - {{ _("!bang") }}{{- "" -}} + {{ _("Bang") }}{{- "" -}} {{ _("Supports selected language") }}{{- "" -}} {{ _("SafeSearch") }}{{- "" -}} {{ _("Time range") }}{{- "" -}} @@ -317,9 +318,12 @@ {{ _("Max time") }}{{- "" -}} {%- if enable_metrics %}{{ _("Reliability") }}{% endif -%} - {% 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 %} @@ -329,13 +333,13 @@ {% if search_engine.enable_http %}{{ icon_big('warning', 'No HTTPS') }}{% endif -%} {{- engine_about(search_engine) -}} {{- "" -}} - {{ shortcuts[search_engine.name] }}{{- "" -}} + {{ '!' + shortcuts[search_engine.name] }}{{- "" -}} {{ checkbox(None, supports[search_engine.name]['supports_selected_language'], true) }}{{- "" -}} {{ checkbox(None, supports[search_engine.name]['safesearch'], true) }}{{- "" -}} {{ checkbox(None, supports[search_engine.name]['time_range_support'], true) }}{{- "" -}} diff --git a/searx/webutils.py b/searx/webutils.py index 4b11a15af..470833291 100644 --- a/searx/webutils.py +++ b/searx/webutils.py @@ -242,4 +242,9 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[ subgroups = itertools.groupby(sorted(engines, key=get_subgroup), get_subgroup) sorted_groups = sorted(((name, list(engines)) for name, engines in subgroups), key=group_sort_key) - 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 != NO_SUBGROUPING else '' + ret_val.append((groupname, group_bang, sorted(engines, key=engine_sort_key))) + + return ret_val