frontpage: Rearrange parameters for add_shortcut

Rename id to shortcut_id.
This commit is contained in:
James Valleroy 2016-12-18 12:27:33 -05:00
parent c57d0284a6
commit f8dfd49f0f
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
10 changed files with 33 additions and 22 deletions

View File

@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
and exit. It can be followed by "essential" or "optional" to only
list those modules.
### Changed
- frontpage: Show app logos instead of generic icons.
## [0.12.0] - 2016-12-08
### Added
- Added screenshots to Readme.

View File

@ -27,18 +27,19 @@ def get_shortcuts():
return sorted(shortcuts.values(), key=lambda item: item['label'])
def add_shortcut(id, label, details=None, configure_url=None,
login_required=False, icon=None, url=None,):
def add_shortcut(shortcut_id, label, login_required=False,
icon=None, url=None,
details=None, configure_url=None):
"""Add shortcut to front page."""
if not url:
url = '?selected={id}'.format(id=id)
url = '?selected={id}'.format(id=shortcut_id)
if not icon:
icon = id
icon = shortcut_id
shortcuts[id] = {
'id': id,
shortcuts[shortcut_id] = {
'id': shortcut_id,
'label': label,
'url': url,
'icon': icon,
@ -48,19 +49,19 @@ def add_shortcut(id, label, details=None, configure_url=None,
}
def remove_shortcut(id):
def remove_shortcut(shortcut_id):
"""
Remove shortcut from front page.
If id ends with *, remove all shortcuts with that prefix.
If shortcut_id ends with *, remove all shortcuts with that prefix.
"""
def match(item):
if id[-1] == '*':
return item['id'].startswith(id[:-1])
if shortcut_id[-1] == '*':
return item['id'].startswith(shortcut_id[:-1])
return item['id'] == id
return item['id'] == shortcut_id
global shortcuts
shortcuts = {id: shortcut
for id, shortcut in shortcuts.items()
shortcuts = {shortcut_id: shortcut
for shortcut_id, shortcut in shortcuts.items()
if not match(shortcut)}

View File

@ -90,7 +90,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('minetest', title, url=None,
description, reverse_lazy('minetest:index'),
details=description,
configure_url=reverse_lazy('minetest:index'),
login_required=False)

View File

@ -90,7 +90,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('mumble', title,
description, reverse_lazy('mumble:index'),
details=description,
configure_url=reverse_lazy('mumble:index'),
login_required=False)

View File

@ -95,7 +95,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('privoxy', title,
description, reverse_lazy('privoxy:index'),
details=description,
configure_url=reverse_lazy('privoxy:index'),
login_required=True)

View File

@ -96,7 +96,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('quassel', title,
description, reverse_lazy('quassel:index'),
details=description,
configure_url=reverse_lazy('quassel:index'),
login_required=True)

View File

@ -88,7 +88,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('radicale', title,
description, reverse_lazy('radicale:index'),
details=description,
configure_url=reverse_lazy('radicale:index'),
login_required=True)

View File

@ -102,7 +102,8 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('repro', title,
description, reverse_lazy('repro:index'),
details=description,
configure_url=reverse_lazy('repro:index'),
login_required=True)

View File

@ -77,7 +77,7 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('shaarli', title, '/shaarli',
frontpage.add_shortcut('shaarli', title, url='/shaarli',
login_required=True)

View File

@ -99,10 +99,11 @@ def setup(helper, old_version=None):
def add_shortcut():
frontpage.add_shortcut('jsxc', _('Chat Client \n (jsxc)'),
reverse_lazy('xmpp:jsxc'),
url=reverse_lazy('xmpp:jsxc'),
login_required=True)
frontpage.add_shortcut('xmpp', title,
description, reverse_lazy('xmpp:index'),
details=description,
configure_url=reverse_lazy('xmpp:index'),
login_required=True)