on master help sign in
Merge pull request #356 from pointhi/settings_fix

fix little bug inside settings, improve oscar template

commit4e28f12bfcc73b47f382bceedb5b65ee314674ae authorAdam Tauber <asciimoo@gmail.com> dateFri 5 Jun 2015, 11:43 (11 years ago) parentaa1b8faa8b75ca
5 files changed+31−16
searx/templates/courgette/preferences.html+1−1 searx/templates/default/preferences.html+1−1 searx/templates/oscar/messages/no_cookies.html+5 searx/templates/oscar/preferences.html+16−14 searx/webapp.py+8
searx/templates/courgette/preferences.html+1−1
@@ -101,7 +101,7 @@
101101 <th>{{ _('Category') }}</th>
102102 <th>{{ _('Allow') }} / {{ _('Block') }}</th>
103103 </tr>
104− {% for categ in categories %}
104+ {% for categ in all_categories %}
105105 {% for search_engine in engines_by_category[categ] %}
106106
107107 {% if not search_engine.private %}
searx/templates/default/preferences.html+1−1
@@ -89,7 +89,7 @@
8989 <th>{{ _('Category') }}</th>
9090 <th>{{ _('Allow') }} / {{ _('Block') }}</th>
9191 </tr>
92− {% for categ in categories %}
92+ {% for categ in all_categories %}
9393 {% for search_engine in engines_by_category[categ] %}
9494
9595 {% if not search_engine.private %}
searx/templates/oscar/messages/no_cookies.htmlnew file+5
@@ -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>
searx/templates/oscar/preferences.html+16−14
@@ -117,7 +117,7 @@
117117
118118 <!-- Nav tabs -->
119119 <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 %}
121121 <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
122122 {% endfor %}
123123 </ul>
@@ -128,7 +128,7 @@
128128
129129 <!-- Tab panes -->
130130 <div class="tab-content">
131− {% for categ in categories %}
131+ {% for categ in all_categories %}
132132 <noscript><label>{{ _(categ) }}</label>
133133 </noscript>
134134 <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
@@ -213,21 +213,23 @@
213213 {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
214214 {{ _('With that list, you can assess searx transparency.') }}<br />
215215 </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>
222222
223223 {% 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>
228228 {% endfor %}
229− </fieldset>
230− </div>
229+ </table>
230+ {% else %}
231+ {% include 'oscar/messages/no_cookies.html' %}
232+ {% endif %}
231233 </div>
232234 </div>
233235 <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.') }}
searx/webapp.py+8
@@ -279,6 +279,12 @@ def render(template_name, override_theme=None, **kwargs):
279279 if x != 'general'
280280 and x in nonblocked_categories)
281281
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+
282288 if 'selected_categories' not in kwargs:
283289 kwargs['selected_categories'] = []
284290 for arg in request.args:
@@ -286,11 +292,13 @@ def render(template_name, override_theme=None, **kwargs):
286292 c = arg.split('_', 1)[1]
287293 if c in categories:
288294 kwargs['selected_categories'].append(c)
295+
289296 if not kwargs['selected_categories']:
290297 cookie_categories = request.cookies.get('categories', '').split(',')
291298 for ccateg in cookie_categories:
292299 if ccateg in categories:
293300 kwargs['selected_categories'].append(ccateg)
301+
294302 if not kwargs['selected_categories']:
295303 kwargs['selected_categories'] = ['general']
296304