Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

bunch of improvements #2

Merged
merged 4 commits into from Aug 10, 2011
View
@@ -3,27 +3,42 @@ Djiki
Djiki is a lightweight, portable Wiki engine based on Django.
Features:
- * Creole markup,
- * anonymous and registered edits,
- * automatic merges of parallel edits when possible,
- * inclusion of images,
- * diff views between revisions,
- * reverts to any revision in the history,
- * automatic undos of any historical revision, if possible.
+
+* Creole markup,
+* anonymous and registered edits,
+* automatic merges of parallel edits when possible,
+* inclusion of images,
+* diff views between revisions,
+* reverts to any revision in the history,
+* automatic undos of any historical revision, if possible.
Requirements
------------
+* google-diff-match-patch:
+ http://code.google.com/p/google-diff-match-patch/
+
+* WikiCreole parser in Python:
+ http://oink.sheep.art.pl/WikiCreole%20parser%20in%20python
+
+* sorl-thumbnail:
+ *It is used in the example templates, but you may run djiki
+ with any other thumbnailing module or without one at all.*
+ https://github.com/sorl/sorl-thumbnail
- * google-diff-match-patch:
- http://code.google.com/p/google-diff-match-patch/
+Usage
+-----
+* Add 'djiki' and 'sorl.thumbnail' to your INSTALLED_APPS setting.
+* Run './manage.py syncdb' in your project.
+* Add the following to your URLconf::
- * WikiCreole parser in Python:
- http://oink.sheep.art.pl/WikiCreole%20parser%20in%20python
+ (r'wiki/', include('djiki.urls')),
- * sorl-thumbnail:
- *It is used in the example templates, but you may run djiki
- with any other thumbnailing module or without one at all.*
- https://github.com/sorl/sorl-thumbnail
+* Add the required setting DJIKI_IMAGES_PATH
+* Create a 'base.html' that Djiki expects to exist and acts as a base template
+ for all the wiki pages. It must have a 'page' block. Alternatively, supply
+ your own 'djiki/base.html' that overrides the supplied template.
+* Optionally include/add the provided CSS in media/css/styles.css to your page
+ template.
Settings
--------
@@ -33,14 +48,14 @@ The following settings configure Djiki's behavior:
``DJIKI_IMAGES_PATH`` — path to images, relative to MEDIA_ROOT.
``DJIKI_ALLOW_ANONYMOUS_EDITS`` — whether unauthorized users are
-able to edit pages.
+able to edit pages. Defaults to True.
``DJIKI_SPACES_AS_UNDERSCORES`` — makes Djiki replace whitespaces in
URLs by underscores. It's a choice between having nice or exact URLs.
Depending on the settings, the adresses may look as
``http://djiki.org/wiki/Main_Page`` or ``http://djiki.org/wiki/Main%20Page``
This setting will also squash multiple spaces into one. It affects image
-names in the same way, too.
+names in the same way, too. Defaults to True.
Images
------
@@ -54,7 +69,7 @@ still valid, however you may add size by typing
Roadmap
-------
- * ACLs: block anonymous edits, limit access to groups
- * more markup backends; MediaWiki is the main priority
- * page operations: rename, delete
- * translations
+* ACLs: block anonymous edits, limit access to groups
+* more markup backends; MediaWiki is the main priority
+* page operations: rename, delete
+* translations
View
@@ -1,13 +1,16 @@
import re
from django.conf import settings
+def spaces_as_underscores():
+ return getattr(settings, 'DJIKI_SPACES_AS_UNDERSCORES', True)
+
def urlize_title(title):
- if settings.DJIKI_SPACES_AS_UNDERSCORES:
+ if spaces_as_underscores():
return re.sub(r'\s+', '_', title)
return title
def deurlize_title(title):
- if settings.DJIKI_SPACES_AS_UNDERSCORES:
+ if spaces_as_underscores():
return re.sub(r'[_\s]+', ' ', title)
return title
View
@@ -6,10 +6,15 @@
from django.shortcuts import get_object_or_404
from django.template import RequestContext, loader
from django.utils.translation import ugettext as _
+from django.utils.safestring import mark_safe
from django.views.generic.simple import direct_to_template
from urllib import urlencode, quote
from . import models, forms, utils
+
+def allow_anonymous_edits():
+ return getattr(settings, 'DJIKI_ALLOW_ANONYMOUS_EDITS', True)
+
def view(request, title, revision_pk=None):
url_title = utils.urlize_title(title)
if title != url_title:
@@ -29,11 +34,11 @@ def view(request, title, revision_pk=None):
revision = page.revisions.get(pk=revision_pk)
except models.PageRevision.DoesNotExist:
return HttpResponseNotFound()
- messages.info(request, _("The version you are viewing is not the latest one, "
+ messages.info(request, mark_safe(_("The version you are viewing is not the latest one, "
"but represents an older revision of this page, which may have been "
"significantly modified. If it is not what you intended to view, "
"<a href=\"%(url)s\">proceed to the latest version</a>.") % {
- 'url': reverse('djiki-page-view', kwargs={'title': url_title})})
+ 'url': reverse('djiki-page-view', kwargs={'title': url_title})}))
else:
revision = page.last_revision()
if request.REQUEST.get('raw', ''):
@@ -45,7 +50,7 @@ def view(request, title, revision_pk=None):
{'page': page, 'revision': revision})
def edit(request, title):
- if not settings.DJIKI_ALLOW_ANONYMOUS_EDITS and not request.user.is_authenticated():
+ if not allow_anonymous_edits() and not request.user.is_authenticated():
return HttpResponseForbidden()
url_title = utils.urlize_title(title)
if title != url_title:
@@ -68,10 +73,10 @@ def edit(request, title):
if form.is_valid():
if is_preview:
preview_content = form.cleaned_data.get('content', form.data['content'])
- messages.info(request, _("The content you see on this page is shown only as "
+ messages.info(request, mark_safe(_("The content you see on this page is shown only as "
"a preview. <strong>No changes have been saved yet.</strong> Please "
"review the modifications and use the <em>Save</em> button to store "
- "them permanently."))
+ "them permanently.")))
else:
form.save()
return HttpResponseRedirect(
@@ -105,7 +110,7 @@ def diff(request, title):
{'page': page, 'from_revision': from_rev, 'to_revision': to_rev, 'diff': diff})
def revert(request, title, revision_pk):
- if not settings.DJIKI_ALLOW_ANONYMOUS_EDITS and not request.user.is_authenticated():
+ if not allow_anonymous_edits() and not request.user.is_authenticated():
return HttpResponseForbidden()
url_title = utils.urlize_title(title)
if title != url_title:
@@ -134,7 +139,7 @@ def revert(request, title, revision_pk):
{'page': page, 'form': form, 'src_revision': src_revision})
def undo(request, title, revision_pk):
- if not settings.DJIKI_ALLOW_ANONYMOUS_EDITS and not request.user.is_authenticated():
+ if not allow_anonymous_edits() and not request.user.is_authenticated():
return HttpResponseForbidden()
url_title = utils.urlize_title(title)
if title != url_title:
@@ -183,7 +188,7 @@ def undo(request, title, revision_pk):
return direct_to_template(request, 'djiki/edit.html', {'page': page, 'form': form})
def image_new(request):
- if not settings.DJIKI_ALLOW_ANONYMOUS_EDITS and not request.user.is_authenticated():
+ if not allow_anonymous_edits() and not request.user.is_authenticated():
return HttpResponseForbidden()
form = forms.NewImageUploadForm(data=request.POST or None, files=request.FILES or None)
if request.method == 'POST':
@@ -202,7 +207,7 @@ def image_view(request, name):
return direct_to_template(request, 'djiki/image_view.html', {'image': image})
def image_edit(request, name):
- if not settings.DJIKI_ALLOW_ANONYMOUS_EDITS and not request.user.is_authenticated():
+ if not allow_anonymous_edits() and not request.user.is_authenticated():
return HttpResponseForbidden()
url_name = utils.urlize_title(name)
if name != url_name:
View
@@ -30,7 +30,7 @@
<div class="grid_12">
<ul>
{% for msg in messages %}
- <li class="{{ msg.tags }}">{{ msg|safe }}</li>
+ <li class="{{ msg.tags }}">{{ msg }}</li>
{% endfor %}
</ul>
</div>