From f83b64270c6c8cff336889b93fdf6b6e3f20ffa2 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Tue, 1 Jun 2021 16:21:56 +0200 Subject: [mod] oscar theme /preferences: reorganize the preferences close #115 --- searx/plugins/__init__.py | 2 ++ searx/plugins/hash_plugin.py | 3 +++ searx/plugins/self_info.py | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'searx/plugins') diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 22f475875..f9fb3aa58 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -70,6 +70,8 @@ class PluginStore(): if not hasattr(plugin, plugin_attr) or not isinstance(getattr(plugin, plugin_attr), plugin_attr_type): setattr(plugin, plugin_attr, plugin_attr_type()) plugin.id = plugin.name.replace(' ', '_') + if not hasattr(plugin, 'preference_section'): + plugin.preference_section = 'general' self.plugins.append(plugin) def call(self, ordered_plugin_list, plugin_type, request, *args, **kwargs): diff --git a/searx/plugins/hash_plugin.py b/searx/plugins/hash_plugin.py index 1d3baaede..edb91dd8e 100644 --- a/searx/plugins/hash_plugin.py +++ b/searx/plugins/hash_plugin.py @@ -23,6 +23,9 @@ import re name = "Hash plugin" description = gettext("Converts strings to different hash digests.") default_on = True +preference_section = 'query' +query_keywords = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'] +query_examples = 'sha512 The quick brown fox jumps over the lazy dog' parser_re = re.compile('(md5|sha1|sha224|sha256|sha384|sha512) (.*)', re.I) diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py index 4fdfb4288..053899483 100644 --- a/searx/plugins/self_info.py +++ b/searx/plugins/self_info.py @@ -19,7 +19,9 @@ import re name = gettext('Self Informations') description = gettext('Displays your IP if the query is "ip" and your user agent if the query contains "user agent".') default_on = True - +preference_section = 'query' +query_keywords = ['user-agent'] +query_examples = '' # Self User Agent regex p = re.compile('.*user[ -]agent.*', re.IGNORECASE) -- cgit v1.2.3 From 881659ca9d29dbce5b19c5a69f03b2d1022d3615 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Wed, 16 Jun 2021 18:28:25 +0200 Subject: [mod] oscar theme: /preferences : HTML detail order match visual tabs First details about the general tab, then detail about UI tab, etc... No functionnal change --- searx/plugins/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'searx/plugins') diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index f9fb3aa58..45b210662 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -72,6 +72,11 @@ class PluginStore(): plugin.id = plugin.name.replace(' ', '_') if not hasattr(plugin, 'preference_section'): plugin.preference_section = 'general' + if plugin.preference_section == 'query': + for plugin_attr in ('query_keywords', 'query_examples'): + if not hasattr(plugin, plugin_attr): + logger.critical('missing attribute "{0}", cannot load plugin: {1}'.format(plugin_attr, plugin)) + exit(3) self.plugins.append(plugin) def call(self, ordered_plugin_list, plugin_type, request, *args, **kwargs): -- cgit v1.2.3