Browse Source

Merge pull request #2327 from return42/ui-pref-add-bang

[mod] in the preference page, show !bang of subgrouping categories
Alexandre Flament 2 years ago
parent
commit
71bd091f6b

+ 26 - 12
docs/admin/engines/configured_engines.rst

@@ -6,49 +6,66 @@ 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`
-
-Explanation of the :ref:`general engine configuration` shown in the table
-:ref:`configured engines`.
+   - :ref:`general engine configuration`
 
 
 .. 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.
+
+   Engines can be assigned to multiple :ref:`categories <engine categories>`.
+   The UI displays the tabs that are configured in :ref:`categories_as_tabs
+   <settings 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 <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 %}
 
 
    .. flat-table::
    .. flat-table::
       :header-rows: 2
       :header-rows: 2
       :stub-columns: 1
       :stub-columns: 1
+      :widths: 10 1 10 1 1 1 1 1 1 1
 
 
       * - :cspan:`5` Engines configured by default (in :ref:`settings.yml <engine settings>`)
       * - :cspan:`5` Engines configured by default (in :ref:`settings.yml <engine settings>`)
         - :cspan:`3` :ref:`Supported features <engine file>`
         - :cspan:`3` :ref:`Supported features <engine file>`
 
 
       * - Name
       * - Name
-        - Shortcut
+        - !bang
         - Module
         - Module
         - Disabled
         - Disabled
         - Timeout
         - Timeout
         - Weight
         - Weight
         - Paging
         - Paging
-        - Language, Region
+        - Locale
         - Safe search
         - Safe search
         - Time range
         - Time range
 
 
       {% for mod in engines %}
       {% for mod in engines %}
 
 
       * - `{{mod.name}} <{{mod.about and mod.about.website}}>`_
       * - `{{mod.name}} <{{mod.about and mod.about.website}}>`_
+          {%- if mod.about and  mod.about.language %}
+          ({{mod.about.language | upper}})
+          {%- endif %}
         - ``!{{mod.shortcut}}``
         - ``!{{mod.shortcut}}``
         - {%- if 'searx.engines.' + mod.__name__ in documented_modules %}
         - {%- if 'searx.engines.' + mod.__name__ in documented_modules %}
           :py:mod:`~searx.engines.{{mod.__name__}}`
           :py:mod:`~searx.engines.{{mod.__name__}}`
@@ -56,9 +73,6 @@ Explanation of the :ref:`general engine configuration` shown in the table
           :origin:`{{mod.__name__}} <searx/engines/{{mod.__name__}}.py>`
           :origin:`{{mod.__name__}} <searx/engines/{{mod.__name__}}.py>`
           {%- endif %}
           {%- endif %}
         - {{(mod.disabled and "y") or ""}}
         - {{(mod.disabled and "y") or ""}}
-          {%- if mod.about and  mod.about.language %}
-          ({{mod.about.language | upper}})
-          {%- endif %}
         - {{mod.timeout}}
         - {{mod.timeout}}
         - {{mod.weight or 1 }}
         - {{mod.weight or 1 }}
         {% if mod.engine_type == 'online' %}
         {% if mod.engine_type == 'online' %}

+ 1 - 1
searx/infopage/de/search-syntax.md

@@ -30,7 +30,7 @@ nach dem Begriff **paris** gesucht.
 
 
 ## `:` Sprache auswählen
 ## `:` Sprache auswählen
 
 
-Um einen Sprachfilter auszuwählen, verwenden Sie das Präfix`:`.  Um ein
+Um einen Sprachfilter auszuwählen, verwenden Sie das Präfix `:`.  Um ein
 einfaches Beispiel zu geben:
 einfaches Beispiel zu geben:
 
 
 - Wikipedia mit einer benutzerdefinierten Sprache durchsuchen
 - Wikipedia mit einer benutzerdefinierten Sprache durchsuchen

+ 7 - 8
searx/static/themes/simple/css/leaflet.css

