on master help sign in
Merge pull request #174 from pointhi/nojs_fix

add no javascript support to oscar-template

commitc5599e3c7c790ac2674b68f99919c0ec284327a3 authorAdam Tauber <asciimoo@gmail.com> dateThu 15 Jan 2015, 17:05 (12 years ago) parenta85be12de60649
10 files changed+47−20
searx/search.py+7−2 searx/static/themes/oscar/css/oscar.min.css+9−5 searx/static/themes/oscar/less/oscar/checkbox.less+2−2 searx/templates/oscar/base.html+3−1 searx/templates/oscar/categories.html+17−1 searx/templates/oscar/result_templates/default.html+1−1 searx/templates/oscar/result_templates/map.html+3−3 searx/templates/oscar/result_templates/videos.html+1−1 searx/templates/oscar/search.html+1−1 searx/templates/oscar/search_full.html+3−3
searx/search.py+7−2
@@ -384,12 +384,17 @@ class Search(object):
384384 for pd_name, pd in self.request_data.items():
385385 if pd_name.startswith('category_'):
386386 category = pd_name[9:]
387+
387388 # if category is not found in list, skip
388389 if category not in categories:
389390 continue
390391
391− # add category to list
392− self.categories.append(category)
392+ if pd != 'off':
393+ # add category to list
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)
393398
394399 # if no category is specified for this search,
395400 # using user-defined default-configuration which
searx/static/themes/oscar/css/oscar.min.css+9−5
@@ -1,11 +1,14 @@
11html{position:relative;min-height:100%}
22body{margin-bottom:80px}
33.footer{position:absolute;bottom:0;width:100%;height:60px}
4−input[type=checkbox]:checked~.label_hide_if_checked{display:none}
5−input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none}
6−.result_header{margin-bottom:5px;margin-top:20px}.result_header .favicon{margin-bottom:-3px}
7−.result_header a{vertical-align:bottom}.result_header a .highlight{font-weight:bold}
8−.result-content{margin-top:5px}.result-content .highlight{font-weight:bold}
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,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}
7+.result_header .favicon{margin-bottom:-3px}
8+.result_header a{vertical-align:bottom}
9+.result_header a .highlight{font-weight:bold}
10+.result-content{margin-top:5px}
11+.result-content .highlight{font-weight:bold}
912.result-default{clear:both}
1013.result-images{float:left !important}
1114.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}
2023.search_categories{margin:10px 0;text-transform:capitalize}
2124.cursor-text{cursor:text !important}
2225.cursor-pointer{cursor:pointer !important}
26+
searx/static/themes/oscar/less/oscar/checkbox.less+2−2
@@ -1,9 +1,9 @@
11// 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 {
33 display:none;
44}
55
66// 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 {
88 display:none;
99}
searx/templates/oscar/base.html+3−1
@@ -36,8 +36,10 @@
3636 </script>
3737 <noscript>
3838 <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;}
4041 .hide_if_nojs {display: none !important;overflow:none !important;}
42+ .disabled_if_nojs {pointer-events: none; cursor: default; text-decoration: line-through;}
4143 </style>
4244 </noscript>
4345</head>
searx/templates/oscar/categories.html+17−1
@@ -1,6 +1,22 @@
1−<div id="categories" class="btn-group btn-toggle" data-toggle="buttons">
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+
15+<div id="categories" class="btn-group btn-toggle hide_if_nojs" data-toggle="buttons">
216{% for category in categories %}
317 <label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
418 <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label>
519{% endfor %}
620</div>
21+
22+
searx/templates/oscar/result_templates/default.html+1−1
@@ -6,7 +6,7 @@
66<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
77
88{% 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>
1010{% endif %}
1111
1212{% if result.embedded %}
searx/templates/oscar/result_templates/map.html+3−3
@@ -7,15 +7,15 @@
77<small><a class="text-info" href="https://web.archive.org/web/{{ result.pretty_url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
88
99{% 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>
1111{% endif %}
1212
1313{% 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>
1515{% endif %}
1616
1717{# {% 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>
1919{% endif %} #}
2020
2121<div class="container-fluid">
searx/templates/oscar/result_templates/videos.html+1−1
@@ -6,7 +6,7 @@
66<small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}">{{ icon('link') }} {{ _('cached') }}</a></small>
77
88{% 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>
1010{% endif %}
1111
1212{% if result.embedded %}
searx/templates/oscar/search.html+1−1
@@ -3,7 +3,7 @@
33 <div class="input-group col-sm-12">
44 <input type="search" name="q" class="form-control" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
55 <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>
77 </span>
88 </div>
99 <div class="search_categories">
searx/templates/oscar/search_full.html+3−3
@@ -4,12 +4,12 @@
44 <div class="input-group col-md-8 col-md-offset-2">
55 <input type="search" name="q" class="form-control input-lg autofocus" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
66 <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>
88 </span>
99 </div>
1010
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>
12− <div class="row collapse" id="search_categories">
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 active_if_nojs margin_top_if_nojs" id="search_categories">
1313 <div class="col-md-12 text-center">
1414 {% include 'oscar/categories.html' %}
1515 </div>