forked from zaclys/searxng
Merge pull request #2311 from return42/fix-1020-part-1
[fix] don't show a category if there is no active engine in
This commit is contained in:
commit
3372fcdb49
|
@ -13,7 +13,7 @@
|
||||||
} -%}
|
} -%}
|
||||||
<div id="categories" class="search_categories">{{- '' -}}
|
<div id="categories" class="search_categories">{{- '' -}}
|
||||||
<div id="categories_container">
|
<div id="categories_container">
|
||||||
{%- for category in categories_as_tabs -%}
|
{%- for category in categories -%}
|
||||||
<div class="category"><input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}"{% if category in selected_categories %} checked="checked"{% endif %}/>
|
<div class="category"><input type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}"{% if category in selected_categories %} checked="checked"{% endif %}/>
|
||||||
<label for="checkbox_{{ category|replace(' ', '_') }}" class="tooltips">
|
<label for="checkbox_{{ category|replace(' ', '_') }}" class="tooltips">
|
||||||
{{- icon_big(category_icons[category]) if category in category_icons else icon_big('globe-outline') -}}
|
{{- icon_big(category_icons[category]) if category in category_icons else icon_big('globe-outline') -}}
|
||||||
|
|
|
@ -373,16 +373,15 @@ def get_translations():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _get_enable_categories(all_categories: Iterable[str]):
|
def get_enabled_categories(category_names: Iterable[str]):
|
||||||
disabled_engines = request.preferences.engines.get_disabled()
|
"""The categories in ``category_names```for which there is no active engine
|
||||||
enabled_categories = set(
|
are filtered out and a reduced list is returned."""
|
||||||
# pylint: disable=consider-using-dict-items
|
|
||||||
category
|
enabled_engines = [item[0] for item in request.preferences.engines.get_enabled()]
|
||||||
for engine_name in engines
|
enabled_categories = set()
|
||||||
for category in engines[engine_name].categories
|
for engine_name in enabled_engines:
|
||||||
if (engine_name, category) not in disabled_engines
|
enabled_categories.update(engines[engine_name].categories)
|
||||||
)
|
return [x for x in category_names if x in enabled_categories]
|
||||||
return [x for x in all_categories if x in enabled_categories]
|
|
||||||
|
|
||||||
|
|
||||||
def get_pretty_url(parsed_url: urllib.parse.ParseResult):
|
def get_pretty_url(parsed_url: urllib.parse.ParseResult):
|
||||||
|
@ -434,7 +433,7 @@ def render(template_name: str, **kwargs):
|
||||||
kwargs['theme'] = request.preferences.get_value('theme')
|
kwargs['theme'] = request.preferences.get_value('theme')
|
||||||
kwargs['method'] = request.preferences.get_value('method')
|
kwargs['method'] = request.preferences.get_value('method')
|
||||||
kwargs['categories_as_tabs'] = list(settings['categories_as_tabs'].keys())
|
kwargs['categories_as_tabs'] = list(settings['categories_as_tabs'].keys())
|
||||||
kwargs['categories'] = _get_enable_categories(categories.keys())
|
kwargs['categories'] = get_enabled_categories(settings['categories_as_tabs'].keys())
|
||||||
kwargs['DEFAULT_CATEGORY'] = DEFAULT_CATEGORY
|
kwargs['DEFAULT_CATEGORY'] = DEFAULT_CATEGORY
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
|
|
Loading…
Reference in New Issue