summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--searx/engines/__init__.py8
-rw-r--r--searx/templates/oscar/preferences.html4
-rw-r--r--searx/templates/simple/preferences.html2
-rwxr-xr-xsearx/webapp.py3
4 files changed, 13 insertions, 4 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index 8d49bae8a..9472186bf 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -45,6 +45,9 @@ ENGINE_DEFAULT_ARGS = {
"display_error_messages": True,
"tokens": [],
}
+# set automatically when an engine does not have any tab category
+OTHER_CATEGORY = 'other'
+
"""Defaults for the namespace of an engine module, see :py:func:`load_engine`"""
categories = {'general': []}
@@ -114,6 +117,9 @@ def load_engine(engine_data):
set_loggers(engine, engine_name)
+ if not any(cat in settings['categories_as_tabs'] for cat in engine.categories):
+ engine.categories.append(OTHER_CATEGORY)
+
return engine
@@ -274,7 +280,7 @@ def group_engines_in_tab(engines): # pylint: disable=redefined-outer-name
return (group[0] == DEFAULT_GROUP_NAME, group[0].lower())
def get_group(eng):
- non_tab_engines = [c for c in eng.categories if c not in settings['categories_as_tabs']]
+ non_tab_engines = [c for c in eng.categories if c not in settings['categories_as_tabs'] + [OTHER_CATEGORY]]
return non_tab_engines[0] if len(non_tab_engines) > 0 else DEFAULT_GROUP_NAME
return [
diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html
index 810e6f072..341c203b0 100644
--- a/searx/templates/oscar/preferences.html
+++ b/searx/templates/oscar/preferences.html
@@ -298,7 +298,7 @@
<div class="tab-pane active_if_nojs" id="tab_engine">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist">
- {% for categ in categories_as_tabs %}
+ {% for categ in categories_as_tabs + [OTHER_CATEGORY] %}
<li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
{% endfor %}
</ul>
@@ -317,7 +317,7 @@
</p>
</div>
- {% for categ in categories_as_tabs %}
+ {% for categ in categories_as_tabs + [OTHER_CATEGORY] %}
<noscript><label>{{ _(categ) }}</label>
</noscript>
<div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html
index b4676d131..bec478f26 100644
--- a/searx/templates/simple/preferences.html
+++ b/searx/templates/simple/preferences.html
@@ -274,7 +274,7 @@
{{ tab_header('maintab', 'engines', _('Engines')) }}
<p>{{ _('Currently used search engines') }}</p>
{{ tabs_open() }}
- {% for categ in categories_as_tabs %}
+ {% for categ in categories_as_tabs + [OTHER_CATEGORY] %}
{{ tab_header('enginetab', 'category' + categ, _(categ)) }}
<div class="scrollx">
<table class="striped">
diff --git a/searx/webapp.py b/searx/webapp.py
index 9ce7b9d5a..c0467932e 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -59,6 +59,7 @@ 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 (
+ OTHER_CATEGORY,
DEFAULT_GROUP_NAME,
categories,
engines,
@@ -182,6 +183,7 @@ _category_names = (
gettext('software wikis'),
gettext('web'),
gettext(DEFAULT_GROUP_NAME),
+ gettext(OTHER_CATEGORY),
)
_simple_style = (gettext('auto'), gettext('light'), gettext('dark'))
@@ -439,6 +441,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['theme'] = get_current_theme_name(override=override_theme)
kwargs['categories_as_tabs'] = settings['categories_as_tabs']
kwargs['categories'] = _get_enable_categories(categories.keys())
+ kwargs['OTHER_CATEGORY'] = OTHER_CATEGORY
# i18n
kwargs['language_codes'] = [l for l in languages if l[0] in settings['search']['languages']]