From 0978f108879324a0367bc6d362f896532d6fc04f Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Fri, 5 Jun 2015 08:48:47 +0200 Subject: [PATCH 1/2] [fix] do not hide categorie inside preferences if there is no engine activated --- searx/templates/courgette/preferences.html | 2 +- searx/templates/default/preferences.html | 2 +- searx/templates/oscar/preferences.html | 4 ++-- searx/webapp.py | 8 ++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/searx/templates/courgette/preferences.html b/searx/templates/courgette/preferences.html index 2afb74d11..f89915d8d 100644 --- a/searx/templates/courgette/preferences.html +++ b/searx/templates/courgette/preferences.html @@ -101,7 +101,7 @@ {{ _('Category') }} {{ _('Allow') }} / {{ _('Block') }} - {% for categ in categories %} + {% for categ in all_categories %} {% for search_engine in engines_by_category[categ] %} {% if not search_engine.private %} diff --git a/searx/templates/default/preferences.html b/searx/templates/default/preferences.html index 0afe9f7d0..90006c029 100644 --- a/searx/templates/default/preferences.html +++ b/searx/templates/default/preferences.html @@ -89,7 +89,7 @@ {{ _('Category') }} {{ _('Allow') }} / {{ _('Block') }} - {% for categ in categories %} + {% for categ in all_categories %} {% for search_engine in engines_by_category[categ] %} {% if not search_engine.private %} diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index ee4e6ab57..6adb43523 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -117,7 +117,7 @@ @@ -128,7 +128,7 @@
- {% for categ in categories %} + {% for categ in all_categories %}
diff --git a/searx/webapp.py b/searx/webapp.py index 8587d546a..dbcbb4c0d 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -279,6 +279,12 @@ def render(template_name, override_theme=None, **kwargs): if x != 'general' and x in nonblocked_categories) + if 'all_categories' not in kwargs: + kwargs['all_categories'] = ['general'] + kwargs['all_categories'].extend(x for x in + sorted(categories.keys()) + if x != 'general') + if 'selected_categories' not in kwargs: kwargs['selected_categories'] = [] for arg in request.args: @@ -286,11 +292,13 @@ def render(template_name, override_theme=None, **kwargs): c = arg.split('_', 1)[1] if c in categories: kwargs['selected_categories'].append(c) + if not kwargs['selected_categories']: cookie_categories = request.cookies.get('categories', '').split(',') for ccateg in cookie_categories: if ccateg in categories: kwargs['selected_categories'].append(ccateg) + if not kwargs['selected_categories']: kwargs['selected_categories'] = ['general'] From a8b75ca47b14b9df13017f7409367993afb3fb7c Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Fri, 5 Jun 2015 09:07:59 +0200 Subject: [PATCH 2/2] [enh] oscar template: using table instead of container-fluid to show cookies --- .../templates/oscar/messages/no_cookies.html | 5 ++++ searx/templates/oscar/preferences.html | 26 ++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 searx/templates/oscar/messages/no_cookies.html diff --git a/searx/templates/oscar/messages/no_cookies.html b/searx/templates/oscar/messages/no_cookies.html new file mode 100644 index 000000000..9bebc8ad1 --- /dev/null +++ b/searx/templates/oscar/messages/no_cookies.html @@ -0,0 +1,5 @@ +{% from 'oscar/macros.html' import icon %} + diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index 6adb43523..ea36a14b9 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -213,21 +213,23 @@ {{ _('This is the list of cookies and their values searx is storing on your computer.') }}
{{ _('With that list, you can assess searx transparency.') }}

-
-
-
-
-
-
+ {% if cookies %} + + + + + {% for cookie in cookies %} -
-
{{ cookie }}
-
{{ cookies[cookie] }}
-
+ + + + {% endfor %} - - +
{{ _('Cookie name') }}{{ _('Value') }}
{{ cookie }}{{ cookies[cookie] }}
+ {% else %} + {% include 'oscar/messages/no_cookies.html' %} + {% endif %}

{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}