CREATE_MISSING_ARTICLE and document settings
This commit is contained in:
parent
39b59fd0f6
commit
18c1dae495
50
README.rst
50
README.rst
@ -21,9 +21,22 @@ libraries for whichever markup options you wish to include.
|
||||
Settings
|
||||
========
|
||||
|
||||
To best make use of MarkupField you should define the
|
||||
``MARKUPWIKI_MARKUP_TYPES`` setting, a dictionary of strings to callables that
|
||||
'render' a markup type::
|
||||
|
||||
``MARKUPWIKI_WRITE_LOCK_SECONDS`` - number of seconds that a user can hold a
|
||||
write lock (default: 300)
|
||||
|
||||
``MARKUPWIKI_CREATE_MISSING_ARTICLES`` - if True when attempting to go to an
|
||||
article that doesn't exist, user will be redirected to the /edit/ page. If
|
||||
False user will get a 404.
|
||||
|
||||
``MARKUPWIKI_DEFAULT_MARKUP_TYPE`` - default markup type to use
|
||||
(default: markdown)
|
||||
|
||||
``MARKUPWIKI_MARKUP_TYPE_EDITABLE`` - if False user won't have option to change
|
||||
markup type (default: True)
|
||||
|
||||
``MARKUPWIKI_MARKUP_TYPES`` - a tuple of string and callable pairs the
|
||||
callable is used to 'render' a markup type. Example::
|
||||
|
||||
import markdown
|
||||
from docutils.core import publish_parts
|
||||
@ -32,30 +45,7 @@ To best make use of MarkupField you should define the
|
||||
parts = publish_parts(source=markup, writer_name="html4css1")
|
||||
return parts["fragment"]
|
||||
|
||||
MARKUPWIKI_MARKUP_TYPES = {
|
||||
'markdown': markdown.markdown,
|
||||
'ReST': render_rest,
|
||||
}
|
||||
|
||||
If you do not define a ``MARKUPWIKI_MARKUP_TYPES`` then one is provided with the
|
||||
following markup types available:
|
||||
|
||||
html:
|
||||
allows HTML, potentially unsafe
|
||||
plain:
|
||||
plain text markup, calls urlize and replaces text with linebreaks
|
||||
markdown:
|
||||
default `markdown`_ renderer (only if `python-markdown`_ is installed)
|
||||
restructuredtext:
|
||||
default `ReST`_ renderer (only if `docutils`_ is installed)
|
||||
textile:
|
||||
default `textile`_ renderer (only if `textile`_ is installed)
|
||||
|
||||
.. _`markdown`: http://daringfireball.net/projects/markdown/
|
||||
.. _`ReST`: http://docutils.sourceforge.net/rst.html
|
||||
.. _`textile`: http://hobix.com/textile/quick.html
|
||||
.. _`python-markdown`: http://www.freewisdom.org/projects/python-markdown/
|
||||
.. _`docutils`: http://docutils.sourceforge.net/
|
||||
.. _`python-textile`: http://pypi.python.org/pypi/textile
|
||||
|
||||
|
||||
MARKUPWIKI_MARKUP_TYPES = (
|
||||
('markdown', markdown.markdown),
|
||||
('ReST', render_rest)
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ from markupfield import markup
|
||||
from markupwiki.utils import wikify_markup_wrapper
|
||||
|
||||
DEFAULT_MARKUP_TYPE = getattr(settings, 'MARKUPWIKI_DEFAULT_MARKUP_TYPE', 'markdown')
|
||||
WRITE_LOCK_SECONDS = getattr(settings, 'MARKUPWIKI_WRITE_LOCK_SECONDS', 60)
|
||||
WRITE_LOCK_SECONDS = getattr(settings, 'MARKUPWIKI_WRITE_LOCK_SECONDS', 300)
|
||||
MARKUP_TYPES = getattr(settings, 'MARKUPWIKI_MARKUP_TYPES', markup.DEFAULT_MARKUP_TYPES)
|
||||
|
||||
# add make_wiki_links to MARKUP_TYPES
|
||||
|
@ -1,14 +1,18 @@
|
||||
from difflib import HtmlDiff
|
||||
from django.shortcuts import get_object_or_404, render_to_response, redirect
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.conf import settings
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||
from django.contrib import messages
|
||||
from django.http import Http404
|
||||
from django.template import RequestContext
|
||||
from django.utils.functional import wraps
|
||||
from markupwiki.models import Article, PUBLIC, DELETED, LOCKED
|
||||
from markupwiki.forms import ArticleForm, StaffModerationForm, ArticleRenameForm
|
||||
|
||||
CREATE_MISSING_ARTICLE = getattr(settings, 'MARKUPWIKI_CREATE_MISSING_ARTICLES', False)
|
||||
|
||||
def title_check(view):
|
||||
def new_view(request, title, *args, **kwargs):
|
||||
newtitle = title.replace(' ', '_')
|
||||
@ -39,7 +43,10 @@ def view_article(request, title, n=None):
|
||||
try:
|
||||
article = Article.objects.get(title=title)
|
||||
except Article.DoesNotExist:
|
||||
return redirect('edit_article', title)
|
||||
if CREATE_MISSING_ARTICLE:
|
||||
return redirect('edit_article', title)
|
||||
else:
|
||||
raise Http404()
|
||||
|
||||
if article.redirect_to_id:
|
||||
return redirect(article.redirect_to)
|
||||
|
Loading…
Reference in New Issue
Block a user