{#- A thread: its posts in order, the unread ones after a divider; replying at the end, with the editor and attachments; closing and deleting for the community's managers. Drawn in `mockups/templates/thread.html`. -#} {% extends "ads_community.html" %} {% import "forum/_post_fields.html" as fields %} {#- Closing and deleting are for the community's managers; the dialog needs it too. -#} {% set moderator = can_manage(current_user, g.community) %} {% block page_title %}{{ thread.title }}{% endblock %} {#- The widgets (the uploader) and the rich-text editor; no stylesheet comes with them. -#} {% block scripts %}{{ vite_asset("src/main.js") }}{{ vite_asset("src/editor.js") }}{% endblock %} {% block content %} {% set first_new = thread.posts | length - new_posts %}
  1. {{ _("Discussions") }}

{% if is_closed %}{{ icon("lock") }} {% endif %}{{ thread.title }}

{{- ngettext("%(num)d reply", "%(num)d replies", thread.posts | length - 1) }} · {{ ngettext("%(num)d participant", "%(num)d participants", participants | length) }} {%- if new_posts %} · {{ ngettext("%(num)d new message", "%(num)d new messages", new_posts) }}{% endif -%}
{% if not is_closed %}{{ icon("arrow-back-up") }}{{ _("Reply") }}{% endif %} {% if moderator %}
{{ icon("dots-vertical") }}

{{ _("Running the community") }}

{{ csrf.field() }} {% if is_closed %} {% else %} {% endif %}
{% endif %}
{% for post in thread.posts %} {% if new_posts and loop.index0 == first_new %}
{{ _("New messages") }}
{% endif %}
{{ m.avatar(post.creator) }}
{{ post.creator.name }} {{ m.time(post.created_at) }} {% if not is_closed and can_write_post(current_user, post) %} {{ icon("pencil") }}{{ _("Edit") }} {% endif %}
{{ post.body_html | safe }}
{% for a in post.attachments %}{{ m.file({"name": a.name, "url": url_for(a), "size": a.content_length}) }}{% endfor %} {% for entry in post.history %} {{ _("Edited by %(user)s, %(date)s", user=entry.user, date=entry.date | datetimeparse | age(date_threshold="day")) }}{% if entry.reason %}: « {{ entry.reason }} »{% endif %} {% endfor %}
{% endfor %}
{% if is_closed %}
{{ _("This discussion is closed: it takes no more replies.") }}
{% else %}
{{ form.csrf_token }} {{ fields.message_field(form.message, _("Your reply")) }} {{ fields.attachments_field(form.attachments) }} {{ fields.send_by_email(form) }}
{% endif %}
{% endblock %} {% block overlays %} {% if moderator %}
{{ csrf.field() }}

{{ _("Delete the discussion?") }}

{{ ngettext("It goes, with its message and its attachments. This cannot be undone.", "It goes, with its %(num)d messages and their attachments. This cannot be undone.", thread.posts | length) }}
{% endif %} {% endblock %}