misuzu/templates/changelog/macros.twig

79 lines
3.3 KiB
Twig
Raw Normal View History

2019-03-02 21:04:45 +00:00
{% macro changelog_listing(changes, hide_dates, is_small, is_manage) %}
2018-07-06 01:28:06 +00:00
{% from _self import changelog_entry %}
2019-03-02 21:04:45 +00:00
<div class="changelog__listing">
{% if changes|length > 0 %}
{% for change in changes %}
2020-05-20 18:09:38 +00:00
{% if not hide_dates and (last_date is not defined or last_date != change.date) %}
{% set last_date = change.date %}
2018-07-06 01:28:06 +00:00
2020-05-20 18:09:38 +00:00
<a href="{{ is_manage ? '#cd' ~ last_date : url('changelog-index', {'date': last_date}) }}" class="changelog__listing__date" id="cd{{ last_date }}">
2019-03-02 21:04:45 +00:00
{{ last_date }}
</a>
{% endif %}
2018-07-06 01:28:06 +00:00
2019-03-02 21:04:45 +00:00
{{ changelog_entry(change, is_small, is_manage) }}
{% endfor %}
{% else %}
<div class="changelog__listing__none">
There are no changes to display here.
</div>
{% endif %}
</div>
2018-07-06 01:28:06 +00:00
{% endmacro %}
2019-03-02 21:04:45 +00:00
{% macro changelog_entry(change, is_small, is_manage) %}
2020-05-20 18:09:38 +00:00
{% set change_url = url(is_manage ? 'manage-changelog-change' : 'changelog-change', {'change': change.id}) %}
2018-07-06 01:28:06 +00:00
2020-05-20 18:09:38 +00:00
<div class="changelog__entry" id="cl{{ change.id }}">
2019-03-02 21:04:45 +00:00
<div class="changelog__entry__info">
{% if is_manage %}
2020-05-20 18:09:38 +00:00
<a href="{{ change_url }}" class="changelog__entry__datetime">
<time class="changelog__datetime__text"
2020-05-20 18:09:38 +00:00
datetime="{{ change.createdTime|date('c') }}"
title="{{ change.createdTime|date('r') }}">
{{ change.createdTime|time_diff }}
</time>
</a>
{% endif %}
2020-05-20 18:09:38 +00:00
<a class="changelog__entry__action changelog__action--{{ change.actionClass }}"
href="{{ change_url }}"
{% if is_small %}title="{{ change.actionString }}"{% endif %}>
2018-12-31 02:16:01 +00:00
{% if not is_small %}
2019-03-02 21:04:45 +00:00
<div class="changelog__entry__action__text">
2020-05-20 18:09:38 +00:00
{{ change.actionString }}
2018-12-31 02:16:01 +00:00
</div>
{% endif %}
</a>
2018-07-06 01:28:06 +00:00
2020-05-20 18:09:38 +00:00
{% if not is_small %}
2019-03-02 21:04:45 +00:00
<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') }}">
2019-03-02 21:04:45 +00:00
<div class="changelog__entry__user__text">
{{ change.user.username|default('Anonymous') }}
</div>
</a>
{% endif %}
</div>
2019-03-02 21:04:45 +00:00
<div class="changelog__entry__text">
2020-05-20 18:09:38 +00:00
<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 %}
2019-03-02 21:04:45 +00:00
<div class="changelog__entry__tags">
{% for tag in change.tags %}
2020-05-20 18:09:38 +00:00
<a href="{{ url(is_manage ? 'manage-changelog-tag' : 'changelog-tag', {'tag': tag.id}) }}" class="changelog__entry__tag">
{{ tag.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
2018-07-06 01:28:06 +00:00
</div>
{% endmacro %}