2.8 KiB · text History 6b4f785
{% import "_avatar.html" as ui %}
<article id="post-{{ post.post_number }}" class="card bg-base-200 border border-base-300 p-4">
  {% if post.deleted %}
    <header class="flex items-center justify-between text-sm">
      <span class="opacity-60 italic">
        <i class="fas fa-trash-can mr-1"></i>
        post #{{ post.post_number }} removed{% if post.deleted_by %} by {{ post.deleted_by }}{% endif %}
      </span>
      {% if post.can_restore %}
      <form method="post" action="/p/{{ post.id }}/restore" class="m-0">
        <button class="btn btn-ghost btn-xs" type="submit">Restore</button>
      </form>
      {% endif %}
    </header>
  {% else %}
    <div class="flex gap-3">
      <div class="shrink-0">
        {{ ui.avatar(post.author_id, post.author, post.author_has_avatar, "size-10", "text-base") | safe }}
      </div>
      <div class="flex-1 min-w-0">
        <header class="flex items-center justify-between text-sm mb-2 gap-2">
          <span class="font-semibold">{{ post.author }}</span>
          <span class="opacity-60 text-xs flex items-center gap-2 shrink-0">
            {% if post.edited %}
              <a href="/p/{{ post.id }}/history" class="link link-hover" title="View edit history">edited</a>
            {% endif %}
            <a href="/p/{{ post.id }}" hx-boost="false" class="link link-hover" title="{{ post.created_at_abs }} · permalink">#{{ post.post_number }} · {{ post.created_at }}</a>
          </span>
        </header>
        <div class="prose prose-sm max-w-none">{{ post.cooked | safe }}</div>
        {# Writing (react/bookmark/edit) needs a verified email. #}
        {% set can_write = user and (user.email_verified_at or not require_email_verification) %}
        {% if can_write %}
          {% include "forum/_reactions.html" %}
        {% elif post.reactions %}
          <div class="flex flex-wrap items-center gap-1 mt-2">
            {% for r in post.reactions %}{% if r.count > 0 %}<span class="group/react badge badge-ghost badge-sm"><span class="emoji-tint">{{ r.emoji }}</span> {{ r.count }}</span>{% endif %}{% endfor %}
          </div>
        {% endif %}
        {% if user %}
        <footer class="flex justify-end items-center gap-2 mt-2">
          {% if can_write %}{% include "forum/_bookmark_button.html" %}{% endif %}
          {% if post.can_edit %}
          {% if can_write %}<a href="/p/{{ post.id }}/edit" class="btn btn-ghost btn-xs">Edit</a>{% endif %}
          <form method="post" action="/p/{{ post.id }}/delete" class="m-0"
                hx-boost="false" onsubmit="return confirm('Delete this post? It stays hidden but is kept so references don\'t break.');">
            <button class="btn btn-ghost btn-xs text-error" type="submit">Delete</button>
          </form>
          {% endif %}
        </footer>
        {% endif %}
      </div>
    </div>
  {% endif %}
</article>