summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-11-13 13:22:07 -0500
committerluxagraf <sng@luxagraf.net>2014-11-13 13:22:07 -0500
commite2f9e4ff3e3443a6875592d823e4e5739a3b7bd1 (patch)
tree8ef5055ae9ef49ffb15476838655c2f001ac50d8 /app/lib
parenta44f67ef290e120736cf881b326eb5145a3d66f7 (diff)
Turned comments back on. See how this goes.
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/templatetags/templatetags/gravatar_local.py20
-rw-r--r--app/lib/templatetags/templatetags/markdown.py9
-rw-r--r--app/lib/templatetags/templatetags/nofollow.py15
3 files changed, 44 insertions, 0 deletions
diff --git a/app/lib/templatetags/templatetags/gravatar_local.py b/app/lib/templatetags/templatetags/gravatar_local.py
new file mode 100644
index 0000000..985ed03
--- /dev/null
+++ b/app/lib/templatetags/templatetags/gravatar_local.py
@@ -0,0 +1,20 @@
+from django import template
+from django.utils.html import escape
+
+from django_gravatar.helpers import calculate_gravatar_hash
+
+# Get template.Library instance
+register = template.Library()
+
+def gravatar_hash(user_or_email):
+ if hasattr(user_or_email, 'email'):
+ email = user_or_email.email
+ else:
+ email = user_or_email
+ try:
+ #return get_gravatar_profile_url(email)
+ return calculate_gravatar_hash(email)
+ except:
+ return ''
+
+register.simple_tag(gravatar_hash)
diff --git a/app/lib/templatetags/templatetags/markdown.py b/app/lib/templatetags/templatetags/markdown.py
new file mode 100644
index 0000000..dca51f2
--- /dev/null
+++ b/app/lib/templatetags/templatetags/markdown.py
@@ -0,0 +1,9 @@
+from django import template
+import markdown2 as markdown
+
+register = template.Library()
+
+def do_markdown(text):
+ return markdown.markdown(text, safe_mode = False)
+
+register.filter('markdown', do_markdown) \ No newline at end of file
diff --git a/app/lib/templatetags/templatetags/nofollow.py b/app/lib/templatetags/templatetags/nofollow.py
new file mode 100644
index 0000000..85fc166
--- /dev/null
+++ b/app/lib/templatetags/templatetags/nofollow.py
@@ -0,0 +1,15 @@
+from django.template import Library
+import re
+
+register = Library()
+
+r_nofollow = re.compile('<a (?![^>]*nofollow)')
+s_nofollow = '<a rel="nofollow" '
+
+def nofollow(value):
+ return r_nofollow.sub(s_nofollow, value)
+
+register.filter(nofollow)
+
+
+re.compile('<a (?![^>]*rel=["\']nofollow[\'"])')