diff options
author | Michael Manfre | 2022-11-28 23:41:36 -0500 |
---|---|---|
committer | GitHub | 2022-11-28 21:41:36 -0700 |
commit | fb8f2d10984bcfa2585dc272b4c85d285b722792 (patch) | |
tree | fa9616f745c7e9e4b5cc5d1ca82d61512ee64f01 /activities/templatetags | |
parent | 7f838433edde6a03d1b7f71da269f9756a3f91e9 (diff) | |
download | takahe-fb8f2d10984bcfa2585dc272b4c85d285b722792.tar.gz takahe-fb8f2d10984bcfa2585dc272b4c85d285b722792.tar.bz2 takahe-fb8f2d10984bcfa2585dc272b4c85d285b722792.zip |
Hashtags
Diffstat (limited to 'activities/templatetags')
-rw-r--r-- | activities/templatetags/activity_tags.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activities/templatetags/activity_tags.py b/activities/templatetags/activity_tags.py index 571e2d6..fb822f6 100644 --- a/activities/templatetags/activity_tags.py +++ b/activities/templatetags/activity_tags.py @@ -3,6 +3,8 @@ import datetime from django import template from django.utils import timezone +from activities.models import Hashtag + register = template.Library() @@ -31,3 +33,14 @@ def timedeltashort(value: datetime.datetime): years = max(days // 365.25, 1) text = f"{years:0n}y" return text + + +@register.filter +def linkify_hashtags(value: str): + """ + Convert hashtags in content in to /tags/<hashtag>/ links. + """ + if not value: + return "" + + return Hashtag.linkify_hashtags(value) |