Browse Source

Merge pull request #356 from pointhi/settings_fix

fix little bug inside settings, improve oscar template
Adam Tauber 10 years ago
parent
commit
4e28f12bfc

+ 1
- 1
searx/templates/courgette/preferences.html View File

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

+ 1
- 1
searx/templates/default/preferences.html View File

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

+ 5
- 0
searx/templates/oscar/messages/no_cookies.html View File

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 View File

117
 
117
 
118
                 <!-- Nav tabs -->
118
                 <!-- Nav tabs -->
119
                 <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;">
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
                     <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
121
                     <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
122
                     {% endfor %}
122
                     {% endfor %}
123
                 </ul>
123
                 </ul>
128
 
128
 
129
                 <!-- Tab panes -->
129
                 <!-- Tab panes -->
130
                 <div class="tab-content">
130
                 <div class="tab-content">
131
-                    {% for categ in categories %}
131
+                    {% for categ in all_categories %}
132
                     <noscript><label>{{ _(categ) }}</label>
132
                     <noscript><label>{{ _(categ) }}</label>
133
                     </noscript>
133
                     </noscript>
134
                     <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
134
                     <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
213
                     {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
213
                     {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
214
                     {{ _('With that list, you can assess searx transparency.') }}<br />
214
                     {{ _('With that list, you can assess searx transparency.') }}<br />
215
                 </p>
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
                     {% for cookie in cookies %}
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
                     {% endfor %}
228
                     {% endfor %}
229
-                    </fieldset>
230
-                </div>
229
+                </table>
230
+                {% else %}
231
+                    {% include 'oscar/messages/no_cookies.html' %}
232
+                {% endif %}
231
             </div>
233
             </div>
232
         </div>
234
         </div>
233
         <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.') }}
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 View File

279
                                     if x != 'general'
279
                                     if x != 'general'
280
                                     and x in nonblocked_categories)
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
     if 'selected_categories' not in kwargs:
288
     if 'selected_categories' not in kwargs:
283
         kwargs['selected_categories'] = []
289
         kwargs['selected_categories'] = []
284
         for arg in request.args:
290
         for arg in request.args:
286
                 c = arg.split('_', 1)[1]
292
                 c = arg.split('_', 1)[1]
287
                 if c in categories:
293
                 if c in categories:
288
                     kwargs['selected_categories'].append(c)
294
                     kwargs['selected_categories'].append(c)
295
+
289
     if not kwargs['selected_categories']:
296
     if not kwargs['selected_categories']:
290
         cookie_categories = request.cookies.get('categories', '').split(',')
297
         cookie_categories = request.cookies.get('categories', '').split(',')
291
         for ccateg in cookie_categories:
298
         for ccateg in cookie_categories:
292
             if ccateg in categories:
299
             if ccateg in categories:
293
                 kwargs['selected_categories'].append(ccateg)
300
                 kwargs['selected_categories'].append(ccateg)
301
+
294
     if not kwargs['selected_categories']:
302
     if not kwargs['selected_categories']:
295
         kwargs['selected_categories'] = ['general']
303
         kwargs['selected_categories'] = ['general']
296
 
304