aboutsummaryrefslogtreecommitdiffstats
path: root/tools/templatetags
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-24 16:39:42 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-24 16:39:42 +0800
commited3d74e61300f91818eeff9dad7e9d35c556f75a (patch)
tree62c96fd6e158068567eebb5072406911e99db47d /tools/templatetags
parenta64eb136b0d8710ff132551f149a39b3a45da1f9 (diff)
downloaddjango-skaschool-ed3d74e61300f91818eeff9dad7e9d35c556f75a.tar.bz2
Added app schedule, tools and archive/templatetags; updated settings.
* Added app 'schedule' to provides a more generic schedule page * Added fake app 'tools' to holds generic utilities * Moved notice/templatetags to tools/templatetags * Small change to archive.models.Archive display format * Added archive/templatetags * Small update to introduction page
Diffstat (limited to 'tools/templatetags')
-rw-r--r--tools/templatetags/__init__.py0
-rw-r--r--tools/templatetags/my_markdown.py26
2 files changed, 26 insertions, 0 deletions
diff --git a/tools/templatetags/__init__.py b/tools/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/templatetags/__init__.py
diff --git a/tools/templatetags/my_markdown.py b/tools/templatetags/my_markdown.py
new file mode 100644
index 0000000..842f72f
--- /dev/null
+++ b/tools/templatetags/my_markdown.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+
+"""
+implement my own 'markdown' template tag
+requires 'python-markdown' (pip install markdown)
+"""
+# ref: http://www.dominicrodger.com/django-markdown.html
+
+import markdown
+
+from django import template
+from django.template.defaultfilters import stringfilter
+from django.utils.encoding import force_unicode
+from django.utils.safestring import mark_safe
+
+register = template.Library()
+
+@register.filter(is_safe=True)
+@stringfilter
+def my_markdown(value):
+ extensions = ["nl2br", ]
+
+ return mark_safe(markdown.markdown(force_unicode(value),
+ extensions,
+ safe_mode=True,
+ enable_attributes=False))