3.3 KiB · text History 2264215
{% extends "root.html" %}
{% import "_avatar.html" as ui %}

{% block inner %}
<div class="space-y-4 text-left">
  <div class="text-sm opacity-70">
    <a href="/" class="link link-hover">Categories</a>
    {% if category %} / <a href="/c/{{ category.slug }}" class="link link-hover">{{ category.name }}</a>{% endif %}
  </div>

  <div class="flex items-start justify-between gap-3">
    <h1 class="text-3xl font-bold">
      {% if topic.is_closed %}<i class="fas fa-lock opacity-60 mr-1" title="Closed"></i>{% endif %}
      {{ topic.title }}
    </h1>
    <div class="flex items-center gap-2 shrink-0">
      {% if can_delete_topic %}
        <form method="post" action="/t/{{ topic.id }}/delete" class="m-0"
              onsubmit="return confirm('Delete this topic? It will be hidden from listings but kept so links don\'t break. Only a moderator can restore it.');">
          <button type="submit" class="btn btn-ghost btn-xs text-error">Delete topic</button>
        </form>
      {% endif %}
      {% if can_restore_topic %}
        <form method="post" action="/t/{{ topic.id }}/restore" class="m-0">
          <button type="submit" class="btn btn-ghost btn-xs">Restore topic</button>
        </form>
      {% endif %}
    </div>
  </div>

  {% if tags %}
  <div class="flex flex-wrap gap-1">
    {% for tag in tags %}<a href="/tag/{{ tag.slug }}" class="badge badge-ghost">{{ tag.name }}</a>{% endfor %}
  </div>
  {% endif %}

  {% if participants %}
  <div class="hidden lg:flex items-center gap-2 text-sm">
    <span class="opacity-60">Top repliers</span>
    <div class="flex items-center -space-x-2">
      {% for p in participants %}
      <span class="ring-2 ring-base-100 rounded-full inline-flex"
            title="{{ p.name }} · {{ p.count }} repl{% if p.count == 1 %}y{% else %}ies{% endif %}">
        {{ ui.avatar(p.id, p.name, p.has_avatar, "size-7", "text-xs") | safe }}
      </span>
      {% endfor %}
    </div>
  </div>
  {% endif %}

  {% if topic_deleted %}
  <div class="alert alert-warning">
    <i class="fas fa-trash-can"></i>
    <span>This topic is deleted — only staff can see it. Restore it to make it public again.</span>
  </div>
  {% endif %}

  <div id="posts" class="space-y-3">
    {% for post in posts %}
      {% include "forum/_post.html" %}
    {% endfor %}
  </div>

  {% if topic.is_closed %}
    <div class="alert alert-warning"><i class="fas fa-lock"></i><span>This topic is closed.</span></div>
  {% elif user %}
    <form class="card bg-base-200 border border-base-300 p-4 space-y-2"
          hx-post="/t/{{ topic.id }}/posts"
          hx-target="#posts"
          hx-swap="beforeend"
          hx-on::after-request="if(event.detail.successful){ this.reset(); }">
      <h2 class="font-semibold">Reply</h2>
      <textarea name="body" rows="4" required
                class="textarea textarea-bordered w-full font-mono text-sm"
                placeholder="Write a reply… markdown supported"></textarea>
      <div class="flex justify-end">
        <button type="submit" class="btn btn-primary btn-sm">
          <i class="fas fa-paper-plane mr-1"></i> Post reply
        </button>
      </div>
    </form>
  {% else %}
    <div class="alert">
      <span><a href="/login" class="link link-primary">Log in</a> to reply.</span>
    </div>
  {% endif %}
</div>
{% endblock %}