From fb8f2d10984bcfa2585dc272b4c85d285b722792 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Mon, 28 Nov 2022 23:41:36 -0500 Subject: Hashtags --- activities/templatetags/activity_tags.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activities/templatetags') 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// links. + """ + if not value: + return "" + + return Hashtag.linkify_hashtags(value) -- cgit v1.2.3