from base import Setting, SettingSet
-from django.forms.widgets import Textarea
+from django.forms.widgets import Textarea, Select
from django.utils.translation import ugettext_lazy as _
+from static import RENDER_CHOICES
+
SIDEBAR_SET = SettingSet('sidebar', 'Sidebar content', "Enter contents to display in the sidebar. You can use markdown and some basic html tags.", 10, True)
SHOW_WELCOME_BOX = Setting('SHOW_WELCOME_BOX', True, SIDEBAR_SET, dict(
help_text = " The upper sidebar block. ",
widget=Textarea(attrs={'rows': '10'})))
+SIDEBAR_UPPER_RENDER_MODE = Setting('SIDEBAR_UPPER_RENDER_MODE', 'markdown', SIDEBAR_SET, dict(
+label = _("Upper block rendering mode"),
+help_text = _("How to render your upper block code."),
+widget=Select(choices=RENDER_CHOICES),
+required=False))
+
SIDEBAR_LOWER_SHOW = Setting('SIDEBAR_LOWER_SHOW', True, SIDEBAR_SET, dict(
label = "Show Lower Block",
""", SIDEBAR_SET, dict(
label = "Lower Block Content",
help_text = " The lower sidebar block. ",
-widget=Textarea(attrs={'rows': '10'})))
\ No newline at end of file
+widget=Textarea(attrs={'rows': '10'})))
+
+SIDEBAR_LOWER_RENDER_MODE = Setting('SIDEBAR_LOWER_RENDER_MODE', 'markdown', SIDEBAR_SET, dict(
+label = _("Lower block rendering mode"),
+help_text = _("How to render your lower block code."),
+widget=Select(choices=RENDER_CHOICES),
+required=False))
\ No newline at end of file
from base import Setting, SettingSet
-from django.forms.widgets import Textarea, RadioSelect
+from django.forms.widgets import Textarea, RadioSelect, Select
from django.utils.translation import ugettext_lazy as _
+RENDER_CHOICES = (
+('markdown', _('Markdown')),
+('html', _('HTML')),
+('escape', _('Escaped'))
+)
+
STATIC_PAGE_REGISTRY = Setting('STATIC_PAGE_REGISTRY', {})
CSS_SET = SettingSet('css', 'Custom CSS', "Define some custom css you can use to override the default css.", 2000,
widget=Textarea(attrs={'rows': '25'}),
required=False))
+CUSTOM_HEADER_RENDER_MODE = Setting('CUSTOM_HEADER_RENDER_MODE', 'markdown', HEAD_AND_FOOT_SET, dict(
+ label = _("Custom Header rendering mode"),
+ help_text = _("How to render your custom header code."),
+ widget=Select(choices=RENDER_CHOICES),
+ required=False))
+
USE_ANNOUNCEMENT_BAR = Setting('USE_ANNOUNCEMENT_BAR', False, HEAD_AND_FOOT_SET, dict(
label = _("Show announcement bar"),
help_text = _("Some piece of content that goes under the search bar and can be used for announcements, etc."),
widget=Textarea(attrs={'rows': '25'}),
required=False))
+ANNOUNCEMENT_BAR_RENDER_MODE = Setting('ANNOUNCEMENT_BAR_RENDER_MODE', 'markdown', HEAD_AND_FOOT_SET, dict(
+ label = _("Announcement bar rendering mode"),
+ help_text = _("How to render your announcement bar code."),
+ widget=Select(choices=RENDER_CHOICES),
+ required=False))
+
USE_CUSTOM_FOOTER = Setting('USE_CUSTOM_FOOTER', False, HEAD_AND_FOOT_SET, dict(
label = _("Use custom footer"),
help_text = _("Do you want to use a custom footer."),
widget=Textarea(attrs={'rows': '25'}),
required=False))
+CUSTOM_FOOTER_RENDER_MODE = Setting('CUSTOM_FOOTER_RENDER_MODE', 'markdown', HEAD_AND_FOOT_SET, dict(
+ label = _("Custom footer rendering mode"),
+ help_text = _("How to render your custom footer code."),
+ widget=Select(choices=RENDER_CHOICES),
+ required=False))
+
CUSTOM_FOOTER_MODE_CHOICES = (
('replace', _('Replace default footer')),
('above', _('Above default footer')),
</script>
{% endif %}
{% if settings.USE_CUSTOM_HEAD|or_preview:request %}
- {{ settings.CUSTOM_HEAD|or_preview:request|markdown:"settingsparser" }}
+ {{ settings.CUSTOM_HEAD|or_preview:request|safe }}
{% endif %}
{% block forejs %}{% endblock %}
<link rel="search" type="application/opensearchdescription+xml" href="{% url opensearch %}" title="{{ settings.APP_SHORT_NAME }} Search" />
</div>
{% if settings.USE_CUSTOM_HEADER|or_preview:request %}
<div id="custom_header">
- {{ settings.CUSTOM_HEADER|or_preview:request|safe }}
+ {{ settings.CUSTOM_HEADER|or_preview:request|static_content:settings.CUSTOM_HEADER_RENDER_MODE }}
</div>
{% endif %}
{% include "header.html" %}
{% if settings.USE_CUSTOM_FOOTER|or_preview:request %}
{% ifequal settings.CUSTOM_FOOTER_MODE|or_preview:request "above" %}
<div id="custom_footer">
- {{ settings.CUSTOM_FOOTER|or_preview:request|markdown:"settingsparser" }}
+ {{ settings.CUSTOM_FOOTER|or_preview:request|static_content:settings.CUSTOM_FOOTER_RENDER_MODE }}
</div>
{% endifequal %}
<div id="ground">
{% ifequal settings.CUSTOM_FOOTER_MODE|or_preview:request "replace" %}
- {{ settings.CUSTOM_FOOTER|or_preview:request|markdown:"settingsparser" }}
+ {{ settings.CUSTOM_FOOTER|or_preview:request|static_content:settings.CUSTOM_FOOTER_RENDER_MODE }}
{% else %}
{% include "footer.html" %}
{% endifequal %}
</div>
{% ifequal settings.CUSTOM_FOOTER_MODE|or_preview:request "below" %}
<div id="custom_footer">
- {{ settings.CUSTOM_FOOTER|or_preview:request|markdown:"settingsparser" }}
+ {{ settings.CUSTOM_FOOTER|or_preview:request|static_content:settings.CUSTOM_FOOTER_RENDER_MODE }}
</div>
{% endifequal %}
{% else %}
{% if settings.USE_ANNOUNCEMENT_BAR|or_preview:request %}
<div id="announcement">
- {{ settings.ANNOUNCEMENT_BAR|or_preview:request|markdown:"settingsparser" }}
+ {{ settings.ANNOUNCEMENT_BAR|or_preview:request|static_content:settings.ANNOUNCEMENT_BAR_RENDER_MODE }}
</div>
{% endif %}
{% if show %}
{% if wrap %}<div id="{{ blockid }}" class="boxC">
<div class="body">{% endif %}
- {{ content|markdown }}
+ {{ content }}
{% if wrap %}</div>
</div>{% endif %}
{% endif %}
from django import template
from django.utils.safestring import mark_safe
import logging
+import markdown
register = template.Library()
@register.filter
def contained_in(item, container):
- return item in container
\ No newline at end of file
+ return item in container
+
+@register.filter
+def static_content(content, render_mode):
+ if render_mode == 'markdown':
+ return mark_safe(markdown.markdown(unicode(content), ["settingsparser"]))
+ elif render_mode == "html":
+ return mark_safe(unicode(content))
+ else:
+ return unicode(content)
\ No newline at end of file
from forum.models import Tag, Award\r
from forum import settings\r
\r
+from extra_filters import static_content\r
+\r
register = template.Library()\r
\r
@register.inclusion_tag('sidebar/markdown_help.html')\r
def sidebar_upper():\r
return {\r
'show': settings.SIDEBAR_UPPER_SHOW,\r
- 'content': settings.SIDEBAR_UPPER_TEXT,\r
+ 'content': static_content(settings.SIDEBAR_UPPER_TEXT, settings.SIDEBAR_UPPER_RENDER_MODE),\r
'wrap': not settings.SIDEBAR_UPPER_DONT_WRAP,\r
'blockid': 'sidebar-upper'\r
}\r
def sidebar_lower():\r
return {\r
'show': settings.SIDEBAR_LOWER_SHOW,\r
- 'content': settings.SIDEBAR_LOWER_TEXT,\r
+ 'content': static_content(settings.SIDEBAR_LOWER_TEXT, settings.SIDEBAR_LOWER_RENDER_MODE),\r
'wrap': not settings.SIDEBAR_LOWER_DONT_WRAP,\r
'blockid': 'sidebar-lower'\r
}\r