浏览代码

Merge pull request #1059 from kvch/preferences-support-intuitive

preferences: make supported/not supported labels
Adam Tauber 7 年前
父节点
当前提交
1adc8d6e26

+ 1
- 8
searx/static/themes/oscar/css/logicodev.min.css
文件差异内容过多而无法显示
查看文件


+ 1
- 1
searx/static/themes/oscar/css/pointhi.min.css
文件差异内容过多而无法显示
查看文件


+ 1
- 1
searx/static/themes/oscar/js/searx.min.js 查看文件

@@ -1,2 +1,2 @@
1
-/*! oscar/searx.min.js | 25-07-2016 | https://github.com/asciimoo/searx */
1
+/*! oscar/searx.min.js | 06-10-2017 | https://github.com/asciimoo/searx */
2 2
 requirejs.config({baseUrl:"./static/themes/oscar/js",paths:{app:"../app"}}),searx.autocompleter&&(searx.searchResults=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("value"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:"./autocompleter?q=%QUERY"}),searx.searchResults.initialize()),$(document).ready(function(){searx.autocompleter&&$("#q").typeahead(null,{name:"search-results",displayKey:function(a){return a},source:searx.searchResults.ttAdapter()})}),$(document).ready(function(){$("#q.autofocus").focus(),$(".select-all-on-click").click(function(){$(this).select()}),$(".btn-collapse").click(function(){var a=$(this).data("btn-text-collapsed"),b=$(this).data("btn-text-not-collapsed");""!==a&&""!==b&&($(this).hasClass("collapsed")?new_html=$(this).html().replace(a,b):new_html=$(this).html().replace(b,a),$(this).html(new_html))}),$(".btn-toggle .btn").click(function(){var a="btn-"+$(this).data("btn-class"),b=$(this).data("btn-label-default"),c=$(this).data("btn-label-toggled");""!==c&&($(this).hasClass("btn-default")?new_html=$(this).html().replace(b,c):new_html=$(this).html().replace(c,b),$(this).html(new_html)),$(this).toggleClass(a),$(this).toggleClass("btn-default")}),$(".media-loader").click(function(){var a=$(this).data("target"),b=$(a+" > iframe"),c=b.attr("src");void 0!==c&&c!==!1||b.attr("src",b.data("src"))}),$(".btn-sm").dblclick(function(){var a="btn-"+$(this).data("btn-class");$(this).hasClass("btn-default")?($(".btn-sm > input").attr("checked","checked"),$(".btn-sm > input").prop("checked",!0),$(".btn-sm").addClass(a),$(".btn-sm").addClass("active"),$(".btn-sm").removeClass("btn-default")):($(".btn-sm > input").attr("checked",""),$(".btn-sm > input").removeAttr("checked"),$(".btn-sm > input").checked=!1,$(".btn-sm").removeClass(a),$(".btn-sm").removeClass("active"),$(".btn-sm").addClass("btn-default"))})}),$(document).ready(function(){$(".searx_overpass_request").on("click",function(a){var b="https://overpass-api.de/api/interpreter?data=",c=b+"[out:json][timeout:25];(",d=");out meta;",e=$(this).data("osm-id"),f=$(this).data("osm-type"),g=$(this).data("result-table"),h="#"+$(this).data("result-table-loadicon"),i=["addr:city","addr:country","addr:housenumber","addr:postcode","addr:street"];if(e&&f&&g){g="#"+g;var j=null;switch(f){case"node":j=c+"node("+e+");"+d;break;case"way":j=c+"way("+e+");"+d;break;case"relation":j=c+"relation("+e+");"+d}if(j){$.ajax(j).done(function(a){if(a&&a.elements&&a.elements[0]){var b=a.elements[0],c=$(g).html();for(var d in b.tags)if(null===b.tags.name||i.indexOf(d)==-1){switch(c+="<tr><td>"+d+"</td><td>",d){case"phone":case"fax":c+='<a href="tel:'+b.tags[d].replace(/ /g,"")+'">'+b.tags[d]+"</a>";break;case"email":c+='<a href="mailto:'+b.tags[d]+'">'+b.tags[d]+"</a>";break;case"website":case"url":c+='<a href="'+b.tags[d]+'">'+b.tags[d]+"</a>";break;case"wikidata":c+='<a href="https://www.wikidata.org/wiki/'+b.tags[d]+'">'+b.tags[d]+"</a>";break;case"wikipedia":if(b.tags[d].indexOf(":")!=-1){c+='<a href="https://'+b.tags[d].substring(0,b.tags[d].indexOf(":"))+".wikipedia.org/wiki/"+b.tags[d].substring(b.tags[d].indexOf(":")+1)+'">'+b.tags[d]+"</a>";break}default:c+=b.tags[d]}c+="</td></tr>"}$(g).html(c),$(g).removeClass("hidden"),$(h).addClass("hidden")}}).fail(function(){$(h).html($(h).html()+'<p class="text-muted">could not load data!</p>')})}}$(this).off(a)}),$(".searx_init_map").on("click",function(a){var b=$(this).data("leaflet-target"),c=$(this).data("map-lon"),d=$(this).data("map-lat"),e=$(this).data("map-zoom"),f=$(this).data("map-boundingbox"),g=$(this).data("map-geojson");require(["leaflet-0.7.3.min"],function(a){f&&(southWest=L.latLng(f[0],f[2]),northEast=L.latLng(f[1],f[3]),map_bounds=L.latLngBounds(southWest,northEast)),L.Icon.Default.imagePath="./static/themes/oscar/img/map";var h=L.map(b),i="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",j='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors',k=new L.TileLayer(i,{minZoom:1,maxZoom:19,attribution:j}),l="https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",m='Wikimedia maps beta | Maps data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';new L.TileLayer(l,{minZoom:1,maxZoom:19,attribution:m});map_bounds?setTimeout(function(){h.fitBounds(map_bounds,{maxZoom:17})},0):c&&d&&(e?h.setView(new L.LatLng(d,c),e):h.setView(new L.LatLng(d,c),8)),h.addLayer(k);var n={"OSM Mapnik":k};L.control.layers(n).addTo(h),g&&L.geoJson(g).addTo(h)}),$(this).off(a)})});

