From 882d9c53b8ae2d20aa69eb6f26e580d3360d527a Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Wed, 11 Sep 2019 18:24:08 -0400 Subject: [PATCH 01/11] add cat to index blog card --- .../templates/wagtailpages/fragments/blog-card.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 057da1c1894..5462c7a8d04 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -22,13 +22,13 @@ {% endfor %} {% else %} - {# Show the tag's own "main" tag (i.e. first tag in its tag list) as each blog card's visible tag #} + {# Show the category's own "main" category (i.e. first tag in its tag list) as each blog card's visible tag #} - {% with tag=page.specific.tags.first %} - {% if tag %} + {% with category=page.specific.category.first tag=page.specific.tags.first %} + {% if category %} {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ tag }} + {{ category }} {% 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 #} {{ tag }} From a53d634fdfdf7e7f9fb4ea4353651935d985de9d Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Wed, 11 Sep 2019 19:08:28 -0400 Subject: [PATCH 02/11] updating classname --- .../templates/wagtailpages/fragments/blog-card.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 5462c7a8d04..df7c417b0eb 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -28,7 +28,7 @@ {% if category %} {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} + {{ category }} {% 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 #} {{ tag }} From 9ff5812d42f0f162a1d8950d46c29fe74a2cbe03 Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Wed, 11 Sep 2019 19:12:03 -0400 Subject: [PATCH 03/11] use bootstrap text transform class --- .../templates/wagtailpages/fragments/blog-card.html | 4 ++-- source/sass/views/blog.scss | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index df7c417b0eb..4940b1458d3 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -28,10 +28,10 @@ {% if category %} {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} + {{ category }} {% 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 #} - {{ tag }} + {{ tag }} {% endif %} {% endif %} {% endwith %} diff --git a/source/sass/views/blog.scss b/source/sass/views/blog.scss index cb26a162c95..b5adf41a389 100644 --- a/source/sass/views/blog.scss +++ b/source/sass/views/blog.scss @@ -17,9 +17,3 @@ } } } - -.blog-card { - .main-tag { - text-transform: capitalize; - } -} From 9932f3443ed3c098a1f66f5ca1b09f8af8db8afe Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Thu, 12 Sep 2019 12:06:15 -0400 Subject: [PATCH 04/11] updated tag/cat styles --- .../templates/wagtailpages/fragments/blog-card.html | 4 ++-- source/sass/views/blog.scss | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 4940b1458d3..2e8c1228128 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -28,10 +28,10 @@ {% if category %} {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} + {{ category }} {% 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 #} - {{ tag }} + {{ tag }} {% endif %} {% endif %} {% endwith %} diff --git a/source/sass/views/blog.scss b/source/sass/views/blog.scss index b5adf41a389..88b8d313d2b 100644 --- a/source/sass/views/blog.scss +++ b/source/sass/views/blog.scss @@ -17,3 +17,12 @@ } } } + +.blog-card { + .main-category, + .main-tag { + @extend .text-uppercase; + color: $dark-blue; + letter-spacing: 0.5px; + } +} From 07319bba8994915ddaf421a96fd430a8022231a0 Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Thu, 12 Sep 2019 14:07:52 -0400 Subject: [PATCH 05/11] testing if cat still works on related pages --- .../templates/wagtailpages/fragments/blog-card.html | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 2e8c1228128..827084f7613 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -24,15 +24,10 @@ {% else %} {# Show the category's own "main" category (i.e. first tag in its tag list) as each blog card's visible tag #} - {% with category=page.specific.category.first tag=page.specific.tags.first %} - {% if category %} - {% if root %} - {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} - {% 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 #} - {{ tag }} - {% endif %} + {% with category=page.specific.category.first %} + {% if category %} + {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} + {{ category }} {% endif %} {% endwith %} {% endif %} From eaeac8d2a7976442c1ba90c9e7e781f0222ee36b Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Thu, 12 Sep 2019 14:21:19 -0400 Subject: [PATCH 06/11] test --- .../templates/wagtailpages/fragments/blog-card.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 827084f7613..5c5ced08bc3 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -26,8 +26,13 @@ {% with category=page.specific.category.first %} {% if category %} + {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} {{ category }} + {% 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 #} + {{ category }} + {% endif %} {% endif %} {% endwith %} {% endif %} From 90507a622d4bce8c9d0f602f87ba1d910c5f3b4a Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Fri, 13 Sep 2019 14:41:30 -0400 Subject: [PATCH 07/11] testing tempatetag --- .../wagtailpages/fragments/blog-card.html | 10 +++------- .../wagtailpages/templatetags/blog_tags.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 network-api/networkapi/wagtailpages/templatetags/blog_tags.py diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 5c5ced08bc3..63968a38f81 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -1,6 +1,6 @@ {% extends "./generic-card.html" %} -{% load wagtailcore_tags wagtailroutablepage_tags class_tags %} +{% load wagtailcore_tags wagtailroutablepage_tags class_tags blog_tags%} {% block card_type %}blog-card{% endblock %} @@ -25,14 +25,10 @@ {# Show the category's own "main" category (i.e. first tag in its tag list) as each blog card's visible tag #} {% with category=page.specific.category.first %} + {% get_root_or_page as parent_page %} {% if category %} - {% if root %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} - {% 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 #} - {{ category }} - {% endif %} + {{ category }} {% endif %} {% endwith %} {% endif %} diff --git a/network-api/networkapi/wagtailpages/templatetags/blog_tags.py b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py new file mode 100644 index 00000000000..425f85689d8 --- /dev/null +++ b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py @@ -0,0 +1,14 @@ +from django import template + +register = template.Library() + + +@register.simple_tag(takes_context=True) +def get_root_or_page(context): + root = context.get('root', None) + page = context.get('page', None) + + if root: + return root.specific + else: + return page.get_parent().specific() From b164c335a0baeed27b73b383279c1c1614b6fffa Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Fri, 13 Sep 2019 14:48:45 -0400 Subject: [PATCH 08/11] specific should be prop not method --- network-api/networkapi/wagtailpages/templatetags/blog_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network-api/networkapi/wagtailpages/templatetags/blog_tags.py b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py index 425f85689d8..2be72c73830 100644 --- a/network-api/networkapi/wagtailpages/templatetags/blog_tags.py +++ b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py @@ -11,4 +11,4 @@ def get_root_or_page(context): if root: return root.specific else: - return page.get_parent().specific() + return page.get_parent().specific From 642f4538efffc5b0fa58e43bd88665f24e494674 Mon Sep 17 00:00:00 2001 From: Youri Wims Date: Fri, 13 Sep 2019 16:55:45 -0400 Subject: [PATCH 09/11] updates --- .../templates/wagtailpages/fragments/blog-card.html | 4 ++-- .../networkapi/wagtailpages/templatetags/blog_tags.py | 4 +++- source/sass/views/blog.scss | 9 --------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 63968a38f81..b4fc8f5a263 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -25,10 +25,10 @@ {# Show the category's own "main" category (i.e. first tag in its tag list) as each blog card's visible tag #} {% with category=page.specific.category.first %} - {% get_root_or_page as parent_page %} {% if category %} + {% get_root_or_page as parent_page %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} - {{ category }} + {{ category }} {% endif %} {% endwith %} {% endif %} diff --git a/network-api/networkapi/wagtailpages/templatetags/blog_tags.py b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py index 2be72c73830..501ba6c0c61 100644 --- a/network-api/networkapi/wagtailpages/templatetags/blog_tags.py +++ b/network-api/networkapi/wagtailpages/templatetags/blog_tags.py @@ -10,5 +10,7 @@ def get_root_or_page(context): if root: return root.specific - else: + elif page: return page.get_parent().specific + else: + print("There is no root or page in templatetag get_root_or_page") diff --git a/source/sass/views/blog.scss b/source/sass/views/blog.scss index 88b8d313d2b..b5adf41a389 100644 --- a/source/sass/views/blog.scss +++ b/source/sass/views/blog.scss @@ -17,12 +17,3 @@ } } } - -.blog-card { - .main-category, - .main-tag { - @extend .text-uppercase; - color: $dark-blue; - letter-spacing: 0.5px; - } -} From a41abe369818d371ad81340f8f18ae010645170e Mon Sep 17 00:00:00 2001 From: Youri Date: Mon, 16 Sep 2019 15:40:54 -0400 Subject: [PATCH 10/11] Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html Co-Authored-By: Pomax --- .../templates/wagtailpages/fragments/blog-card.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index e9acba8e459..4f228fe0180 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -1,6 +1,6 @@ {% extends "./generic-card.html" %} -{% load wagtailcore_tags wagtailroutablepage_tags class_tags blog_tags%} +{% load wagtailcore_tags wagtailroutablepage_tags class_tags blog_tags %} {% block card_type %}blog-card{% endblock %} From ffafdc4017c2857bd4151c9eb5740e3f64b10e22 Mon Sep 17 00:00:00 2001 From: Youri Date: Mon, 16 Sep 2019 15:41:01 -0400 Subject: [PATCH 11/11] Update network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html Co-Authored-By: Pomax --- .../templates/wagtailpages/fragments/blog-card.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html index 4f228fe0180..84620f1f2b3 100644 --- a/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html +++ b/network-api/networkapi/wagtailpages/templates/wagtailpages/fragments/blog-card.html @@ -24,7 +24,7 @@ {% else %} {% with category=page.specific.category.first %} {% if category %} - {% get_root_or_page as parent_page %} + {% get_root_or_page as parent_page %} {# If we have a "root" context variable, we know this card is generated on an index page (or index page subroute) #} {{ category }} {% endif %}