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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-10-01 19:13:00 -07:00 committed by James Valleroy
parent 1b86414488
commit 77737afadd
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
7 changed files with 56 additions and 136 deletions

View File

@ -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)

View File

@ -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 %}
<h3>{% trans "Configuration" %}</h3>
{% block diagnostics %}
{% if diagnostics_module_name %}
{% include "diagnostics_button.html" with module=diagnostics_module_name enabled=is_enabled %}
{% endif %}
{% endblock %}
<form class="form form-configuration" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Update setup" %}"/>
</form>
{% block status %}
<a href="{% url 'ikiwiki:create' %}" class="btn btn-primary"
role="button" title="{% trans 'Create Wiki or Blog' %}">
<span class="fa fa-plus" aria-hidden="true"></span>
{% trans 'Create Wiki or Blog' %}
</a>
{% endblock %}
{% block configuration %}
{{ block.super }}
<h3>{% trans "Manage Wikis and Blogs" %}</h3>
<div class="row">
<div class="col-sm-6">
{% if not sites %}
<p>{% trans "No wikis or blogs available." %}</p>
<p>
<a class="btn btn-primary btn-md"
href="{% url 'ikiwiki:create' %}">
{% trans "Create a Wiki or Blog" %}
</a>
</p>
{% else %}
<div class="list-group">
{% for site in sites %}
<div class="list-group-item clearfix">
<a href="{% url 'ikiwiki:delete' site %}"
class="btn btn-default btn-sm pull-right"
role="button"
title="{% blocktrans %}Delete site {{ site }}{% endblocktrans %}">
<span class="fa fa-trash-o"
aria-hidden="true"></span>
</a>
<a class="wiki-label" href="/ikiwiki/{{ site }}"
title="{% blocktrans %}Go to site {{ site }}{% endblocktrans %}">
{{ site }}
</a>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -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 %}
<h3>{% trans "Create Wiki or Blog" %}</h3>
<form class="form" method="post">

View File

@ -42,9 +42,6 @@
<input type="submit" class="btn btn-md btn-danger"
value="{% blocktrans %}Delete {{ name }}{% endblocktrans %}"/>
<a href="{% url 'ikiwiki:manage' %}" role="button"
class="btn btn-md btn-primary">{% trans "Cancel" %}</a>
</form>
{% endblock %}

View File

@ -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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block page_head %}
<style type="text/css">
.wiki-label {
display: inline-block;
width: 40%;
}
.list-group-item .btn {
margin: -5px 0;
}
</style>
{% endblock %}
{% block configuration %}
<h3>{% trans "Manage Wikis and Blogs" %}</h3>
<div class="row">
<div class="col-sm-6">
{% if not sites %}
<p>{% trans "No wikis or blogs available." %}</p>
<p>
<a class="btn btn-primary btn-md"
href="{% url 'ikiwiki:create' %}">
{% trans "Create a Wiki or Blog" %}
</a>
</p>
{% else %}
<div class="list-group">
{% for site in sites %}
<div class="list-group-item clearfix">
<a href="{% url 'ikiwiki:delete' site %}"
class="btn btn-default btn-sm pull-right"
role="button"
title="{% blocktrans %}Delete site {{ site }}{% endblocktrans %}">
<span class="fa fa-trash-o"
aria-hidden="true"></span>
</a>
<a class="wiki-label" href="/ikiwiki/{{ site }}"
title="{% blocktrans %}Go to site {{ site }}{% endblocktrans %}">
{{ site }}
</a>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@ -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<name>[\w.@+-]+)/delete/$', views.delete,
name='delete'),
url(r'^apps/ikiwiki/create/$', views.create, name='create'),

View File

@ -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,