+ 2
- 0
searx/static/themes/oscar/less/logicodev/oscar.less 查看文件

@@ -19,3 +19,5 @@
19 19
 @import "cursor.less";
20 20
 
21 21
 @import "code.less";
22
+
23
+@import "preferences.less";

+ 3
- 0
searx/static/themes/oscar/less/logicodev/preferences.less 查看文件

@@ -0,0 +1,3 @@
1
+.table > tbody > tr > td, .table > tbody > tr > th {
2
+    vertical-align: middle !important;
3
+}

+ 2
- 0
searx/static/themes/oscar/less/pointhi/oscar.less 查看文件

@@ -17,3 +17,5 @@
17 17
 @import "code.less";
18 18
 
19 19
 @import "navbar.less";
20
+
21
+@import "preferences.less";

+ 3
- 0
searx/static/themes/oscar/less/pointhi/preferences.less 查看文件

@@ -0,0 +1,3 @@
1
+.table > tbody > tr > td, .table > tbody > tr > th {
2
+    vertical-align: middle !important;
3
+}

+ 12
- 0
searx/templates/oscar/macros.html 查看文件

@@ -85,3 +85,15 @@
85 85
         </label>
86 86
     </div>
87 87
 {%- endmacro %}
88
+
89
+{% macro support_toggle(supports) -%}
90
+    {% if supports %}
91
+    <span class="label label-success">
92
+        {{ _("supported") }}
93
+    </span>
94
+    {% else %}
95
+    <span class="label label-danger">
96
+        {{ _("not supported") }}
97
+    </span>
98
+    {% endif %}
99
+{%- endmacro %}

+ 17
- 14
searx/templates/oscar/preferences.html 查看文件

