diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index cf561a5ab..2d8288ddd 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -228,16 +228,16 @@ Categories not listed here can still be searched with the :ref:`search-syntax`. .. code-block:: yaml categories_as_tabs: - - general - - images - - videos - - news - - map - - music - - it - - science - - files - - social media + general: + images: + videos: + news: + map: + music: + it: + science: + files: + social media: .. _settings engine: diff --git a/searx/preferences.py b/searx/preferences.py index 918a7a300..b550e1ebd 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -272,7 +272,7 @@ class EnginesSetting(SwitchableSetting): transformed_choices = [] for engine_name, engine in self.choices.items(): # pylint: disable=no-member,access-member-before-definition for category in engine.categories: - if not category in settings['categories_as_tabs'] + [OTHER_CATEGORY]: + if not category in list(settings['categories_as_tabs'].keys()) + [OTHER_CATEGORY]: continue transformed_choice = {} transformed_choice['default_on'] = not engine.disabled diff --git a/searx/settings.yml b/searx/settings.yml index ee39b7b29..0aa7b99b0 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -228,16 +228,16 @@ checker: - has_infobox categories_as_tabs: - - general - - images - - videos - - news - - map - - music - - it - - science - - files - - social media + general: + images: + videos: + news: + map: + music: + it: + science: + files: + social media: engines: - name: apk mirror diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index d8e3ec693..c1154f7ff 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -20,18 +20,18 @@ OUTPUT_FORMATS = ['html', 'csv', 'json', 'rss'] LANGUAGE_CODES = ['all'] + list(l[0] for l in languages) OSCAR_STYLE = ('logicodev', 'logicodev-dark', 'pointhi') SIMPLE_STYLE = ('auto', 'light', 'dark') -CATEGORIES_AS_TABS = [ - 'general', - 'images', - 'videos', - 'news', - 'map', - 'music', - 'it', - 'science', - 'files', - 'social media', -] +CATEGORIES_AS_TABS = { + 'general': {}, + 'images': {}, + 'videos': {}, + 'news': {}, + 'map': {}, + 'music': {}, + 'it': {}, + 'science': {}, + 'files': {}, + 'social media': {}, +} STR_TO_BOOL = { '0': False, 'false': False, @@ -211,7 +211,7 @@ SCHEMA = { 'checker': { 'off_when_debug': SettingsValue(bool, True), }, - 'categories_as_tabs': SettingsValue(list, CATEGORIES_AS_TABS), + 'categories_as_tabs': SettingsValue(dict, CATEGORIES_AS_TABS), 'engines': SettingsValue(list, []), 'doi_resolvers': {}, } diff --git a/searx/webapp.py b/searx/webapp.py index b40aa912e..f2957a944 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -439,7 +439,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['query_in_title'] = request.preferences.get_value('query_in_title') kwargs['safesearch'] = str(request.preferences.get_value('safesearch')) kwargs['theme'] = get_current_theme_name(override=override_theme) - kwargs['categories_as_tabs'] = settings['categories_as_tabs'] + kwargs['categories_as_tabs'] = list(settings['categories_as_tabs'].keys()) kwargs['categories'] = _get_enable_categories(categories.keys()) kwargs['OTHER_CATEGORY'] = OTHER_CATEGORY diff --git a/searx/webutils.py b/searx/webutils.py index 4c3073aac..0c0854dfc 100644 --- a/searx/webutils.py +++ b/searx/webutils.py @@ -146,7 +146,9 @@ def group_engines_in_tab(engines: Iterable[Engine]) -> List[Tuple[str, Iterable[ """Groups an Iterable of engines by their first non tab category""" def get_group(eng): - non_tab_categories = [c for c in eng.categories if c not in settings['categories_as_tabs'] + [OTHER_CATEGORY]] + non_tab_categories = [ + c for c in eng.categories if c not in list(settings['categories_as_tabs'].keys()) + [OTHER_CATEGORY] + ] return non_tab_categories[0] if len(non_tab_categories) > 0 else DEFAULT_GROUP_NAME groups = itertools.groupby(sorted(engines, key=get_group), get_group) diff --git a/tests/robot/settings_robot.yml b/tests/robot/settings_robot.yml index 438ccf9a0..db22cce14 100644 --- a/tests/robot/settings_robot.yml +++ b/tests/robot/settings_robot.yml @@ -34,8 +34,8 @@ outgoing: useragent_suffix: "" categories_as_tabs: - - general - - dummy + general: + dummy: engines: - name: general dummy