Repository: searxng/searxng

Issue:
/preferences: use simple layout for the oscar theme
Suggestion: change how the options are displayed in the /preferences page in the oscar theme :
* General
  * Default categories
  * Search languages
  * Autocomplete
  * SafeSearch
  * Open Access DOI rewrite (plugin)
  * Open Access DOI resolver
* Engines
* User Interface
  * Interface language
  * Themes
  * Results on new tabs
  * Infinite scroll (plugin)
  * Search on category select (plugin)
  * Hotkeys (plugins)
* Privacy
  * HTTP method
  * Image proxy
  * Tracker URL remover (plugin)
* Cookies
* Query syntax (new tab, a mix between documentation and auto documentation from the current settings)
  * Documentation about the query syntax (bang, external bangs, ...)
  * Answers (list of configured answers)
  * Special engines: currency, translations (list the engines that ).
  * External bangs

/preferences: use simple layout for the oscar theme
Suggestion: change how the options are displayed in the /preferences page in the oscar theme :
* General
  * Default categories
  * Search languages
  * Autocomplete
  * SafeSearch
  * Open Access DOI rewrite (plugin)
  * Open Access DOI resolver
* Engines
* User Interface
  * Interface language
  * Themes
  * Results on new tabs
  * Infinite scroll (plugin)
  * Search on category select (plugin)
  * Hotkeys (plugins)
* Privacy
  * HTTP method
  * Image proxy
  * Tracker URL remover (plugin)
* Cookies
* Query syntax (new tab, a mix between documentation and auto documentation from the current settings)
  * Documentation about the query syntax (bang, external bangs, ...)
  * Answers (list of configured answers)
  * Special engines: currency, translations (list the engines that ).
  * External bangs



Discussion:

Resolving patch:
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py
--- a/searx/plugins/__init__.py
+++ b/searx/plugins/__init__.py
@@ -70,6 +70,13 @@ def register(self, *plugins, external=False):
                 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'
+            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):
diff --git a/searx/plugins/hash_plugin.py b/searx/plugins/hash_plugin.py
--- a/searx/plugins/hash_plugin.py
+++ b/searx/plugins/hash_plugin.py
@@ -23,6 +23,9 @@
 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
--- a/searx/plugins/self_info.py
+++ b/searx/plugins/self_info.py
@@ -19,7 +19,9 @@
 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)


Test patch:
diff --git a/tests/robot/__init__.py b/tests/robot/__init__.py
--- a/tests/robot/__init__.py
+++ b/tests/robot/__init__.py
@@ -57,6 +57,7 @@ def test_preferences_locale(browser):
     browser.visit(url)
     browser.click_link_by_text('preferences')
 
+    browser.find_by_xpath('//a[@href="#tab_ui"]').first.click()
     browser.select('locale', 'hu')
     browser.find_by_xpath('//input[@value="save"]').first.click()