@@ -1,7 +1,8 @@
1
-{% from 'oscar/macros.html' import preferences_item_header, preferences_item_header_rtl, preferences_item_footer, preferences_item_footer_rtl, checkbox_toggle %}
1
+{% from 'oscar/macros.html' import preferences_item_header, preferences_item_header_rtl, preferences_item_footer, preferences_item_footer_rtl, checkbox_toggle, support_toggle %}
2 2
 {% extends "oscar/base.html" %}
3 3
 {% block title %}{{ _('preferences') }} - {% endblock %}
4 4
 {% block content %}
5
+
5 6
 <div>
6 7
 
7 8
     <h1>{{ _('Preferences') }}</h1>
@@ -148,7 +149,7 @@
148 149
 				    <th>{{ _("Allow") }}</th>
149 150
 				    <th>{{ _("Engine name") }}</th>
150 151
 				    <th>{{ _("Shortcut") }}</th>
151
-				    <th>{{ _("Supports selected language") }}</th>
152
+				    <th>{{ _("Selected language") }}</th>
152 153
 				    <th>{{ _("SafeSearch") }}</th>
153 154
 				    <th>{{ _("Time range") }}</th>
154 155
 				    <th>{{ _("Avg. time") }}</th>
@@ -156,8 +157,9 @@
156 157
                                     {% else %}
157 158
 				    <th>{{ _("Max time") }}</th>
158 159
 				    <th>{{ _("Avg. time") }}</th>
160
+				    <th>{{ _("Time range") }}</th>
159 161
 				    <th>{{ _("SafeSearch") }}</th>
160
-				    <th>{{ _("Supports selected language") }}</th>
162
+				    <th>{{ _("Selected language") }}</th>
161 163
 				    <th>{{ _("Shortcut") }}</th>
162 164
 				    <th>{{ _("Engine name") }}</th>
163 165
 				    <th>{{ _("Allow") }}</th>
@@ -172,17 +174,18 @@
172 174
                                     </td>
173 175
                                     <th>{{ search_engine.name }}</th>
174 176
 				    <td class="name">{{ shortcuts[search_engine.name] }}</td>
175
-				    <td><input type="checkbox" {{ "checked" if current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages else ""}} readonly="readonly" disabled="disabled"></td>
176
-				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
177
-				    <td><input type="checkbox" {{ "checked" if search_engine.time_range_support==True else ""}} readonly="readonly" disabled="disabled"></td>
178
-				    <td class="{{ 'danger' if stats[search_engine.name]['warn_time'] else '' }}">{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}</td>
179
-				    <td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
180
-                                    {% else %}
181
-				    <td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
182
-				    <td class="{{ 'danger' if stats[search_engine.name]['warn_time'] else '' }}">{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}</td>
183
-				    <td><input type="checkbox" {{ "checked" if search_engine.safesearch==True else ""}} readonly="readonly" disabled="disabled"></td>
184
-				    <td><input type="checkbox" {{ "checked" if current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages else ""}} readonly="readonly" disabled="disabled"></td>
185
-				    <td>{{ shortcuts[search_engine.name] }}</td>
177
+					<td>{{ support_toggle(current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages) }}</td>
178
+					<td>{{ support_toggle(search_engine.safesearch==True) }}</td>
179
+					<td>{{ support_toggle(search_engine.time_range_support==True) }}</td>
180
+					<td class="{{ 'danger' if stats[search_engine.name]['warn_time'] else '' }}">{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}</td>
181
+					<td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
182
+									{% else %}
183
+					<td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
184
+					<td class="{{ 'danger' if stats[search_engine.name]['warn_time'] else '' }}">{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}</td>
185
+					<td>{{ support_toggle(search_engine.time_range_support==True) }}</td>
186
+					<td>{{ support_toggle(search_engine.safesearch==True) }}</td>
187
+					<td>{{ support_toggle(current_language == 'all' or current_language in search_engine.supported_languages or current_language.split('-')[0] in search_engine.supported_languages) }}</td>
188
+					<td>{{ shortcuts[search_engine.name] }}</td>
186 189
                                     <th>{{ search_engine.name }}</th>
187 190
                                     <td class="onoff-checkbox">
188 191
                                         {{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}