more wiki-like

* handle [[wiki style]] links
* adjust markuptypes based on new 1.0.0b functionality
* replace _ in names with ' ' on display
This commit is contained in:
James Turk 2010-04-02 17:40:56 -04:00
parent fde627eda0
commit 7262e392b6
4 changed files with 17 additions and 8 deletions

View File

@ -14,15 +14,15 @@ might not be for you.
Requirements
------------
django-markupwiki depends on django 1.2+, django-markupfield and libraries
for whichever markup options you wish to include.
django-markupwiki depends on django 1.2+, django-markupfield 1.0.0b+ and
libraries for whichever markup options you wish to include.
Settings
========
To best make use of MarkupField you should define the
``MARKUP_FIELD_TYPES`` setting, a dictionary of strings to callables that
``MARKUPWIKI_MARKUP_TYPES`` setting, a dictionary of strings to callables that
'render' a markup type::
import markdown
@ -32,12 +32,12 @@ To best make use of MarkupField you should define the
parts = publish_parts(source=markup, writer_name="html4css1")
return parts["fragment"]
MARKUP_FIELD_TYPES = {
MARKUPWIKI_MARKUP_TYPES = {
'markdown': markdown.markdown,
'ReST': render_rest,
}
If you do not define a ``MARKUP_FIELD_TYPES`` then one is provided with the
If you do not define a ``MARKUPWIKI_MARKUP_TYPES`` then one is provided with the
following markup types available:
html:

View File

@ -5,9 +5,17 @@ from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.urlresolvers import reverse
from markupfield.fields import MarkupField
from markupfield import markup
from markupwiki.utils import wikify_markup_wrapper
DEFAULT_MARKUP_TYPE = getattr(settings, 'MARKUPWIKI_DEFAULT_MARKUP_TYPE', 'plain')
WRITE_LOCK_SECONDS = getattr(settings, 'MARKUPWIKI_WRITE_LOCK_SECONDS', 60)
MARKUP_TYPES = getattr(settings, 'MARKUPWIKI_MARKUP_TYPES', markup.DEFAULT_MARKUP_TYPES)
# add make_wiki_links to MARKUP_TYPES
WIKI_MARKUP_TYPES = []
for name, func in MARKUP_TYPES:
WIKI_MARKUP_TYPES.append((name, wikify_markup_wrapper(func)))
PUBLIC, LOCKED, DELETED = range(3)
ARTICLE_STATUSES = (
@ -58,7 +66,8 @@ class ArticleVersion(models.Model):
article = models.ForeignKey(Article, related_name='versions')
author = models.ForeignKey(User, related_name='article_versions')
number = models.PositiveIntegerField()
body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE)
body = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
markup_choices=WIKI_MARKUP_TYPES)
comment = models.CharField(max_length=200, blank=True)
timestamp = models.DateTimeField(auto_now_add=True)

View File

@ -1,6 +1,6 @@
from django.conf.urls.defaults import *
WIKI_REGEX = r'^(?P<title>[\w\s]+)'
WIKI_REGEX = r'^(?P<title>[^/]+)'
urlpatterns = patterns('markupwiki.views',
url(WIKI_REGEX + '/$', 'view_article', name='view_article'),

View File

@ -50,7 +50,7 @@ def view_article(request, title, n=None):
version = article.versions.latest()
version.is_latest = True
# display title
# change article for display
article.title = article.title.replace('_', ' ')
# set editable flag on article