misuzu/templates/changelog/macros.twig

79 lines
3.3 KiB
Twig
Raw Normal View History

2022-09-13 13:14:49 +00:00
{% 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 %}
{% 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 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_diff }}
</time>
</a>
{% endif %}
<a class="changelog__entry__action changelog__action--{{ change.actionClass }}"
href="{{ change_url }}"
{% if is_small %}title="{{ change.actionString }}"{% endif %}>
{% if not is_small %}
<div class="changelog__entry__action__text">
{{ change.actionString }}
</div>
{% endif %}
</a>
{% if not is_small %}
<a class="changelog__entry__user"
href="{{ url(is_manage ? 'manage-user' : 'user-profile', {'user': change.user.id|default(0)}) }}"
style="--user-colour: {{ change.user.colour|default('inherit') }}">
<div class="changelog__entry__user__text">
{{ change.user.username|default('Anonymous') }}
</div>
</a>
{% endif %}
</div>
<div class="changelog__entry__text">
<a class="changelog__entry__log{% if change.hasBody %} changelog__entry__log--link{% endif %}"
{% if change.hasBody %}href="{{ change_url }}"{% endif %}>
{{ change.header }}
</a>
{% if is_manage %}
<div class="changelog__entry__tags">
{% for tag in change.tags %}
<a href="{{ url(is_manage ? 'manage-changelog-tag' : 'changelog-tag', {'tag': tag.id}) }}" class="changelog__entry__tag">
{{ tag.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endmacro %}