From c6b765ef593c07483f342b7be612bc84a6e78cec Mon Sep 17 00:00:00 2001 From: Deimos Date: Fri, 6 Sep 2019 16:01:36 -0600 Subject: [PATCH] Move "segmented" group links into template macro --- tildes/tildes/templates/macros/groups.jinja2 | 13 +++++++++++++ tildes/tildes/templates/topic.jinja2 | 7 ++----- tildes/tildes/templates/topic_listing.jinja2 | 8 ++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tildes/tildes/templates/macros/groups.jinja2 b/tildes/tildes/templates/macros/groups.jinja2 index 56c89e6..acfc235 100644 --- a/tildes/tildes/templates/macros/groups.jinja2 +++ b/tildes/tildes/templates/macros/groups.jinja2 @@ -30,3 +30,16 @@ {% endif %} {% endmacro %} + +{% macro group_segmented_link(group, class=None) -%} + {# Split the link out for each "segment" of the group path #} + ~{{ group.path[0:1] }} + {% for i in range(1, group.path|length) %} + . + {{ group.path[i:i+1] }} + {% endfor %} +{%- endmacro %} diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 7ed3755..143081e 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -7,6 +7,7 @@ {% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_comment_tree with context %} {% from 'macros/datetime.jinja2' import adaptive_date_responsive, time_ago %} {% from 'macros/forms.jinja2' import markdown_textarea %} +{% from 'macros/groups.jinja2' import group_segmented_link %} {% from 'macros/links.jinja2' import group_linked, username_linked %} {% from 'macros/topics.jinja2' import topic_voting with context %} {% from 'macros/utils.jinja2' import pluralize %} @@ -26,11 +27,7 @@ {% endblock %} {% block header_context_link %} - {# Split the link out for each "segment" of the group path #} - ~{{ topic.group.path[0:1] }} - {% for i in range(1, topic.group.path|length) %} - .{{ topic.group.path[i:i+1] }} - {% endfor %} + {{ group_segmented_link(topic.group, class="site-header-context") }} {% endblock %} {% block content %} diff --git a/tildes/tildes/templates/topic_listing.jinja2 b/tildes/tildes/templates/topic_listing.jinja2 index 37d3fec..eecc501 100644 --- a/tildes/tildes/templates/topic_listing.jinja2 +++ b/tildes/tildes/templates/topic_listing.jinja2 @@ -4,18 +4,14 @@ {% extends 'base.jinja2' %} {% from 'macros/forms.jinja2' import search_form %} -{% from 'macros/groups.jinja2' import render_group_subscription_box with context %} +{% from 'macros/groups.jinja2' import group_segmented_link, render_group_subscription_box with context %} {% from 'macros/links.jinja2' import group_linked %} {% from 'macros/topics.jinja2' import render_topic_for_listing with context %} {% block title %}Topics in ~{{ group.path }}{% endblock %} {% block header_context_link %} - {# Split the link out for each "segment" of the group path #} - ~{{ group.path[0:1] }} - {% for i in range(1, group.path|length) %} - .{{ group.path[i:i+1] }} - {% endfor %} + {{ group_segmented_link(group, class="site-header-context") }} {% endblock %} {% block content %}