diff --git a/plinth/frontpage.py b/plinth/frontpage.py index 7e149dbb8..d000253a4 100644 --- a/plinth/frontpage.py +++ b/plinth/frontpage.py @@ -37,6 +37,15 @@ def add_shortcut(app, label, url, icon): def remove_shortcut(app): - """Remove shortcut from front page.""" - if app in shortcuts: + """ + Remove shortcut from front page. + + If app ends with *, remove all shortcuts with that prefix. + """ + if app[-1] == '*': + remove = [k for k in shortcuts if k.startswith(app[:-1])] + for k in remove: + del shortcuts[k] + + elif app in shortcuts: del shortcuts[app] diff --git a/plinth/modules/ikiwiki/__init__.py b/plinth/modules/ikiwiki/__init__.py index 1c9b6c3ed..bf4345855 100644 --- a/plinth/modules/ikiwiki/__init__.py +++ b/plinth/modules/ikiwiki/__init__.py @@ -60,7 +60,7 @@ def init(): is_enabled=is_enabled, enable=enable, disable=disable) if is_enabled(): - add_shortcut() + add_shortcuts() def setup(helper, old_version=None): @@ -68,11 +68,14 @@ def setup(helper, old_version=None): helper.install(managed_packages) helper.call('post', actions.superuser_run, 'ikiwiki', ['setup']) helper.call('post', service.notify_enabled, None, True) - helper.call('post', add_shortcut) -def add_shortcut(): - frontpage.add_shortcut('ikiwiki', title, '/ikiwiki', 'glyphicon-edit') +def add_shortcuts(): + sites = actions.run('ikiwiki', ['get-sites']).split('\n') + sites = [name for name in sites if name != ''] + for site in sites: + frontpage.add_shortcut( + 'ikiwiki_' + site, site, '/ikiwiki/' + site, 'glyphicon-edit') def is_enabled(): @@ -83,13 +86,13 @@ def is_enabled(): def enable(): """Enable the module.""" actions.superuser_run('ikiwiki', ['enable']) - add_shortcut() + add_shortcuts() def disable(): """Enable the module.""" actions.superuser_run('ikiwiki', ['disable']) - frontpage.remove_shortcut('ikiwiki') + frontpage.remove_shortcut('ikiwiki*') def diagnose(): diff --git a/plinth/modules/ikiwiki/views.py b/plinth/modules/ikiwiki/views.py index 44a092ca6..d807ffc5f 100644 --- a/plinth/modules/ikiwiki/views.py +++ b/plinth/modules/ikiwiki/views.py @@ -26,6 +26,7 @@ from django.urls import reverse_lazy from django.utils.translation import ugettext as _, ugettext_lazy from plinth import actions +from plinth import frontpage from plinth import views from plinth.modules import ikiwiki @@ -81,6 +82,10 @@ def create(request): form.cleaned_data['admin_name'], form.cleaned_data['admin_password']) + site = form.cleaned_data['name'].replace(' ', '') + frontpage.add_shortcut('ikiwiki_' + site, site, + '/ikiwiki/' + site, 'glyphicon-edit') + return redirect(reverse_lazy('ikiwiki:manage')) else: form = IkiwikiCreateForm(prefix='ikiwiki') @@ -129,6 +134,7 @@ def delete(request, name): try: actions.superuser_run('ikiwiki', ['delete', '--name', name]) messages.success(request, _('{name} deleted.').format(name=name)) + frontpage.remove_shortcut('ikiwiki_' + name) except actions.ActionError as error: messages.error(request, _('Could not delete {name}: {error}') .format(name=name, error=error)) diff --git a/plinth/templates/index.html b/plinth/templates/index.html index ac11b978d..120911db9 100644 --- a/plinth/templates/index.html +++ b/plinth/templates/index.html @@ -56,11 +56,11 @@ {% block sidebar %} -

- {% blocktrans trimmed %} - Welcome to {{ box_name }}! - {% endblocktrans %} -

+

+ {% blocktrans trimmed %} + Welcome to {{ box_name }}! + {% endblocktrans %} +

{% blocktrans trimmed %}