瀏覽代碼

Merge pull request #356 from pointhi/settings_fix

fix little bug inside settings, improve oscar template
Adam Tauber 10 年之前
父節點
當前提交
4e28f12bfc

+ 1
- 1
searx/templates/courgette/preferences.html 查看文件

@@ -101,7 +101,7 @@
101 101
                 <th>{{ _('Category') }}</th>
102 102
                 <th>{{ _('Allow') }} / {{ _('Block') }}</th>
103 103
             </tr>
104
-        {% for categ in categories %}
104
+        {% for categ in all_categories %}
105 105
             {% for search_engine in engines_by_category[categ] %}
106 106
 
107 107
                 {% if not search_engine.private %}

+ 1
- 1
searx/templates/default/preferences.html 查看文件

@@ -89,7 +89,7 @@
89 89
             <th>{{ _('Category') }}</th>
90 90
             <th>{{ _('Allow') }} / {{ _('Block') }}</th>
91 91
         </tr>
92
-    {% for categ in categories %}
92
+    {% for categ in all_categories %}
93 93
         {% for search_engine in engines_by_category[categ] %}
94 94
 
95 95
             {% if not search_engine.private %}

+ 5
- 0
searx/templates/oscar/messages/no_cookies.html 查看文件

@@ -0,0 +1,5 @@
1
+{% from 'oscar/macros.html' import icon %}
2
+<div class="alert alert-info fade in" role="alert">
3
+    <strong class="lead">{{ icon('info-sign') }} {{ _('Information!') }}</strong>
4
+    {{ _('currently, there are no cookies defined.') }}
5
+</div>

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

@@ -117,7 +117,7 @@
117 117
 
118 118
                 <!-- Nav tabs -->
119 119
                 <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;">
120
-                    {% for categ in categories %}
120
+                    {% for categ in all_categories %}
121 121
                     <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
122 122
                     {% endfor %}
123 123
                 </ul>
@@ -128,7 +128,7 @@
128 128
 
129 129
                 <!-- Tab panes -->
130 130
                 <div class="tab-content">
131
-                    {% for categ in categories %}
131
+                    {% for categ in all_categories %}
132 132
                     <noscript><label>{{ _(categ) }}</label>
133 133
                     </noscript>
134 134
                     <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
@@ -213,21 +213,23 @@
213 213
                     {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
214 214
                     {{ _('With that list, you can assess searx transparency.') }}<br />
215 215
                 </p>
216
-                <div class="container-fluid">
217
-                    <fieldset>
218
-                        <div class="row">
219
-                            <div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Cookie name') }}</label></div>
220
-                            <div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Value') }}</label></div>
221
-                        </div>
216
+                {% if cookies %}
217
+                <table class="table table-striped">
218
+                    <tr>
219
+                        <th class="text-muted" style="padding-right:40px;">{{ _('Cookie name') }}</th>
220
+                        <th class="text-muted">{{ _('Value') }}</th>
221
+                    </tr>
222 222
 
223 223
                     {% for cookie in cookies %}
224
-                        <div class="row">
225
-                            <div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookie }}</div>
226
-                            <div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookies[cookie] }}</div>
227
-                        </div>
224
+                    <tr>
225
+                        <td class="text-muted" style="padding-right:40px;">{{ cookie }}</td>
226
+                        <td class="text-muted">{{ cookies[cookie] }}</td>
227
+                    </tr>
228 228
                     {% endfor %}
229
-                    </fieldset>
230
-                </div>
229
+                </table>
230
+                {% else %}
231
+                    {% include 'oscar/messages/no_cookies.html' %}
232
+                {% endif %}
231 233
             </div>
232 234
         </div>
233 235
         <p class="text-muted" style="margin:20px 0;">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}

+ 8
- 0
searx/webapp.py 查看文件

@@ -279,6 +279,12 @@ def render(template_name, override_theme=None, **kwargs):
279 279
                                     if x != 'general'
280 280
                                     and x in nonblocked_categories)
281 281
 
282
+    if 'all_categories' not in kwargs:
283
+        kwargs['all_categories'] = ['general']
284
+        kwargs['all_categories'].extend(x for x in
285
+                                        sorted(categories.keys())
286
+                                        if x != 'general')
287
+
282 288
     if 'selected_categories' not in kwargs:
283 289
         kwargs['selected_categories'] = []
284 290
         for arg in request.args:
@@ -286,11 +292,13 @@ def render(template_name, override_theme=None, **kwargs):
286 292
                 c = arg.split('_', 1)[1]
287 293
                 if c in categories:
288 294
                     kwargs['selected_categories'].append(c)
295
+
289 296
     if not kwargs['selected_categories']:
290 297
         cookie_categories = request.cookies.get('categories', '').split(',')
291 298
         for ccateg in cookie_categories:
292 299
             if ccateg in categories:
293 300
                 kwargs['selected_categories'].append(ccateg)
301
+
294 302
     if not kwargs['selected_categories']:
295 303
         kwargs['selected_categories'] = ['general']
296 304