Skip to content

Commit

Permalink
highlight active nav item
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Davids authored and Peter Davids committed Mar 22, 2020
1 parent 79f4823 commit 13eed17
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
8 changes: 8 additions & 0 deletions dolweb/blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 ""
37 changes: 28 additions & 9 deletions dolweb/templates/_base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load i18n %}
{% load language %}
{% load static from staticfiles %}
{% load blog_tags %}

<!DOCTYPE html>

Expand Down Expand Up @@ -103,15 +104,33 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav pull-left">
<li><a href="{% url 'downloads_index' %}">{% trans "Download" %}</a></li>
<li><a href="{% url 'zinnia:entry_archive_index' %}">{% trans "Blog" %}</a></li>
<li><a href="{% url 'media_all' %}">{% trans "Screenshots" %}</a></li>
<li><a href="{% url 'docs_faq' %}">{% trans "FAQ" %}</a></li>
<li><a href="{% url 'docs_guides_index' %}">{% trans "Guides" %}</a></li>
<li><a href="{% url 'compat_index' %}">{% trans "Compatibility" %}</a></li>
<li><a href="{{ FORUM_URL }}">{% trans "Forum" %}</a></li>
<li><a href="{{ WIKI_URL }}">{% trans "Wiki" %}</a></li>
<li><a href="{{ GIT_BROWSE_URL }}">{% trans "Code" %}</a></li>
<li class="{% navactive request 'downloads_index' %}">
<a href="{% url 'downloads_index' %}">{% trans "Download" %}</a>
</li>
<li class="{% navactive request 'zinnia:entry_archive_index' %}">
<a href="{% url 'zinnia:entry_archive_index' %}">{% trans "Blog" %}</a>
</li>
<li class="{% navactive request 'media_all' %}">
<a href="{% url 'media_all' %}">{% trans "Screenshots" %}</a>
</li>
<li class="{% navactive request 'docs_faq' %}">
<a href="{% url 'docs_faq' %}">{% trans "FAQ" %}</a>
</li>
<li class="{% navactive request 'docs_guides_index' %}">
<a href="{% url 'docs_guides_index' %}">{% trans "Guides" %}</a>
</li>
<li class="{% navactive request 'compat_index' %}">
<a href="{% url 'compat_index' %}">{% trans "Compatibility" %}</a>
</li>
<li>
<a href="{{ FORUM_URL }}">{% trans "Forum" %}</a>
</li>
<li>
<a href="{{ WIKI_URL }}">{% trans "Wiki" %}</a>
</li>
<li>
<a href="{{ GIT_BROWSE_URL }}">{% trans "Code" %}</a>
</li>
</ul>
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
Expand Down

0 comments on commit 13eed17

Please sign in to comment.