Commit 495d70ee by benjaoming

Adding a couple of new settings that are not fully implemented yet. Do not let…

Adding a couple of new settings that are not fully implemented yet. Do not let MARKDOWN_EXTENSIONS be a callable since the markdown_instance already has an article property accessible to any extension that wants it.
parent 9392b2f6
......@@ -13,23 +13,7 @@ WIKI_LANGUAGE = 'markdown'
# extend the built-in editor and customize it....
EDITOR = getattr(django_settings, 'WIKI_EDITOR', 'wiki.editors.markitup.MarkItUp')
# If you want to write an extension, you should use the plugin API as you
# will get an article model instance to play with. These are just the
# builtin markdown extensions
# Notice that this should be a callable which accepts the article as an argument
def get_extensions(article):
from wiki.models import URLPath
try:
urlpath = URLPath.objects.get(article=article)
url = reverse_lazy('wiki:get', kwargs={'path': urlpath.path})
except URLPath.DoesNotExist:
url = reverse_lazy('wiki:get', kwargs={'article_id': article.id})
return ['extra', 'wikilinks(base_url=%s)' % url, 'codehilite', 'toc']
MARKDOWN_EXTENSIONS = getattr(
django_settings,
'WIKI_MARKDOWN_EXTENSIONS',
get_extensions
)
MARKDOWN_EXTENSIONS = getattr(django_settings, 'WIKI_MARKDOWN_EXTENSIONS', ['extra', 'toc'])
# This slug is used in URLPath if an article has been deleted. The children of the
# URLPath of that article are moved to lost and found. They keep their permissions
......@@ -40,6 +24,34 @@ LOST_AND_FOUND_SLUG = getattr(django_settings, 'WIKI_LOST_AND_FOUND_SLUG', 'lost
LOG_IPS_ANONYMOUS = getattr(django_settings, 'WIKI_LOG_IPS_ANONYMOUS', True)
LOG_IPS_USERS = getattr(django_settings, 'WIKI_LOG_IPS_USERS', False)
####################################
# PERMISSIONS AND ACCOUNT HANDLING #
####################################
# A function returning True/False if a user has permission to assign
# permissions on an article
# Relevance: changing owner and group membership
CAN_ASSIGN = getattr(django_settings, 'WIKI_CAN_ASSIGN', lambda article, user: user.has_perm('wiki.assign'))
# A function returning True/False if a user has permission to change
# read/write access for groups and others
CAN_CHANGE_PERMISSIONS = getattr(django_settings, 'WIKI_CAN_CHANGE_PERMISSIONS', lambda article, user: article.owner == user or user.has_perm('wiki.assign'))
# A function returning True/False if a user has permission to change
# moderate, ie. lock articles and permanently delete content.
CAN_MODERATE = getattr(django_settings, 'WIKI_CAN_MODERATE', lambda article, user: user.has_perm('wiki.moderate'))
# A function returning True/False if a user has permission to create
# new groups and users for the wiki.
CAN_ADMIN = getattr(django_settings, 'WIKI_CAN_ADMIN', lambda article, user: user.has_perm('wiki.admin'))
# Treat anonymous (non logged in) users as the "other" user group
ANONYMOUS = getattr(django_settings, 'WIKI_ANONYMOUS', True)
# Globally enable write access for anonymous users, if true anonymous users will be treated
# as the others_write boolean field on models.Article.
ANONYMOUS_WRITE = getattr(django_settings, 'WIKI_ANONYMOUS_WRITE', False)
# Sign up, login and logout views should be accessible
ACCOUNT_HANDLING = getattr(django_settings, 'WIKI_ACCOUNT_HANDLING', True)
......@@ -48,11 +60,17 @@ if ACCOUNT_HANDLING:
else:
LOGIN_URL = getattr(django_settings, "LOGIN_URL", "/")
##################
# OTHER SETTINGS #
##################
# Maximum amount of children to display in a menu before going "+more"
# NEVER set this to 0 as it will wrongly inform the user that there are no
# children and for instance that an article can be safely deleted.
SHOW_MAX_CHILDREN = getattr(django_settings, 'WIKI_SHOW_MAX_CHILDREN', 20)
####################
# PLANNED SETTINGS #
####################
......@@ -65,13 +83,3 @@ MAX_REVISION_AGE = getattr(django_settings, 'MAX_REVISION_AGE', 365)
# Maximum allowed revisions per minute for any given user or IP
REVISIONS_PER_MINUTE = getattr(django_settings, 'WIKI_REVISIONS_PER_MINUTE', 3)
# Allow others to upload
UPLOAD_OTHERS = getattr(django_settings, 'WIKI_UPLOAD_OTHERS', True)
# Treat anonymous (non logged in) users as the "other" user group
ANONYMOUS = getattr(django_settings, 'WIKI_ANONYMOUS', True)
# Globally enable write access for anonymous users, if true anonymous users will be treated
# as the others_write boolean field on models.Article.
ANONYMOUS_WRITE = getattr(django_settings, 'WIKI_ANONYMOUS_WRITE', False)
......@@ -161,7 +161,7 @@ class Article(models.Model):
else:
content = self.current_revision.content
extensions = plugin_registry.get_markdown_extensions()
extensions += settings.MARKDOWN_EXTENSIONS(self)
extensions += settings.MARKDOWN_EXTENSIONS
return mark_safe(article_markdown(content, self, extensions=extensions))
......
......@@ -40,7 +40,7 @@ class Image(RevisionPlugin):
def __unicode__(self):
title = (_(u'Image: %s') % self.current_revision.imagerevision.get_filename()) if self.current_revision else _(u'Current revision not set!!')
return unicode(title)
return title
class ImageRevision(RevisionPluginRevision):
......@@ -90,3 +90,6 @@ class ImageRevision(RevisionPluginRevision):
verbose_name_plural = _(u'image revisions')
app_label = settings.APP_LABEL
ordering = ('-created',)
def __unicode__(self):
return _(u'Image Revsion: %d') % self.revision_number
......@@ -29,7 +29,7 @@ function insert_image(image_id) {
<p>
<a href="javascript:void(insert_image({{ image.id }}))"><span class="icon-edit"></span> {% trans "Insert" %}</a><br />
{% if image|can_write:user %}
<a href="{% url 'wiki:images_add_revision' path=urlpath.path article_id=article.id image_id=image.id %}"><span class="icon-edit"></span> {% trans "Replace" %}</a>
<a href="{% url 'wiki:images_add_revision' path=urlpath.path article_id=article.id image_id=image.id %}"><span class="icon-upload"></span> {% trans "Replace" %}</a>
{% endif %}
</p>
</td>
......
......@@ -25,7 +25,7 @@
#article_edit_form label {max-width: 100px;}
#article_edit_form .controls {margin-left: 120px;}
.form-horizontal label { font-size: 18px; font-weight: bold; color: #777;}
.form-horizontal label { font-size: 16px; font-weight: normal; color: #777;}
.settings-form label {min-width: 250px; font-size: inherit; font-weight: normal;}
.settings-form .controls {margin-left: 270px;}
......
......@@ -17,4 +17,10 @@
{% if revision.previous_revision.deleted and not revision.deleted %}
<span class="badge badge-success">{% trans "restored" %}</span>
{% endif %}
{% if revision.locked %}
<span class="badge">{% trans "locked" %}</span>
{% endif %}
{% if revision.previous_revision.locked and not revision.locked %}
<span class="badge">{% trans "unlocked" %}</span>
{% endif %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment