From 5bfaabeb6bb50844fd7389770eb5c8a64e63f13e Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Thu, 15 Jan 2015 15:48:50 +0100 Subject: [PATCH 1/3] [enh] add nojs support into oscar-template --- searx/search.py | 9 +++++++-- searx/static/themes/oscar/css/oscar.min.css | Bin 1078 -> 1246 bytes .../themes/oscar/less/oscar/checkbox.less | 4 ++-- searx/templates/oscar/base.html | 3 ++- searx/templates/oscar/categories.html | 18 +++++++++++++++++- searx/templates/oscar/search_full.html | 4 ++-- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/searx/search.py b/searx/search.py index 427da3ba..0324d4aa 100644 --- a/searx/search.py +++ b/searx/search.py @@ -384,12 +384,17 @@ class Search(object): for pd_name, pd in self.request_data.items(): if pd_name.startswith('category_'): category = pd_name[9:] + # if category is not found in list, skip if category not in categories: continue - # add category to list - self.categories.append(category) + if pd != 'off': + # add category to list + self.categories.append(category) + elif category in self.categories: + # remove category from list if property is set to 'off' + self.categories.remove(category) # if no category is specified for this search, # using user-defined default-configuration which diff --git a/searx/static/themes/oscar/css/oscar.min.css b/searx/static/themes/oscar/css/oscar.min.css index b8d6fba156d46bd2063a4f4003ea52cffe8608c3..72be92c4651f458184879dee2ceeab3d783e12de 100644 GIT binary patch delta 103 zcmdnSagTGt3<+($oW!KmocN5)l+^glwD{zV)a2~c6rG7RGK|_2A4&mdZ=QBD?e!v(!*@Ve=a}!fE695;D4Q2oU diff --git a/searx/static/themes/oscar/less/oscar/checkbox.less b/searx/static/themes/oscar/less/oscar/checkbox.less index 712e53d4..6428b36e 100644 --- a/searx/static/themes/oscar/less/oscar/checkbox.less +++ b/searx/static/themes/oscar/less/oscar/checkbox.less @@ -1,9 +1,9 @@ // Hide element if checkbox is checked -input[type=checkbox]:checked ~ .label_hide_if_checked { +input[type=checkbox]:checked + .label_hide_if_checked, input[type=checkbox]:checked + .label_hide_if_not_checked + .label_hide_if_checked { display:none; } // Hide element if checkbox is not checked -input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked { +input[type=checkbox]:not(:checked) + .label_hide_if_not_checked, input[type=checkbox]:not(:checked) + .label_hide_if_checked + .label_hide_if_not_checked { display:none; } diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index 466756b6..c0393a66 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -36,7 +36,8 @@ diff --git a/searx/templates/oscar/categories.html b/searx/templates/oscar/categories.html index 82ddcf68..f38cce5b 100644 --- a/searx/templates/oscar/categories.html +++ b/searx/templates/oscar/categories.html @@ -1,6 +1,22 @@ -
+ + + +
{% for category in categories %} {% endfor %}
+ + diff --git a/searx/templates/oscar/search_full.html b/searx/templates/oscar/search_full.html index 673f2396..5818286e 100644 --- a/searx/templates/oscar/search_full.html +++ b/searx/templates/oscar/search_full.html @@ -8,8 +8,8 @@
- -
+ +
{% include 'oscar/categories.html' %}
From 525833bea7ea41f4794899dc0e8f6b3d05e21a85 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Thu, 15 Jan 2015 15:55:39 +0100 Subject: [PATCH 2/3] [enh] disable js-based links if no js is available --- searx/templates/oscar/base.html | 1 + searx/templates/oscar/result_templates/default.html | 2 +- searx/templates/oscar/result_templates/map.html | 6 +++--- searx/templates/oscar/result_templates/videos.html | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index c0393a66..bddeecb6 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -39,6 +39,7 @@ .tab-content > .active_if_nojs, .active_if_nojs {display: block;} .margin_top_if_nojs {margin-top: 20px;} .hide_if_nojs {display: none !important;overflow:none !important;} + .disabled_if_nojs {pointer-events: none; cursor: default; text-decoration: line-through;} diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html index b2430ed6..23af61f2 100644 --- a/searx/templates/oscar/result_templates/default.html +++ b/searx/templates/oscar/result_templates/default.html @@ -6,7 +6,7 @@ {{ icon('link') }} {{ _('cached') }} {% if result.embedded %} - + {% endif %} {% if result.embedded %} diff --git a/searx/templates/oscar/result_templates/map.html b/searx/templates/oscar/result_templates/map.html index c08e2e72..fd339527 100644 --- a/searx/templates/oscar/result_templates/map.html +++ b/searx/templates/oscar/result_templates/map.html @@ -7,15 +7,15 @@ {{ icon('link') }} {{ _('cached') }} {% if (result.latitude and result.longitude) or result.boundingbox %} - + {% endif %} {% if result.osm and (result.osm.type and result.osm.id) %} - + {% endif %} {# {% if (result.latitude and result.longitude) %} - + {% endif %} #}
diff --git a/searx/templates/oscar/result_templates/videos.html b/searx/templates/oscar/result_templates/videos.html index c3d02c14..7e773c67 100644 --- a/searx/templates/oscar/result_templates/videos.html +++ b/searx/templates/oscar/result_templates/videos.html @@ -6,7 +6,7 @@ {{ icon('link') }} {{ _('cached') }} {% if result.embedded %} - + {% endif %} {% if result.embedded %} From de6064994ef4854ccfb960947398f7b0cd565030 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Thu, 15 Jan 2015 16:03:30 +0100 Subject: [PATCH 3/3] [enh] show text "Start search" instead of icon, if javascript is disabled --- searx/templates/oscar/base.html | 2 +- searx/templates/oscar/search.html | 2 +- searx/templates/oscar/search_full.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index bddeecb6..42cd4e9a 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -36,7 +36,7 @@