Merge pull request #356 from pointhi/settings_fix

fix little bug inside settings, improve oscar template
This commit is contained in:
Adam Tauber 2015-06-05 11:43:46 -04:00
commit 4e28f12bfc
5 changed files with 31 additions and 16 deletions

View File

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

View File

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

View File

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

View File

@ -117,7 +117,7 @@
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;"> <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;">
{% for categ in categories %} {% for categ in all_categories %}
<li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li> <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -128,7 +128,7 @@
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content"> <div class="tab-content">
{% for categ in categories %} {% for categ in all_categories %}
<noscript><label>{{ _(categ) }}</label> <noscript><label>{{ _(categ) }}</label>
</noscript> </noscript>
<div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}"> <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
@ -213,21 +213,23 @@
{{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br /> {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
{{ _('With that list, you can assess searx transparency.') }}<br /> {{ _('With that list, you can assess searx transparency.') }}<br />
</p> </p>
<div class="container-fluid"> {% if cookies %}
<fieldset> <table class="table table-striped">
<div class="row"> <tr>
<div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Cookie name') }}</label></div> <th class="text-muted" style="padding-right:40px;">{{ _('Cookie name') }}</th>
<div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Value') }}</label></div> <th class="text-muted">{{ _('Value') }}</th>
</div> </tr>
{% for cookie in cookies %} {% for cookie in cookies %}
<div class="row"> <tr>
<div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookie }}</div> <td class="text-muted" style="padding-right:40px;">{{ cookie }}</td>
<div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookies[cookie] }}</div> <td class="text-muted">{{ cookies[cookie] }}</td>
</div> </tr>
{% endfor %} {% endfor %}
</fieldset> </table>
</div> {% else %}
{% include 'oscar/messages/no_cookies.html' %}
{% endif %}
</div> </div>
</div> </div>
<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.') }} <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.') }}

View File

@ -279,6 +279,12 @@ def render(template_name, override_theme=None, **kwargs):
if x != 'general' if x != 'general'
and x in nonblocked_categories) and x in nonblocked_categories)
if 'all_categories' not in kwargs:
kwargs['all_categories'] = ['general']
kwargs['all_categories'].extend(x for x in
sorted(categories.keys())
if x != 'general')
if 'selected_categories' not in kwargs: if 'selected_categories' not in kwargs:
kwargs['selected_categories'] = [] kwargs['selected_categories'] = []
for arg in request.args: for arg in request.args:
@ -286,11 +292,13 @@ def render(template_name, override_theme=None, **kwargs):
c = arg.split('_', 1)[1] c = arg.split('_', 1)[1]
if c in categories: if c in categories:
kwargs['selected_categories'].append(c) kwargs['selected_categories'].append(c)
if not kwargs['selected_categories']: if not kwargs['selected_categories']:
cookie_categories = request.cookies.get('categories', '').split(',') cookie_categories = request.cookies.get('categories', '').split(',')
for ccateg in cookie_categories: for ccateg in cookie_categories:
if ccateg in categories: if ccateg in categories:
kwargs['selected_categories'].append(ccateg) kwargs['selected_categories'].append(ccateg)
if not kwargs['selected_categories']: if not kwargs['selected_categories']:
kwargs['selected_categories'] = ['general'] kwargs['selected_categories'] = ['general']