From e060aedc16bb2b9e5c1ee3fc69a0e07a3576a80c Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Tue, 5 Dec 2017 22:30:20 +0100 Subject: [PATCH] [enh] make custom oscar option configurable from url --- searx/preferences.py | 4 ++++ searx/templates/oscar/base.html | 4 ++-- searx/templates/oscar/preferences.html | 4 ++-- searx/webapp.py | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/searx/preferences.py b/searx/preferences.py index dde4f098a..abd11d71e 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -305,6 +305,8 @@ class Preferences(object): elif user_setting_name == 'disabled_plugins': self.plugins.parse_cookie((input_data.get('disabled_plugins', ''), input_data.get('enabled_plugins', ''))) + else: + self.unknown_params[user_setting_name] = user_setting def parse_form(self, input_data): disabled_engines = [] @@ -329,6 +331,8 @@ class Preferences(object): def get_value(self, user_setting_name): if user_setting_name in self.key_value_settings: return self.key_value_settings[user_setting_name].get_value() + if user_setting_name in self.unknown_params: + return self.unknown_params[user_setting_name] def save(self, resp): for user_setting_name, user_setting in self.key_value_settings.items(): diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index 890204c7e..e3afb1ff0 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -13,8 +13,8 @@ {% block title %}{% endblock %}{{ instance_name }} - {% if cookies['oscar-style'] %} - + {% if preferences.get_value('oscar-style') %} + {% else %} {% endif %} diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index ac62dc939..f2e5cc539 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -106,8 +106,8 @@ {{ preferences_item_header(_('Choose style for this theme'), _('Style'), rtl) }} {{ preferences_item_footer(_('Choose style for this theme'), _('Style'), rtl) }} diff --git a/searx/webapp.py b/searx/webapp.py index abbbce950..ca4a3e101 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -376,6 +376,8 @@ def render(template_name, override_theme=None, **kwargs): kwargs['unicode'] = unicode + kwargs['preferences'] = request.preferences + kwargs['scripts'] = set() for plugin in request.user_plugins: for script in plugin.js_dependencies: