-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tag "filtering" through dedicated URLs
- Loading branch information
Showing
12 changed files
with
201 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 33 additions & 6 deletions
39
network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,42 @@ | ||
{% extends "./generic-card.html" %} | ||
|
||
{% load wagtailcore_tags %} | ||
{% load wagtailcore_tags wagtailroutablepage_tags class_tags %} | ||
|
||
{% block card_type %}blog-card{% endblock %} | ||
|
||
The following block needs to know where the blog IndexPage is, | ||
so it checks whether "we" are the index page, and if not, it | ||
crawls up the ancestor tree until it has found it. | ||
|
||
(Without it, we cannot generate the links to /blob/tag/... for | ||
each blog page's dominant tag) | ||
|
||
{% block tags %} | ||
{% if filtered %} | ||
<ul class="tag-list mt-3"> | ||
{% for tag in page.specific.tags.all %} | ||
<li class="tag"> | ||
<a href="{% routablepageurl root.specific "entries_by_tag" tag.slug %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
{# Show the tag's own "main" tag (i.e. first tag in its tag list) as each blog card's visible tag #} | ||
|
||
{% block tags-DISABLED-FOR-NOW %} | ||
<div> | ||
{% with tag=page.specific.tags.first %} | ||
<a class="main-tag" href="#">{{ tag }}</a> | ||
{% if tag %} | ||
{% if root %} | ||
{# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} | ||
<a class="main-tag d-block mt-3" href="{% routablepageurl root.specific "entries_by_tag" tag.slug %}">{{ tag }}</a> | ||
{% else %} | ||
{# If we do not have a "root" context variable, this card is being generated outside of an index page, and so needs to use its parent as root #} | ||
<a class="main-tag d-block mt-3" href="{% routablepageurl page.get_parent.specific "entries_by_tag" tag.slug %}">{{ tag }}</a> | ||
{% endif %} | ||
{% endif %} | ||
{% endwith %} | ||
</div> | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block byline %} | ||
By {{ page.specific.author }} on {{ page.first_published_at|date:"F j, Y" }} | ||
{% endblock%} | ||
{% endblock %} |
4 changes: 2 additions & 2 deletions
4
network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/generic-card.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
network-api/networkapi/wagtailpages/templatetags/class_tags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django import template | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter | ||
def to_class_name(value): | ||
return value.__class__.__name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.term-list { | ||
display: inline-block; | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
|
||
.term { | ||
display: inline-block; | ||
padding: 0 0.5em; | ||
margin-left: 0.25em; | ||
border: 1px solid $black; | ||
border-radius: 10px; | ||
color: $black; | ||
text-transform: capitalize; | ||
} | ||
} |