misuzu/templates/changelog/macros.twig

87 lines
3.6 KiB
Twig

{% macro changelog_listing(changes, hide_dates, is_small, is_manage) %}
{% from _self import changelog_entry %}
<div class="changelog__listing">
{% if changes|length > 0 %}
{% for change in changes %}
{% set change_date = change.change is defined ? change.change.date : change.date %}
{% if not hide_dates and (last_date is not defined or last_date != change_date) %}
{% set last_date = change_date %}
<a href="{{ is_manage ? '#cd' ~ last_date : url('changelog-index', {'date': last_date}) }}" class="changelog__listing__date" id="cd{{ last_date }}">
{{ last_date }}
</a>
{% endif %}
{{ changelog_entry(change, is_small, is_manage) }}
{% endfor %}
{% else %}
<div class="changelog__listing__none">
There are no changes to display here.
</div>
{% endif %}
</div>
{% endmacro %}
{% macro changelog_entry(change, is_small, is_manage) %}
{% set user = change.user|default(null) %}
{% set user_colour = change.user_colour|default(null) %}
{% set tags = change.tags|default([]) %}
{% if change.change is defined %}
{% set change = change.change %}
{% endif %}
{% set change_url = url(is_manage ? 'manage-changelog-change' : 'changelog-change', {'change': change.id}) %}
<div class="changelog__entry" id="cl{{ change.id }}">
<div class="changelog__entry__info">
{% if is_manage %}
<a href="{{ change_url }}" class="changelog__entry__datetime">
<time class="changelog__datetime__text"
datetime="{{ change.createdTime|date('c') }}"
title="{{ change.createdTime|date('r') }}">
{{ change.createdTime|time_format }}
</time>
</a>
{% endif %}
<a class="changelog__entry__action changelog__action--{{ change.action }}"
href="{{ change_url }}"
{% if is_small %}title="{{ change.actionText }}"{% endif %}>
{% if not is_small %}
<div class="changelog__entry__action__text">
{{ change.actionText }}
</div>
{% endif %}
</a>
{% if not is_small %}
<a class="changelog__entry__user"
href="{{ url(is_manage ? 'manage-user' : 'user-profile', {'user': user.id|default(0)}) }}"
{% if user_colour is not null %}style="--user-colour: {{ user_colour }}"{% endif %}>
<div class="changelog__entry__user__text">
{{ user.name|default('Anonymous') }}
</div>
</a>
{% endif %}
</div>
<div class="changelog__entry__text">
<a class="changelog__entry__log{% if change.body is not empty %} changelog__entry__log--link{% endif %}"
{% if change.body is not empty %}href="{{ change_url }}"{% endif %}>
{{ change.summary }}
</a>
{% if is_manage %}
<div class="changelog__entry__tags">
{% for tag in tags %}
<a href="{{ is_manage ? url('manage-changelog-tag', {'tag': tag.id}) : url('changelog-index', {'tags': tag.id}) }}" class="changelog__entry__tag">
{{ tag.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endmacro %}