diff --git a/actions/ikiwiki b/actions/ikiwiki
index 5c449be53..16cadaeca 100755
--- a/actions/ikiwiki
+++ b/actions/ikiwiki
@@ -47,6 +47,9 @@ def parse_arguments():
# Disable ikiwiki site
subparsers.add_parser('disable', help='Disable ikiwiki site')
+ # Get wikis and blogs
+ subparsers.add_parser('get-sites', help='Get wikis and blogs')
+
# Create a wiki
create_wiki = subparsers.add_parser('create-wiki', help='Create a wiki')
create_wiki.add_argument('--name', help='Name of new wiki')
@@ -71,8 +74,9 @@ def subcommand_enable(_):
if not os.path.isfile(CONFIG_FILE):
setup()
+ subprocess.check_output(['a2enmod', 'cgi'])
subprocess.check_output(['a2enconf', 'ikiwiki'])
- subprocess.check_output(['service', 'apache2', 'reload'])
+ subprocess.check_output(['service', 'apache2', 'restart'])
def subcommand_disable(_):
@@ -81,6 +85,12 @@ def subcommand_disable(_):
subprocess.check_output(['service', 'apache2', 'reload'])
+def subcommand_get_sites(_):
+ """Get wikis and blogs"""
+ sites = os.listdir(WIKI_PATH)
+ print('\n'.join(sites))
+
+
def subcommand_create_wiki(arguments):
"""Create a wiki"""
subprocess.check_output(['ikiwiki', '-setup', SETUP_WIKI, arguments.name])
@@ -163,18 +173,16 @@ def setup():
' url => "/ikiwiki/$wikiname_short",\n',
' cgiurl => "/ikiwiki/$wikiname_short/ikiwiki.cgi",\n',
' cgi_wrapper => "/var/www/ikiwiki/$wikiname_short/ikiwiki.cgi",\n',
- ' add_plugins => [qw{goodstuff websetup comments blogspam calendar sidebar trail httpauth}],\n',
+ ' add_plugins => [qw{goodstuff websetup comments calendar sidebar trail httpauth}],\n',
' rss => 1,\n',
' atom => 1,\n',
' syslog => 1,\n',
'\n',
' example => "blog",\n',
' comments_pagespec => "posts/* and !*/Discussion",\n',
- ' blogspam_pagespec => "postcomment(*)",\n',
' archive_pagespec => "page(posts/*) and !*/Discussion",\n',
' global_sidebars => 0,\n',
' discussion => 0,\n',
- ' locked_pages => "* and !postcomment(*)",\n',
' tagbase => "tags",\n',
')\n',
])
diff --git a/plinth/modules/ikiwiki/forms.py b/plinth/modules/ikiwiki/forms.py
index d6eb762ba..7279ebecf 100644
--- a/plinth/modules/ikiwiki/forms.py
+++ b/plinth/modules/ikiwiki/forms.py
@@ -28,3 +28,11 @@ class IkiwikiForm(forms.Form):
enabled = forms.BooleanField(
label=_('Enable ikiwiki site'),
required=False)
+
+
+class IkiwikiCreateForm(forms.Form):
+ """Form to create a wiki or blog."""
+ type = forms.ChoiceField(
+ label=_('Type'),
+ choices=[('wiki', 'Wiki'), ('blog', 'Blog')])
+ name = forms.CharField(label=_('Name'))
diff --git a/plinth/modules/ikiwiki/templates/ikiwiki.html b/plinth/modules/ikiwiki/templates/ikiwiki.html
index 413d2a235..928f16802 100644
--- a/plinth/modules/ikiwiki/templates/ikiwiki.html
+++ b/plinth/modules/ikiwiki/templates/ikiwiki.html
@@ -22,8 +22,6 @@
{% block content %}
-
Wiki & Blog
-
When enabled, the ikiwiki site will be available from
/ikiwiki path on the web server.
diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_create.html b/plinth/modules/ikiwiki/templates/ikiwiki_create.html
new file mode 100644
index 000000000..0d75b09c3
--- /dev/null
+++ b/plinth/modules/ikiwiki/templates/ikiwiki_create.html
@@ -0,0 +1,33 @@
+{% extends "base.html" %}
+{% comment %}
+#
+# This file is part of Plinth.
+#
+# 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 %}
+
+{% block content %}
+
+
+
+{% endblock %}
diff --git a/plinth/modules/ikiwiki/templates/ikiwiki_manage.html b/plinth/modules/ikiwiki/templates/ikiwiki_manage.html
new file mode 100644
index 000000000..aa0051e59
--- /dev/null
+++ b/plinth/modules/ikiwiki/templates/ikiwiki_manage.html
@@ -0,0 +1,61 @@
+{% extends "base.html" %}
+{% comment %}
+#
+# This file is part of Plinth.
+#
+# 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 %}
+
+{% block page_head %}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+ {% for site in sites %}
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
diff --git a/plinth/modules/ikiwiki/urls.py b/plinth/modules/ikiwiki/urls.py
index eca6c5c74..749a18283 100644
--- a/plinth/modules/ikiwiki/urls.py
+++ b/plinth/modules/ikiwiki/urls.py
@@ -25,4 +25,6 @@ from django.conf.urls import patterns, url
urlpatterns = patterns(
'plinth.modules.ikiwiki.views',
url(r'^apps/ikiwiki/$', 'index', name='index'),
+ url(r'^apps/ikiwiki/manage/$', 'manage', name='manage'),
+ url(r'^apps/ikiwiki/create/$', 'create', name='create'),
)
diff --git a/plinth/modules/ikiwiki/views.py b/plinth/modules/ikiwiki/views.py
index 8c3a2ce69..6343c5286 100644
--- a/plinth/modules/ikiwiki/views.py
+++ b/plinth/modules/ikiwiki/views.py
@@ -21,17 +21,26 @@ Plinth module for configuring ikiwiki
from django.contrib import messages
from django.contrib.auth.decorators import login_required
+from django.core.urlresolvers import reverse_lazy
from django.template.response import TemplateResponse
from gettext import gettext as _
-from .forms import IkiwikiForm
+from .forms import IkiwikiForm, IkiwikiCreateForm
from plinth import actions
from plinth import package
from plinth.modules import ikiwiki
+subsubmenu = [{'url': reverse_lazy('ikiwiki:index'),
+ 'text': _('Configure')},
+ {'url': reverse_lazy('ikiwiki:manage'),
+ 'text': _('Manage')},
+ {'url': reverse_lazy('ikiwiki:create'),
+ 'text': _('Create')}]
+
+
@login_required
-@package.required(['ikiwiki'])
+@package.required(['ikiwiki', 'libcgi-formbuilder-perl', 'libcgi-session-perl'])
def index(request):
"""Serve configuration page."""
status = get_status()
@@ -48,9 +57,10 @@ def index(request):
form = IkiwikiForm(initial=status, prefix='ikiwiki')
return TemplateResponse(request, 'ikiwiki.html',
- {'title': _('Wiki'),
+ {'title': _('Wiki & Blog'),
'status': status,
- 'form': form})
+ 'form': form,
+ 'subsubmenu': subsubmenu})
def get_status():
@@ -73,3 +83,47 @@ def _apply_changes(request, old_status, new_status):
messages.success(request, _('Configuration updated'))
else:
messages.info(request, _('Setting unchanged'))
+
+
+@login_required
+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': _('Manage Wikis and Blogs'),
+ 'subsubmenu': subsubmenu,
+ 'sites': sites})
+
+
+@login_required
+def create(request):
+ """Form to create a wiki or blog."""
+ form = None
+
+ if request.method == 'POST':
+ form = IkiwikiCreateForm(request.POST, prefix='ikiwiki')
+ if form.is_valid():
+ if form.cleaned_data['type'] == 'wiki':
+ _create_wiki(request, form.cleaned_data['name'])
+ elif form.cleaned_data['type'] == 'blog':
+ _create_blog(request, form.cleaned_data['name'])
+ form = IkiwikiCreateForm(prefix='ikiwiki')
+ else:
+ form = IkiwikiCreateForm(prefix='ikiwiki')
+
+ return TemplateResponse(request, 'ikiwiki_create.html',
+ {'title': _('Create Wiki/Blog'),
+ 'form': form,
+ 'subsubmenu': subsubmenu})
+
+
+def _create_wiki(request, name):
+ """Create wiki."""
+ actions.superuser_run('ikiwiki', ['create-wiki', '--name', name])
+
+
+def _create_blog(request, name):
+ """Create blog."""
+ actions.superuser_run('ikiwiki', ['create-blog', '--name', name])