aboutsummaryrefslogtreecommitdiffstats
path: root/ryuslash/aggregator/templatetags/posts_extras.py
diff options
context:
space:
mode:
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)