88 lines
3.9 KiB
HTML
88 lines
3.9 KiB
HTML
{% import "widgets/user.html" as widget_user %}
|
|
{% import "widgets/attachments.html" as widget_attachments %}
|
|
|
|
{# Thread widget: this widget expands to a table that shows a list of comments
|
|
from a thread, along with message controls.
|
|
|
|
comments: List of comments to render
|
|
top_comment: Thread's top comment (will be elided if encountered) #}
|
|
|
|
{% macro thread(comments, top_comment, owner=None) %}
|
|
<table class="thread">
|
|
{% for c in comments %}
|
|
{% if c != top_comment %}
|
|
<tr id="{{ c.id }}">
|
|
<td class="author">{{ widget_user.profile(c.author) }}</td>
|
|
<td class="message">
|
|
<div class="info">
|
|
<div>Posté le <a href="{{ request.path }}#{{ c.id }}">{{ c.date_created | dyndate }}</a></div>
|
|
{% if c.date_created != c.date_modified %}
|
|
<div>Modifié le <a href="{{ request.path }}#{{ c.id }}">{{ c.date_modified | dyndate }}</a></div>
|
|
{% endif %}
|
|
|
|
{# TODO: Let guests edit their posts #}
|
|
{% set can_edit = current_user.is_authenticated and current_user.can_edit_post(c) %}
|
|
{% set can_delete = current_user.is_authenticated and current_user.can_delete_post(c) %}
|
|
{% set can_punish = current_user.is_authenticated and current_user.priv("delete.posts") %}
|
|
{% set can_topcomm = current_user.is_authenticated and current_user.can_set_topcomment(c) %}
|
|
|
|
{% if can_edit or can_delete or can_punish %}
|
|
<details>
|
|
<summary><b>⋮</b></summary>
|
|
<div class='context-menu'>
|
|
{% if can_edit %}
|
|
<a href="{{ url_for('edit_post', postid=c.id, r=request.path) }}">Modifier</a>
|
|
{% endif %}
|
|
|
|
{% if can_punish %}
|
|
<a href="{{ url_for('delete_post', postid=c.id, penalty=False, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé.')">Supprimer (normal)</a>
|
|
<a href="{{ url_for('delete_post', postid=c.id, penalty=True, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé avec pénalité d\'XP.')">Supprimer (pénalité)</a>
|
|
{% elif can_delete %}
|
|
<a href="{{ url_for('delete_post', postid=c.id, penalty=False, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé !')">Supprimer</a>
|
|
{% endif %}
|
|
|
|
{% if can_topcomm %}
|
|
<a href="{{ url_for('set_post_topcomment', postid=c.id, csrf_token=csrf_token()) }}">Utiliser comme en-tête</a>
|
|
{% endif %}
|
|
</div>
|
|
</details>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{{ c.text|md }}
|
|
|
|
{{ widget_attachments.attachments(c) }}
|
|
|
|
{% if c.author.signature %}
|
|
<hr class="signature">
|
|
{{ c.author.signature|md }}
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% elif loop.index0 != 0 %}
|
|
<tr class="topcomment-placeholder">
|
|
<td></td>
|
|
<td><div>Le commentaire à cet endroit est actuellement utilisé comme en-tête.</div></td>
|
|
</tr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</table>
|
|
{% endmacro %}
|
|
|
|
{# Thread leader widget: this widget expands to a single-message thread which
|
|
can show more text when called. This is intended for programs and similar
|
|
objects which display metadata before description and comments.
|
|
|
|
leader: Posts's top comment (actual rendering is delegated to caller) #}
|
|
|
|
{% macro thread_leader(leader) %}
|
|
<table class="thread topcomment">
|
|
{# Empty line to get normal background (instead of alternate one) #}
|
|
<tr></tr>
|
|
<tr id="{{ leader.id }}">
|
|
<td class="author">{{ widget_user.profile(leader.author) }}</td>
|
|
<td class="message">{{ caller() }}</td>
|
|
</tr>
|
|
</table>
|
|
{% endmacro %}
|