From 77737afaddd5754cf8b33fc883639b6c4af060c9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 1 Oct 2019 19:13:00 -0700 Subject: [PATCH] ikiwiki: Remove subsubmenu in favor of toolbar - Merge managing table into the index page. - Remove separate URL/view/template for manage. - Convert create tab into a toolbar button. - Remove cancel button from delete confirmation page. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- functional_tests/support/application.py | 3 - .../ikiwiki/templates/ikiwiki_configure.html | 65 ++++++++++++----- .../ikiwiki/templates/ikiwiki_create.html | 4 +- .../ikiwiki/templates/ikiwiki_delete.html | 3 - .../ikiwiki/templates/ikiwiki_manage.html | 72 ------------------- plinth/modules/ikiwiki/urls.py | 1 - plinth/modules/ikiwiki/views.py | 44 +++--------- 7 files changed, 56 insertions(+), 136 deletions(-) delete mode 100644 plinth/modules/ikiwiki/templates/ikiwiki_manage.html diff --git a/functional_tests/support/application.py b/functional_tests/support/application.py index 758240fac..76d9714bf 100644 --- a/functional_tests/support/application.py +++ b/functional_tests/support/application.py @@ -322,7 +322,6 @@ def ejabberd_has_contact(browser): def ikiwiki_create_wiki_if_needed(browser): """Create wiki if it does not exist.""" interface.nav_to_module(browser, 'ikiwiki') - browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() wiki = browser.find_link_by_href('/ikiwiki/wiki') if not wiki: browser.find_link_by_href('/plinth/apps/ikiwiki/create/').first.click() @@ -337,7 +336,6 @@ def ikiwiki_create_wiki_if_needed(browser): def ikiwiki_delete_wiki(browser): """Delete wiki.""" interface.nav_to_module(browser, 'ikiwiki') - browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() browser.find_link_by_href( '/plinth/apps/ikiwiki/wiki/delete/').first.click() submit(browser) @@ -346,7 +344,6 @@ def ikiwiki_delete_wiki(browser): def ikiwiki_wiki_exists(browser): """Check whether the wiki exists.""" interface.nav_to_module(browser, 'ikiwiki') - browser.find_link_by_href('/plinth/apps/ikiwiki/manage/').first.click() wiki = browser.find_link_by_href('/ikiwiki/wiki') return bool(wiki) diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_configure.html b/plinth/modules/ikiwiki/templates/ikiwiki_configure.html index 56ce04cff..fa822d24f 100644 --- a/plinth/modules/ikiwiki/templates/ikiwiki_configure.html +++ b/plinth/modules/ikiwiki/templates/ikiwiki_configure.html @@ -1,4 +1,4 @@ -{% extends "app-subsubmenu.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of FreedomBox. @@ -21,22 +21,49 @@ {% load bootstrap %} {% load i18n %} -{% block configuration %} -

{% trans "Configuration" %}

- - {% block diagnostics %} - {% if diagnostics_module_name %} - {% include "diagnostics_button.html" with module=diagnostics_module_name enabled=is_enabled %} - {% endif %} - {% endblock %} - -
- {% csrf_token %} - - {{ form|bootstrap }} - - -
- +{% block status %} + + + {% trans 'Create Wiki or Blog' %} + +{% endblock %} + +{% block configuration %} + {{ block.super }} + +

{% trans "Manage Wikis and Blogs" %}

+ +
+
+ {% if not sites %} +

{% trans "No wikis or blogs available." %}

+

+ + {% trans "Create a Wiki or Blog" %} + +

+ {% else %} +
+ {% for site in sites %} + + {% endfor %} +
+ {% endif %} +
+
{% endblock %} diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_create.html b/plinth/modules/ikiwiki/templates/ikiwiki_create.html index 35d1839c0..f86e8c664 100644 --- a/plinth/modules/ikiwiki/templates/ikiwiki_create.html +++ b/plinth/modules/ikiwiki/templates/ikiwiki_create.html @@ -1,4 +1,4 @@ -{% extends "app-subsubmenu.html" %} +{% extends "base.html" %} {% comment %} # # This file is part of FreedomBox. @@ -21,7 +21,7 @@ {% load bootstrap %} {% load i18n %} -{% block configuration %} +{% block content %}

{% trans "Create Wiki or Blog" %}

diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_delete.html b/plinth/modules/ikiwiki/templates/ikiwiki_delete.html index 29cf22826..467768c0c 100644 --- a/plinth/modules/ikiwiki/templates/ikiwiki_delete.html +++ b/plinth/modules/ikiwiki/templates/ikiwiki_delete.html @@ -42,9 +42,6 @@ - - {% trans "Cancel" %}
{% endblock %} diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_manage.html b/plinth/modules/ikiwiki/templates/ikiwiki_manage.html deleted file mode 100644 index 00c3881e1..000000000 --- a/plinth/modules/ikiwiki/templates/ikiwiki_manage.html +++ /dev/null @@ -1,72 +0,0 @@ -{% extends "app-subsubmenu.html" %} -{% comment %} -# -# This file is part of FreedomBox. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} - -{% block page_head %} - -{% endblock %} - -{% block configuration %} -

{% trans "Manage Wikis and Blogs" %}

- -
-
- {% if not sites %} -

{% trans "No wikis or blogs available." %}

-

- - {% trans "Create a Wiki or Blog" %} - -

- {% else %} -
- {% for site in sites %} - - {% endfor %} -
- {% endif %} -
-
- -{% endblock %} diff --git a/plinth/modules/ikiwiki/urls.py b/plinth/modules/ikiwiki/urls.py index 57bed0f7f..cd66d97f5 100644 --- a/plinth/modules/ikiwiki/urls.py +++ b/plinth/modules/ikiwiki/urls.py @@ -24,7 +24,6 @@ from . import views urlpatterns = [ url(r'^apps/ikiwiki/$', views.IkiwikiAppView.as_view(), name='index'), - url(r'^apps/ikiwiki/manage/$', views.manage, name='manage'), url(r'^apps/ikiwiki/(?P[\w.@+-]+)/delete/$', views.delete, name='delete'), url(r'^apps/ikiwiki/create/$', views.create, name='create'), diff --git a/plinth/modules/ikiwiki/views.py b/plinth/modules/ikiwiki/views.py index e230aae4c..bddc53a41 100644 --- a/plinth/modules/ikiwiki/views.py +++ b/plinth/modules/ikiwiki/views.py @@ -23,24 +23,12 @@ from django.shortcuts import redirect from django.template.response import TemplateResponse from django.urls import reverse_lazy from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_lazy from plinth import actions, views from plinth.modules import ikiwiki from .forms import IkiwikiCreateForm -subsubmenu = [{ - 'url': reverse_lazy('ikiwiki:index'), - 'text': ugettext_lazy('Configure') -}, { - 'url': reverse_lazy('ikiwiki:manage'), - 'text': ugettext_lazy('Manage') -}, { - 'url': reverse_lazy('ikiwiki:create'), - 'text': ugettext_lazy('Create') -}] - class IkiwikiAppView(views.AppView): """Serve configuration page.""" @@ -50,34 +38,19 @@ class IkiwikiAppView(views.AppView): diagnostics_module_name = 'ikiwiki' show_status_block = False template_name = 'ikiwiki_configure.html' + manual_page = ikiwiki.manual_page + clients = ikiwiki.clients def get_context_data(self, **kwargs): """Return the context data for rendering the template view.""" + sites = actions.run('ikiwiki', ['get-sites']).split('\n') + sites = [name for name in sites if name != ''] + context = super().get_context_data(**kwargs) - context['title'] = ikiwiki.name - context['subsubmenu'] = subsubmenu - context['clients'] = ikiwiki.clients - context['manual_page'] = ikiwiki.manual_page + context['sites'] = sites return context -def manage(request): - """Manage existing wikis and blogs.""" - sites = actions.run('ikiwiki', ['get-sites']).split('\n') - sites = [name for name in sites if name != ''] - - return TemplateResponse( - request, 'ikiwiki_manage.html', { - 'title': ikiwiki.name, - 'clients': ikiwiki.clients, - 'description': ikiwiki.description, - 'manual_page': ikiwiki.manual_page, - 'subsubmenu': subsubmenu, - 'sites': sites, - 'is_enabled': ikiwiki.app.is_enabled(), - }) - - def create(request): """Form to create a wiki or blog.""" form = None @@ -98,7 +71,7 @@ def create(request): shortcut = ikiwiki.app.add_shortcut(site) shortcut.enable() - return redirect(reverse_lazy('ikiwiki:manage')) + return redirect(reverse_lazy('ikiwiki:index')) else: form = IkiwikiCreateForm(prefix='ikiwiki') @@ -109,7 +82,6 @@ def create(request): 'description': ikiwiki.description, 'form': form, 'manual_page': ikiwiki.manual_page, - 'subsubmenu': subsubmenu, 'is_enabled': ikiwiki.app.is_enabled(), }) @@ -157,7 +129,7 @@ def delete(request, name): _('Could not delete {name}: {error}').format( name=name, error=error)) - return redirect(reverse_lazy('ikiwiki:manage')) + return redirect(reverse_lazy('ikiwiki:index')) return TemplateResponse(request, 'ikiwiki_delete.html', { 'title': ikiwiki.name,