mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
frontpage: Fix regression in showing description
- After the shortcuts were turned into a list instead of dictionary, the descriptions stopped showing in the front page due to an 'in' check that worked for dict. Fix this by changing the shortcuts into a dictionary. - Also make the key of the shortcut dict an 'id' instead of 'app' that could create confusion how an app maps to a shortcut. - Minor indentation fixes.
This commit is contained in:
parent
3763e28d15
commit
7d2f9549a0
@ -19,33 +19,38 @@
|
|||||||
Manage application shortcuts on front page.
|
Manage application shortcuts on front page.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
shortcuts = []
|
shortcuts = {}
|
||||||
|
|
||||||
|
|
||||||
def get_shortcuts():
|
def get_shortcuts():
|
||||||
"""Return menu items in sorted order according to current locale."""
|
"""Return menu items in sorted order according to current locale."""
|
||||||
return sorted(shortcuts, key=lambda x: x['label'])
|
return sorted(shortcuts.values(), key=lambda item: item['label'])
|
||||||
|
|
||||||
|
|
||||||
def add_shortcut(app, label, url, icon, details=None):
|
def add_shortcut(id, label, url, icon, details=None):
|
||||||
"""Add shortcut to front page."""
|
"""Add shortcut to front page."""
|
||||||
shortcuts.append({
|
shortcuts[id] = {
|
||||||
'app': app,
|
'id': id,
|
||||||
'label': label,
|
'label': label,
|
||||||
'url': url,
|
'url': url,
|
||||||
'icon': icon,
|
'icon': icon,
|
||||||
'details': details,
|
'details': details,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
def remove_shortcut(app):
|
def remove_shortcut(id):
|
||||||
"""
|
"""
|
||||||
Remove shortcut from front page.
|
Remove shortcut from front page.
|
||||||
|
|
||||||
If app ends with *, remove all shortcuts with that prefix.
|
If id ends with *, remove all shortcuts with that prefix.
|
||||||
"""
|
"""
|
||||||
match = lambda x: x['app'] == app
|
def match(item):
|
||||||
if app[-1] == '*':
|
if id[-1] == '*':
|
||||||
match = lambda x: x['app'].startswith(app[:-1])
|
return item['id'].startswith(id[:-1])
|
||||||
|
|
||||||
shortcuts[:] = [shortcut for shortcut in shortcuts if not match(shortcut)]
|
return item['id'] == id
|
||||||
|
|
||||||
|
global shortcuts
|
||||||
|
shortcuts = {id: shortcut
|
||||||
|
for id, shortcut in shortcuts.items()
|
||||||
|
if not match(shortcut)}
|
||||||
|
|||||||
@ -23,39 +23,37 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if shortcuts %}
|
{% if shortcuts %}
|
||||||
|
|
||||||
{% for shortcut in shortcuts %}
|
{% for shortcut in shortcuts %}
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<ul class="nav nav-pills nav-stacked">
|
<ul class="nav nav-pills nav-stacked">
|
||||||
{% if selected_app == shortcut.app %}
|
{% if selected_id == shortcut.id %}
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="{{ shortcut.url }}" class="active">
|
<a href="{{ shortcut.url }}" class="active">
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ shortcut.url }}">
|
<a href="{{ shortcut.url }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="{{ shortcut.icon }} glyphicon"></span>
|
<span class="{{ shortcut.icon }} glyphicon"></span>
|
||||||
{{ shortcut.label }}
|
{{ shortcut.label }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
{% url 'apps:index' as apps_url %}
|
{% url 'apps:index' as apps_url %}
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
Enable some <a href="{{ apps_url }}">applications</a> to add
|
||||||
|
shortcuts to this page.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</h4>
|
||||||
|
|
||||||
Enable some <a href="{{ apps_url }}">applications</a> to add
|
{% endif %}
|
||||||
shortcuts to this page.
|
|
||||||
|
|
||||||
{% endblocktrans %}
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -67,7 +65,7 @@
|
|||||||
|
|
||||||
{% for paragraph in details %}
|
{% for paragraph in details %}
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{ paragraph|safe }}
|
{{ paragraph|safe }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -86,32 +84,26 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
|
||||||
{{ box_name }}, a Debian pure blend, is a 100% free software
|
{{ box_name }}, a Debian pure blend, is a 100% free software
|
||||||
self-hosting web server to deploy social applications on small
|
self-hosting web server to deploy social applications on small
|
||||||
machines. It provides online communication tools respecting your
|
machines. It provides online communication tools respecting your
|
||||||
privacy and data ownership.
|
privacy and data ownership.
|
||||||
|
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
|
||||||
More info about {{ box_name }} is available on the
|
More info about {{ box_name }} is available on the
|
||||||
project <a href="https://freedombox.org">homepage</a>
|
project <a href="https://freedombox.org">homepage</a>
|
||||||
and <a href="https://wiki.debian.org/FreedomBox">wiki</a>.
|
and <a href="https://wiki.debian.org/FreedomBox">wiki</a>.
|
||||||
|
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
|
|
||||||
This portal is a part of Plinth, the {{ box_name }} web
|
This portal is a part of Plinth, the {{ box_name }} web
|
||||||
interface. Plinth is free software, distributed under the GNU
|
interface. Plinth is free software, distributed under the GNU
|
||||||
Affero General Public License, Version 3 or later.
|
Affero General Public License, Version 3 or later.
|
||||||
|
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ def index(request):
|
|||||||
return TemplateResponse(request, 'index.html',
|
return TemplateResponse(request, 'index.html',
|
||||||
{'title': _('FreedomBox'),
|
{'title': _('FreedomBox'),
|
||||||
'shortcuts': shortcuts,
|
'shortcuts': shortcuts,
|
||||||
'selected_app': selection,
|
'selected_id': selection,
|
||||||
'details': details,
|
'details': details,
|
||||||
'details_label': details_label})
|
'details_label': details_label})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user