diff --git a/dolweb/blog/templatetags/blog_tags.py b/dolweb/blog/templatetags/blog_tags.py index 1dd8ed4b..9380e555 100644 --- a/dolweb/blog/templatetags/blog_tags.py +++ b/dolweb/blog/templatetags/blog_tags.py @@ -7,6 +7,7 @@ from bs4 import BeautifulSoup from django.conf import settings from django.template import defaultfilters +from django.urls import reverse from dolweb.blog.models import BlogSeries @register.inclusion_tag('blog_chunk_series.html') @@ -24,3 +25,10 @@ def cuthere_excerpt(content): return ''.join(map(str, reversed(cut_here.parent.find_previous_siblings()))) except AttributeError: return defaultfilters.truncatewords(content, 100) + + +@register.simple_tag +def navactive(request, urls): + if request.path in ( reverse(url) for url in urls.split() ): + return "active" + return "" diff --git a/dolweb/templates/_base.html b/dolweb/templates/_base.html index 1abf7e5d..849ccac1 100644 --- a/dolweb/templates/_base.html +++ b/dolweb/templates/_base.html @@ -1,6 +1,7 @@ {% load i18n %} {% load language %} {% load static from staticfiles %} +{% load blog_tags %} @@ -103,15 +104,33 @@