Browse Source

Move "segmented" group links into template macro

merge-requests/85/head
Deimos 5 years ago
parent
commit
c6b765ef59
  1. 13
      tildes/tildes/templates/macros/groups.jinja2
  2. 7
      tildes/tildes/templates/topic.jinja2
  3. 8
      tildes/tildes/templates/topic_listing.jinja2

13
tildes/tildes/templates/macros/groups.jinja2

@ -30,3 +30,16 @@
{% endif %}
</div>
{% endmacro %}
{% macro group_segmented_link(group, class=None) -%}
{# Split the link out for each "segment" of the group path #}
<a href="/~{{ group.path[0:1] }}"
{% if class %}class="{{ class }}"{% endif %}
>~{{ group.path[0:1] }}</a>
{% for i in range(1, group.path|length) %}
.
<a href="/~{{ group.path[0:i+1] }}"
{% if class %}class="{{ class }}"{% endif %}
>{{ group.path[i:i+1] }}</a>
{% endfor %}
{%- endmacro %}

7
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 #}
<a class="site-header-context" href="/~{{ topic.group.path[0:1] }}">~{{ topic.group.path[0:1] }}</a>
{% for i in range(1, topic.group.path|length) %}
.<a class="site-header-context" href="/~{{ topic.group.path[0:i+1] }}">{{ topic.group.path[i:i+1] }}</a>
{% endfor %}
{{ group_segmented_link(topic.group, class="site-header-context") }}
{% endblock %}
{% block content %}

8
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 #}
<a class="site-header-context" href="/~{{ group.path[0:1] }}">~{{ group.path[0:1] }}</a>
{% for i in range(1, group.path|length) %}
.<a class="site-header-context" href="/~{{ group.path[0:i+1] }}">{{ group.path[i:i+1] }}</a>
{% endfor %}
{{ group_segmented_link(group, class="site-header-context") }}
{% endblock %}
{% block content %}

Loading…
Cancel
Save