misuzu/templates/changelog/macros.twig

88 lines
3.6 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 %}
2023-07-15 02:05:49 +00:00
{% 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 %}
2022-09-13 13:14:49 +00:00
<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) %}
2023-07-15 02:08:13 +00:00
{% set user = change.user|default(null) %}
{% set user_colour = change.user_colour|default(null) %}
{% set tags = change.tags|default([]) %}
2023-07-15 02:05:49 +00:00
{% if change.change is defined %}
{% set change = change.change %}
{% endif %}
2022-09-13 13:14:49 +00:00
{% 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') }}">
2023-07-18 23:12:47 +00:00
{{ change.createdTime|time_format }}
2022-09-13 13:14:49 +00:00
</time>
</a>
{% endif %}
2023-07-15 02:05:49 +00:00
<a class="changelog__entry__action changelog__action--{{ change.action }}"
2022-09-13 13:14:49 +00:00
href="{{ change_url }}"
2023-07-15 02:05:49 +00:00
{% if is_small %}title="{{ change.actionText }}"{% endif %}>
2022-09-13 13:14:49 +00:00
{% if not is_small %}
<div class="changelog__entry__action__text">
2023-07-15 02:05:49 +00:00
{{ change.actionText }}
2022-09-13 13:14:49 +00:00
</div>
{% endif %}
</a>
{% if not is_small %}
<a class="changelog__entry__user"
2023-07-15 02:05:49 +00:00
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 %}>
2022-09-13 13:14:49 +00:00
<div class="changelog__entry__user__text">
{{ user.name|default('Anonymous') }}
2022-09-13 13:14:49 +00:00
</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 %}>
2023-07-15 02:05:49 +00:00
{{ change.summary }}
2022-09-13 13:14:49 +00:00
</a>
{% if is_manage %}
<div class="changelog__entry__tags">
{% for tag in tags %}
2023-07-15 02:05:49 +00:00
<a href="{{ is_manage ? url('manage-changelog-tag', {'tag': tag.id}) : url('changelog-index', {'tags': tag.id}) }}" class="changelog__entry__tag">
2022-09-13 13:14:49 +00:00
{{ tag.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
</div>
{% endmacro %}