mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
frontpage: Change shortcuts to list to simplify
This commit is contained in:
parent
0d350638d0
commit
f226b823a2
@ -19,23 +19,23 @@
|
|||||||
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.values(), key=lambda x: x['label'])
|
return sorted(shortcuts, key=lambda x: x['label'])
|
||||||
|
|
||||||
|
|
||||||
def add_shortcut(app, label, url, icon, details=None):
|
def add_shortcut(app, label, url, icon, details=None):
|
||||||
"""Add shortcut to front page."""
|
"""Add shortcut to front page."""
|
||||||
shortcuts[app] = {
|
shortcuts.append({
|
||||||
'app': app,
|
'app': app,
|
||||||
'label': label,
|
'label': label,
|
||||||
'url': url,
|
'url': url,
|
||||||
'icon': icon,
|
'icon': icon,
|
||||||
'details': details,
|
'details': details,
|
||||||
}
|
})
|
||||||
|
|
||||||
|
|
||||||
def remove_shortcut(app):
|
def remove_shortcut(app):
|
||||||
@ -44,10 +44,8 @@ def remove_shortcut(app):
|
|||||||
|
|
||||||
If app ends with *, remove all shortcuts with that prefix.
|
If app ends with *, remove all shortcuts with that prefix.
|
||||||
"""
|
"""
|
||||||
|
match = lambda x: x['app'] == app
|
||||||
if app[-1] == '*':
|
if app[-1] == '*':
|
||||||
remove = [k for k in shortcuts if k.startswith(app[:-1])]
|
match = lambda x: x['app'].startswith(app[:-1])
|
||||||
for k in remove:
|
|
||||||
del shortcuts[k]
|
|
||||||
|
|
||||||
elif app in shortcuts:
|
shortcuts[:] = [shortcut for shortcut in shortcuts if not match(shortcut)]
|
||||||
del shortcuts[app]
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user