mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
ikiwiki: Create and manage wikis/blogs.
This commit is contained in:
1 parent
fbce204180
commit
1464ff3184
7 files changed
+174
-10
No files matched your search
@@ -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'))
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>Wiki & Blog</h2>
|
||||
|
||||
<p>When enabled, the ikiwiki site will be available from <a href="/ikiwiki">
|
||||
/ikiwiki</a> path on the web server.</p>
|
||||
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form|bootstrap }}
|
||||
|
||||
<input type="submit" class="btn btn-primary" value="Update setup"/>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
{% endcomment %}
|
||||
|
||||
{% load bootstrap %}
|
||||
|
||||
{% block page_head %}
|
||||
<style type="text/css">
|
||||
.wiki-label {
|
||||
display: inline-block;
|
||||
width: 40%;
|
||||
}
|
||||
.list-group-item .btn {
|
||||
margin: -5px 0;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="list-group">
|
||||
{% for site in sites %}
|
||||
<div class="list-group-item clearfix">
|
||||
<a href="{% url 'ikiwiki:index' %}"
|
||||
class="btn btn-default btn-sm pull-right"
|
||||
role="button" title="Delete site {{ site }}">
|
||||
<span class="glyphicon glyphicon-trash"
|
||||
aria-hidden="true"></span>
|
||||
</a>
|
||||
|
||||
<a class="wiki-label"
|
||||
href="/ikiwiki/{{ site }}"
|
||||
title="Go to site {{ site }}">
|
||||
{{ site }}
|
||||
</a>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -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'),
|
||||
)
|
||||
@@ -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])
|
||||
Reference in new issue
Block a user