@@ -423,8 +423,11 @@ svg.leaflet-image-layer.leaflet-interactive path {
 .leaflet-control-attribution a:focus {
 .leaflet-control-attribution a:focus {
 	text-decoration: underline;
 	text-decoration: underline;
 	}
 	}
-.leaflet-control-attribution svg {
+.leaflet-attribution-flag {
 	display: inline !important;
 	display: inline !important;
+	vertical-align: baseline !important;
+	width: 1em;
+	height: 0.6669em;
 	}
 	}
 .leaflet-left .leaflet-control-scale {
 .leaflet-left .leaflet-control-scale {
 	margin-left: 5px;
 	margin-left: 5px;
@@ -438,12 +441,10 @@ svg.leaflet-image-layer.leaflet-interactive path {
 	line-height: 1.1;
 	line-height: 1.1;
 	padding: 2px 5px 1px;
 	padding: 2px 5px 1px;
 	white-space: nowrap;
 	white-space: nowrap;
-	overflow: hidden;
 	-moz-box-sizing: border-box;
 	-moz-box-sizing: border-box;
 	     box-sizing: border-box;
 	     box-sizing: border-box;
-
-	background: #fff;
-	background: rgba(255, 255, 255, 0.5);
+	background: rgba(255, 255, 255, 0.8);
+	text-shadow: 1px 1px #fff;
 	}
 	}
 .leaflet-control-scale-line:not(:first-child) {
 .leaflet-control-scale-line:not(:first-child) {
 	border-top: 2px solid #777;
 	border-top: 2px solid #777;
@@ -537,8 +538,6 @@ svg.leaflet-image-layer.leaflet-interactive path {
 	}
 	}
 .leaflet-popup-scrolled {
 .leaflet-popup-scrolled {
 	overflow: auto;
 	overflow: auto;
-	border-bottom: 1px solid #ddd;
-	border-top: 1px solid #ddd;
 	}
 	}
 
 
 .leaflet-oldie .leaflet-popup-content-wrapper {
 .leaflet-oldie .leaflet-popup-content-wrapper {
@@ -652,6 +651,6 @@ svg.leaflet-image-layer.leaflet-interactive path {
 	/* Prevent printers from removing background-images of controls. */
 	/* Prevent printers from removing background-images of controls. */
 	.leaflet-control {
 	.leaflet-control {
 		-webkit-print-color-adjust: exact;
 		-webkit-print-color-adjust: exact;
-		color-adjust: exact;
+		print-color-adjust: exact;
 		}
 		}
 	}
 	}

File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/simple/css/searxng-rtl.min.css


File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/simple/css/searxng-rtl.min.css.map


File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/simple/css/searxng.min.css


File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/simple/css/searxng.min.css.map


File diff suppressed because it is too large
+ 1 - 1
searx/static/themes/simple/js/leaflet.js


+ 1 - 1
searx/static/themes/simple/js/searxng.head.min.js.map

@@ -1 +1 @@
-{"version":3,"file":"searxng.head.min.js","sources":["../src/js/head/00_init.js"],"sourcesContent":["/* SPDX-License-Identifier: AGPL-3.0-or-later */\n(function (w, d) {\n  'use strict';\n\n  // add data- properties\n  var script = d.currentScript  || (function () {\n    var scripts = d.getElementsByTagName('script');\n    return scripts[scripts.length - 1];\n  })();\n\n  w.searxng = {\n    settings: JSON.parse(atob(script.getAttribute('client_settings')))\n  };\n\n  // update the css\n  var hmtlElement = d.getElementsByTagName(\"html\")[0];\n  hmtlElement.classList.remove('no-js');\n  hmtlElement.classList.add('js');\n\n})(window, document);\n"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searxng","settings","JSON","parse","atob","getAttribute","hmtlElement","classList","remove","add","window","document"],"mappings":"CACA,SAAWA,EAAGC,gBAIZ,IAAIC,EAASD,EAAEE,eAAkB,WAC/B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFD,GAKjCN,EAAEO,QAAU,CACVC,SAAUC,KAAKC,MAAMC,KAAKT,EAAOU,aAAa,sBAIhD,IAAIC,EAAcZ,EAAEI,qBAAqB,QAAQ,GACjDQ,EAAYC,UAAUC,OAAO,SAC7BF,EAAYC,UAAUE,IAAI,OAhB5B,CAkBGC,OAAQC"}
+{"version":3,"file":"searxng.head.min.js","sources":["../src/js/head/00_init.js"],"sourcesContent":["/* SPDX-License-Identifier: AGPL-3.0-or-later */\n(function (w, d) {\n  'use strict';\n\n  // add data- properties\n  var script = d.currentScript  || (function () {\n    var scripts = d.getElementsByTagName('script');\n    return scripts[scripts.length - 1];\n  })();\n\n  w.searxng = {\n    settings: JSON.parse(atob(script.getAttribute('client_settings')))\n  };\n\n  // update the css\n  var hmtlElement = d.getElementsByTagName(\"html\")[0];\n  hmtlElement.classList.remove('no-js');\n  hmtlElement.classList.add('js');\n\n})(window, document);\n"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searxng","settings","JSON","parse","atob","getAttribute","hmtlElement","classList","remove","add","window","document"],"mappings":"CACA,SAAWA,EAAGC,GACZ,aAGA,IAAIC,EAASD,EAAEE,eAAkB,WAC/B,IAAIC,EAAUH,EAAEI,qBAAqB,QAAQ,EAC7C,OAAOD,EAAQA,EAAQE,OAAS,EACjC,EAAE,EAEHN,EAAEO,QAAU,CACVC,SAAUC,KAAKC,MAAMC,KAAKT,EAAOU,aAAa,iBAAiB,CAAC,CAAC,CACnE,EAGA,IAAIC,EAAcZ,EAAEI,qBAAqB,MAAM,EAAE,GACjDQ,EAAYC,UAAUC,OAAO,OAAO,EACpCF,EAAYC,UAAUE,IAAI,IAAI,CAE/B,GAAEC,OAAQC,QAAQ"}

File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/simple/js/searxng.min.js.map


+ 4 - 4
searx/static/themes/simple/src/less/definitions.less

@@ -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-background: #fdd;
+  --color-doc-code: #003;
+  --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-background: #300;
+  --color-doc-code: #ddd;
+  --color-doc-code-background: #4d5a6f;
 }
 }
 
 
 /// Dark Theme (autoswitch based on device pref)
 /// Dark Theme (autoswitch based on device pref)

+ 4 - 3
searx/static/themes/simple/src/less/info.less

@@ -1,9 +1,10 @@
 .info-page {
 .info-page {
   code {
   code {
     font-family: monospace;
     font-family: monospace;
-    color: var(--color-doc-code);
+    .rounded-corners-tiny;
     background-color: var(--color-doc-code-background);
     background-color: var(--color-doc-code-background);
-    padding: 2px 5px;
-    .rounded-corners(5px);
+    color: var(--color-doc-code);
+    padding: 0.2rem;
+    border: 0 none;
   }
   }
 }
 }

+ 13 - 0
searx/static/themes/simple/src/less/preferences.less

@@ -72,6 +72,15 @@
     font-size: 90%;
     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 {
   table {
     border-collapse: collapse;
     border-collapse: collapse;
   }
   }
@@ -114,6 +123,10 @@
         .engine-description {
         .engine-description {
           margin-top: 0.5rem;
           margin-top: 0.5rem;
         }
         }
+
+        .bang {
+          margin: 0.3rem;
+        }
       }
       }
     }
     }
 
 

+ 10 - 6
searx/templates/simple/preferences.html

@@ -32,7 +32,8 @@
       {{ _('View error logs and submit a bug report') -}}
       {{ _('View error logs and submit a bug report') -}}
     </a>
     </a>
     {%- endif -%}
     {%- endif -%}
-
+    <p><span class="right">{{ _("!bang for this engine") }}</span>{% for bang in [search_engine.name] + [search_engine.shortcut] %}<span class="bang"> {{ '!' + bang.replace(' ', '_') }}</span>{% endfor %}</p>
+    <p><span class="right">{{ _("!bang for its categories") }}</span>{% for bang in search_engine.categories %}<span class="bang"> {{ '!' + bang.replace(' ', '_') }}</span>{% endfor %}</p>
 </div>
 </div>
 {%- endif -%}
 {%- endif -%}
 {%- endmacro %}
 {%- endmacro %}
@@ -309,7 +310,7 @@
       <tr>{{- "" -}}
       <tr>{{- "" -}}
         <th class="engine_checkbox">{{ _("Allow") }}</th>{{- "" -}}
         <th class="engine_checkbox">{{ _("Allow") }}</th>{{- "" -}}
         <th class="name">{{ _("Engine name") }}</th>{{- "" -}}
         <th class="name">{{ _("Engine name") }}</th>{{- "" -}}
-        <th class="shortcut">{{ _("!bang") }}</th>{{- "" -}}
+        <th class="shortcut">{{ _("Bang") }}</th>{{- "" -}}
         <th>{{ _("Supports selected language") }}</th>{{- "" -}}
         <th>{{ _("Supports selected language") }}</th>{{- "" -}}
         <th>{{ _("SafeSearch") }}</th>{{- "" -}}
         <th>{{ _("SafeSearch") }}</th>{{- "" -}}
         <th>{{ _("Time range") }}</th>{{- "" -}}
         <th>{{ _("Time range") }}</th>{{- "" -}}
@@ -317,9 +318,12 @@
         <th>{{ _("Max time") }}</th>{{- "" -}}
         <th>{{ _("Max time") }}</th>{{- "" -}}
         {%- if enable_metrics %}<th>{{ _("Reliability") }}</th>{% endif -%}
         {%- if enable_metrics %}<th>{{ _("Reliability") }}</th>{% endif -%}
       </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 class="engine-group" colspan="2">{{_(group)}}</th>
+        <th class="engine-group" colspan="7">{% if group_bang %}<span class="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 %}
@@ -329,13 +333,13 @@
         <th class="name" data-engine-name="{{ search_engine.name }}">{% if search_engine.enable_http %}{{ icon_big('warning', 'No HTTPS') }}{% endif -%}
         <th class="name" data-engine-name="{{ search_engine.name }}">{% if search_engine.enable_http %}{{ icon_big('warning', 'No HTTPS') }}{% endif -%}
           <label for="{{ engine_id }}">
           <label for="{{ engine_id }}">
             {{- search_engine.name -}}
             {{- search_engine.name -}}
-            {%- if search_engine.about and search_engine.about.language -%}
+            {%- if search_engine.about and search_engine.about.language %}
               ({{search_engine.about.language | upper}})
               ({{search_engine.about.language | upper}})
             {%- endif -%}
             {%- endif -%}
           </label>
           </label>
           {{- engine_about(search_engine) -}}
           {{- engine_about(search_engine) -}}
         </th>{{- "" -}}
         </th>{{- "" -}}
-        <td class="shortcut">{{ shortcuts[search_engine.name] }}</td>{{- "" -}}
+        <td class="shortcut"><span class="bang">{{ '!' + shortcuts[search_engine.name] }}</span></td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['supports_selected_language'], true) }}</td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['supports_selected_language'], true) }}</td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['safesearch'], true) }}</td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['safesearch'], true) }}</td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['time_range_support'], true) }}</td>{{- "" -}}
         <td>{{ checkbox(None, supports[search_engine.name]['time_range_support'], true) }}</td>{{- "" -}}

+ 6 - 1
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)
     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)
     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

Some files were not shown because too many files changed in this diff