Sith/forum/templates/forum/macros.jinja
Skia 15a9eff599 forum: fix time localization
Signed-off-by: Skia <skia@libskia.so>
2017-07-05 21:41:33 +02:00

158 lines
6.5 KiB
Django/Jinja
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% from 'core/macros.jinja' import user_profile_link_short_name %}
{% macro display_forum(forum, user, is_root=False) %}
<div class="forum {% if is_root %}category{% endif %}">
<div class="ib w_big">
{% if not is_root %}
<a class="ib w_big" href="{{ url('forum:view_forum', forum_id=forum.id) }}">
{% else %}
<div class="ib w_big">
{% endif %}
<div class="title">{{ forum.name }}</div>
<p>{{ forum.description }}</p>
{% if not is_root %}
</a>
{% else %}
</div>
{% endif %}
{% if user.is_owner(forum) %}
<div class="tools">
<a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">{% trans %}Edit{% endtrans %}</a>
<a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">{% trans %}Delete{% endtrans %}</a>
</div>
{% endif %}
</div>
{% if not is_root %}
<div class="ib w_small">
<p class="ib w_medium">
{{ forum.topic_number }}
</p>
<div class="ib w_medium last_message" style="font-size: x-small; text-align: center">
{% if forum.last_message %}
{{ user_profile_link_short_name(forum.last_message.author) }} <br/>
<a href="{{ forum.last_message.get_absolute_url() }}">
<date>
{{ forum.last_message.date|localtime|date(DATETIME_FORMAT) }}
{{ forum.last_message.date|localtime|time(DATETIME_FORMAT) }}
</date><br>
<span>
{{ forum.last_message.topic }}
</span>
</a>
{% endif %}
</div>
</div>
{% endif %}
</div>
{% endmacro %}
{% macro display_topic(topic, user, first_unread=False) %}
<div class="topic">
<div class="ib w_medium">
{% if first_unread %}
<a class="ib w_big" href="{{ topic.get_first_unread_message(user).get_absolute_url() }}">
{% else %}
<a class="ib w_big" href="{{ url('forum:view_topic', topic_id=topic.id) }}">
{% endif %}
<div class="title">{{ topic.title or topic.messages.first().title }}</div>
<p>{{ topic.description }}</p>
</a>
{% if user.can_edit(topic) %}
<div class="ib tools" style="text-align: center;">
<a href="{{ url('forum:edit_topic', topic_id=topic.id) }}">{% trans %}Edit{% endtrans %}</a>
</div>
{% endif %}
</div>
<div class="ib w_medium last_message">
<div class="ib w_medium">
<p class="ib w_medium" style="text-align: center;">
{{ user_profile_link_short_name(topic.author) }}
</p>
<p class="ib w_medium" style="text-align: center;">
{{ topic._message_number }}
</p>
</div>
<p class="ib w_medium" style="text-align: center;">
{% set last_msg = topic.last_message %}
{% if last_msg %}
{{ user_profile_link_short_name(last_msg.author) }} <br/>
<a href="{{ last_msg.get_absolute_url() }}">
<date>{{ last_msg.date|localtime|date(DATETIME_FORMAT) }} {{ last_msg.date|localtime|time(DATETIME_FORMAT) }}</date>
</a>
{% endif %}
</p>
</div>
</div>
{% endmacro %}
{% macro display_message(m, user, unread=False) %}
{% if user.can_view(m) %}
<div id="msg_{{ m.id }}" class="message {% if unread %}unread{% endif %}">
<div class="msg_author {% if m.deleted %}deleted{% endif %}">
{% if m.author.avatar_pict %}
<img src="{{ m.author.avatar_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
{% else %}
<img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
{% endif %}
<br/>
<strong><a href="{{ m.author.get_absolute_url() }}">{{ m.author.get_short_name() }}</a></strong>
</div>
<div class="msg_content {% if m.deleted %}deleted{% endif %}" {% if m.id == first_unread_message_id %}id="first_unread"{% endif %}>
<div class="msg_header">
<div class="ib w_big title">
<a href="{{ m.get_absolute_url() }}">
{{ m.date|localtime|date(DATETIME_FORMAT) }}
{{ m.date|localtime|time(DATETIME_FORMAT) }}
{%- if m.title -%}
- {{ m.title }}
{%- endif -%}
</a>
</div>
<div class="ib w_small">
<span><a href="{{ m.get_absolute_url() }}">#{{ m.id }}</a></span>
<br/>
<span><a href="{{ url('forum:new_message', topic_id=m.topic.id) }}?quote_id={{ m.id }}">
{% trans %}Reply as quote{% endtrans %}</a></span>
{% if user.can_edit(m) %}
<span> <a href="{{ url('forum:edit_message', message_id=m.id) }}">{% trans %}Edit{% endtrans %}</a></span>
{% endif %}
{% if m.can_be_moderated_by(user) %}
{% if m.deleted %}
<span> <a href="{{ url('forum:undelete_message', message_id=m.id) }}">{% trans %}Undelete{% endtrans %}</a></span>
{% else %}
<span> <a href="{{ url('forum:delete_message', message_id=m.id) }}">{% trans %}Delete{% endtrans %}</a></span>
{% endif %}
{% endif %}
</div>
</div>
<hr>
<div>
{{ m.message|markdown }}
</div>
{% if m.can_be_moderated_by(user) %}
<ul class="msg_meta">
{% for meta in m.metas.select_related('user').order_by('id') %}
<li style="background: {% if m.author == meta.user %}#bfffbf{% else %}#ffffbf{% endif %}">
{{ meta.get_action_display() }} {{ meta.user.get_short_name() }}
{% trans %} at {% endtrans %}{{ meta.date|localtime|time(DATETIME_FORMAT) }}
{% trans %} the {% endtrans %}{{ meta.date|localtime|date(DATETIME_FORMAT)}}</li>
{% endfor %}
</ul>
{% endif %}
<div class="forum_signature">{{ m.author.forum_signature|markdown }}</div>
</div>
</div>
{% else %}
<div id="msg_{{ m.id }}" class="message">
<div class="msg_author deleted">
</div>
<div class="msg_content deleted">
<p class="ib w_big">{% trans %}Deleted or unreadable message.{% endtrans %}</p>
<p class="ib w_small">{{ m.date|localtime|date(DATETIME_FORMAT) }} {{ m.date|localtime|time(DATETIME_FORMAT) }}</p>
</div>
</div>
{% endif %}
{{ m.mark_as_read(user) or "" }}
{% endmacro %}