aboutsummaryrefslogtreecommitdiffstats
path: root/ryuslash/aggregator/templatetags/posts_extras.py
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-05-09 20:07:49 +0200
committerGravatar Tom Willemse2013-05-09 20:07:49 +0200
commit15c5869b54e9a770b9abbeab1e990b713cdb1b3b (patch)
tree4aa805a44e8da93f4b0698520f16096d216d8ec3 /ryuslash/aggregator/templatetags/posts_extras.py
parent5f7df695ac6dd9ccc5444a8fc20fa8d97196953e (diff)
downloadryuslash.org-15c5869b54e9a770b9abbeab1e990b713cdb1b3b.tar.gz
ryuslash.org-15c5869b54e9a770b9abbeab1e990b713cdb1b3b.zip
Update for django 1.4
Diffstat (limited to 'ryuslash/aggregator/templatetags/posts_extras.py')
-rw-r--r--ryuslash/aggregator/templatetags/posts_extras.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ryuslash/aggregator/templatetags/posts_extras.py b/ryuslash/aggregator/templatetags/posts_extras.py
new file mode 100644
index 0000000..64718a2
--- /dev/null
+++ b/ryuslash/aggregator/templatetags/posts_extras.py
@@ -0,0 +1,20 @@
+import re
+
+from django import template
+from django.template.defaultfilters import stringfilter
+
+register = template.Library()
+
+@stringfilter
+def nameless(value):
+ return re.sub(r'(^|by[- ])(ryuslash|tom)[- ]?', '', value)
+
+@stringfilter
+def truncate(value, length):
+ if len(value) > length:
+ value = value[:length-3] + '...'
+
+ return value
+
+register.filter('nameless', nameless)
+register.filter('truncate', truncate)