on master help sign in
Merge pull request #174 from pointhi/nojs_fix
c5599e3Adam Tauber
searx/search.py+7−2
@@ -384,12 +384,17 @@ class Search(object):
384 for pd_name, pd in self.request_data.items():
384 for pd_name, pd in self.request_data.items():
385 if pd_name.startswith('category_'):
385 if pd_name.startswith('category_'):
386 category = pd_name[9:]
386 category = pd_name[9:]
387+
387 # if category is not found in list, skip
388 # if category is not found in list, skip
388 if category not in categories:
389 if category not in categories:
389 continue
390 continue
390
391
392+ if pd != 'off':
391− # add category to list
393+ # add category to list
392− self.categories.append(category)
394+ self.categories.append(category)
395+ elif category in self.categories:
396+ # remove category from list if property is set to 'off'
397+ self.categories.remove(category)
393
398
394 # if no category is specified for this search,
399 # if no category is specified for this search,
395 # using user-defined default-configuration which
400 # using user-defined default-configuration which
searx/static/themes/oscar/css/oscar.min.css+9−5
@@ -1,11 +1,14 @@
1html{position:relative;min-height:100%}
1html{position:relative;min-height:100%}
2body{margin-bottom:80px}
2body{margin-bottom:80px}
3.footer{position:absolute;bottom:0;width:100%;height:60px}
3.footer{position:absolute;bottom:0;width:100%;height:60px}
4−input[type=checkbox]:checked~.label_hide_if_checked{display:none}
4+input[type=checkbox]:checked+.label_hide_if_checked,input[type=checkbox]:checked+.label_hide_if_not_checked+.label_hide_if_checked{display:none}
5−input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none}
5+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}
6−.result_header{margin-bottom:5px;margin-top:20px}.result_header .favicon{margin-bottom:-3px}
6+.result_header{margin-bottom:5px;margin-top:20px}
7+.result_header .favicon{margin-bottom:-3px}
8+.result_header a{vertical-align:bottom}
7−.result_header a{vertical-align:bottom}.result_header a .highlight{font-weight:bold}
9+.result_header a .highlight{font-weight:bold}
10+.result-content{margin-top:5px}
8−.result-content{margin-top:5px}.result-content .highlight{font-weight:bold}
11+.result-content .highlight{font-weight:bold}
9.result-default{clear:both}
12.result-default{clear:both}
10.result-images{float:left !important}
13.result-images{float:left !important}
11.img-thumbnail{margin:5px;max-height:128px;min-height:128px}
14.img-thumbnail{margin:5px;max-height:128px;min-height:128px}
@@ -20,3 +23,4 @@ input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none}
20.search_categories{margin:10px 0;text-transform:capitalize}
23.search_categories{margin:10px 0;text-transform:capitalize}
21.cursor-text{cursor:text !important}
24.cursor-text{cursor:text !important}
22.cursor-pointer{cursor:pointer !important}
25.cursor-pointer{cursor:pointer !important}
26+
searx/static/themes/oscar/less/oscar/checkbox.less+2−2
@@ -1,9 +1,9 @@
1// Hide element if checkbox is checked
1// Hide element if checkbox is checked
2−input[type=checkbox]:checked ~ .label_hide_if_checked {
2+input[type=checkbox]:checked + .label_hide_if_checked, input[type=checkbox]:checked + .label_hide_if_not_checked + .label_hide_if_checked {
3 display:none;
3 display:none;
4}
4}
5
5
6// Hide element if checkbox is not checked
6// Hide element if checkbox is not checked
7−input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked {
7+input[type=checkbox]:not(:checked) + .label_hide_if_not_checked, input[type=checkbox]:not(:checked) + .label_hide_if_checked + .label_hide_if_not_checked {
8 display:none;
8 display:none;
9}
9}
searx/templates/oscar/base.html+3−1
@@ -36,8 +36,10 @@
36 </script>
36 </script>
37 <noscript>
37 <noscript>
38 <style type="text/css">
38 <style type="text/css">
39− .tab-content > .active_if_nojs {display: block;}
39+ .tab-content > .active_if_nojs, .active_if_nojs {display: block !important; visibility: visible !important;}
40+ .margin_top_if_nojs {margin-top: 20px;}
40 .hide_if_nojs {display: none !important;overflow:none !important;}
41 .hide_if_nojs {display: none !important;overflow:none !important;}
42+ .disabled_if_nojs {pointer-events: none; cursor: default; text-decoration: line-through;}
41 </style>
43 </style>
42 </noscript>
44 </noscript>
43</head>
45</head>
searx/templates/oscar/categories.html+17−1
@@ -1,6 +1,22 @@
1+<!-- used if scripts are disabled -->
2+<noscript>
3+<div id="categories" class="btn-group btn-toggle">
4+{% for category in categories %}
5+ <!--<div class="checkbox">-->
6+ <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_nojs" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
7+ <label class="btn btn-sm btn-primary active label_hide_if_not_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
8+ <label class="btn btn-sm btn-default label_hide_if_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
9+ <!--</div>-->
10+ {% if category in selected_categories %}<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_dis_activation" name="category_{{ category }}" value="off" checked="checked"/>{% endif %}
11+{% endfor %}
12+</div>
13+</noscript>
14+
1−<div id="categories" class="btn-group btn-toggle" data-toggle="buttons">
15+<div id="categories" class="btn-group btn-toggle hide_if_nojs" data-toggle="buttons">
2{% for category in categories %}
16{% for category in categories %}
3 <label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
17 <label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
4 <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label>
18 <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label>
5{% endfor %}
19{% endfor %}
6</div>
20</div>
21+
22+
searx/templates/oscar/result_templates/default.html+1−1
@@ -6,7 +6,7 @@
6<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
6<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
7
7
8{% if result.embedded %}
8{% if result.embedded %}
9− <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer media-loader" data-toggle="collapse" data-target="#result-media-{{ index }}" data-btn-text-collapsed="{{ _('show media') }}" data-btn-text-not-collapsed="{{ _('hide media') }}">{{ icon('music') }} {{ _('show media') }}</a></small>
9+ <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer media-loader disabled_if_nojs" data-toggle="collapse" data-target="#result-media-{{ index }}" data-btn-text-collapsed="{{ _('show media') }}" data-btn-text-not-collapsed="{{ _('hide media') }}">{{ icon('music') }} {{ _('show media') }}</a></small>
10{% endif %}
10{% endif %}
11
11
12{% if result.embedded %}
12{% if result.embedded %}
searx/templates/oscar/result_templates/map.html+3−3
@@ -7,15 +7,15 @@
7<small><a class="text-info" href="https://web.archive.org/web/{{ result.pretty_url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
7<small><a class="text-info" href="https://web.archive.org/web/{{ result.pretty_url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
8
8
9{% if (result.latitude and result.longitude) or result.boundingbox %}
9{% if (result.latitude and result.longitude) or result.boundingbox %}
10− <small> &bull; <a class="text-info btn-collapse collapsed searx_init_map cursor-pointer" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></small>
10+ <small> &bull; <a class="text-info btn-collapse collapsed searx_init_map cursor-pointer disabled_if_nojs" data-toggle="collapse" data-target="#result-map-{{ index }}" data-leaflet-target="osm-map-{{ index }}" data-map-lon="{{ result.longitude }}" data-map-lat="{{ result.latitude }}" {% if result.boundingbox %}data-map-boundingbox='{{ result.boundingbox|tojson|safe }}'{% endif %} {% if result.geojson %}data-map-geojson='{{ result.geojson|tojson|safe }}'{% endif %} data-btn-text-collapsed="{{ _('show map') }}" data-btn-text-not-collapsed="{{ _('hide map') }}">{{ icon('globe') }} {{ _('show map') }}</a></small>
11{% endif %}
11{% endif %}
12
12
13{% if result.osm and (result.osm.type and result.osm.id) %}
13{% if result.osm and (result.osm.type and result.osm.id) %}
14− <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer searx_overpass_request" data-toggle="collapse" data-target="#result-overpass-{{ index }}" data-osm-type="{{ result.osm.type }}" data-osm-id="{{ result.osm.id }}" data-result-table="result-overpass-table-{{ index }}" data-result-table-loadicon="result-overpass-table-loading-{{ index }}" data-btn-text-collapsed="{{ _('show details') }}" data-btn-text-not-collapsed="{{ _('hide details') }}">{{ icon('map-marker') }} {{ _('show details') }}</a></small>
14+ <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer searx_overpass_request disabled_if_nojs" data-toggle="collapse" data-target="#result-overpass-{{ index }}" data-osm-type="{{ result.osm.type }}" data-osm-id="{{ result.osm.id }}" data-result-table="result-overpass-table-{{ index }}" data-result-table-loadicon="result-overpass-table-loading-{{ index }}" data-btn-text-collapsed="{{ _('show details') }}" data-btn-text-not-collapsed="{{ _('hide details') }}">{{ icon('map-marker') }} {{ _('show details') }}</a></small>
15{% endif %}
15{% endif %}
16
16
17{# {% if (result.latitude and result.longitude) %}
17{# {% if (result.latitude and result.longitude) %}
18− <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer" data-toggle="collapse" data-target="#result-geodata-{{ index }}" data-btn-text-collapsed="{{ _('show geodata') }}" data-btn-text-not-collapsed="{{ _('hide geodata') }}">{{ icon('map-marker') }} {{ _('show geodata') }}</a></small>
18+ <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer disabled_if_nojs" data-toggle="collapse" data-target="#result-geodata-{{ index }}" data-btn-text-collapsed="{{ _('show geodata') }}" data-btn-text-not-collapsed="{{ _('hide geodata') }}">{{ icon('map-marker') }} {{ _('show geodata') }}</a></small>
19{% endif %} #}
19{% endif %} #}
20
20
21<div class="container-fluid">
21<div class="container-fluid">
searx/templates/oscar/result_templates/videos.html+1−1
@@ -6,7 +6,7 @@
6<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
6<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
7
7
8{% if result.embedded %}
8{% if result.embedded %}
9− <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer media-loader" data-toggle="collapse" data-target="#result-video-{{ index }}" data-btn-text-collapsed="{{ _('show video') }}" data-btn-text-not-collapsed="{{ _('hide video') }}">{{ icon('film') }} {{ _('show video') }}</a></small>
9+ <small> &bull; <a class="text-info btn-collapse collapsed cursor-pointer media-loader disabled_if_nojs" data-toggle="collapse" data-target="#result-video-{{ index }}" data-btn-text-collapsed="{{ _('show video') }}" data-btn-text-not-collapsed="{{ _('hide video') }}">{{ icon('film') }} {{ _('show video') }}</a></small>
10{% endif %}
10{% endif %}
11
11
12{% if result.embedded %}
12{% if result.embedded %}
searx/templates/oscar/search.html+1−1
@@ -3,7 +3,7 @@
3 <div class="input-group col-sm-12">
3 <div class="input-group col-sm-12">
4 <input type="search" name="q" class="form-control" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
4 <input type="search" name="q" class="form-control" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
5 <span class="input-group-btn">
5 <span class="input-group-btn">
6− <button type="submit" class="btn btn-default">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
6+ <button type="submit" class="btn btn-default"><span class="hide_if_nojs">{{ icon('search') }}</span><span class="hidden active_if_nojs">{{ _('Start search') }}</span></button>
7 </span>
7 </span>
8 </div>
8 </div>
9 <div class="search_categories">
9 <div class="search_categories">
searx/templates/oscar/search_full.html+3−3
@@ -4,12 +4,12 @@
4 <div class="input-group col-md-8 col-md-offset-2">
4 <div class="input-group col-md-8 col-md-offset-2">
5 <input type="search" name="q" class="form-control input-lg autofocus" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
5 <input type="search" name="q" class="form-control input-lg autofocus" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
6 <span class="input-group-btn">
6 <span class="input-group-btn">
7− <button type="submit" class="btn btn-default input-lg">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
7+ <button type="submit" class="btn btn-default input-lg"><span class="hide_if_nojs">{{ icon('search') }}</span><span class="hidden active_if_nojs">{{ _('Start search') }}</span></button>
8 </span>
8 </span>
9 </div>
9 </div>
10
10
11− <button type="button" class="btn btn-link btn-collapse center-block collapsed" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
11+ <button type="button" class="btn btn-link btn-collapse center-block collapsed hide_if_nojs" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
12− <div class="row collapse" id="search_categories">
12+ <div class="row collapse active_if_nojs margin_top_if_nojs" id="search_categories">
13 <div class="col-md-12 text-center">
13 <div class="col-md-12 text-center">
14 {% include 'oscar/categories.html' %}
14 {% include 'oscar/categories.html' %}
15 </div>
15 </div>