3.2 KiB · text History 263b40b
{% extends "root.html" %}

{% block content %}
<div class="space-y-4 text-left">
  <div class="text-sm opacity-70">
    <a href="/t/{{ topic_id }}#post-{{ post_number }}" class="link link-hover">&larr; Back to post #{{ post_number }}</a>
  </div>

  <h1 class="text-2xl font-bold">Edit history — post #{{ post_number }}</h1>
  <p class="text-sm opacity-70">Every version of this post, oldest first.</p>

  {% if is_staff and moderated %}
  <div class="alert alert-warning text-sm" data-staff-history>
    <i class="fas fa-shield-halved"></i>
    <span>Staff moderated this post.{% if any_hidden %} Its earlier versions are hidden from everyone but staff.{% else %} Its earlier versions are visible to everyone.{% endif %}</span>
    <div class="flex flex-wrap gap-1">
      <form method="post" action="/p/{{ post_id }}/history/{% if any_hidden %}unhide{% else %}hide{% endif %}" class="m-0" hx-boost="false">
        <button class="btn btn-xs" type="submit">{% if any_hidden %}Show them again{% else %}Hide the original{% endif %}</button>
      </form>
      <form method="post" action="/p/{{ post_id }}/moderation/restore" class="m-0" hx-boost="false"
            onsubmit="return confirm('Put the author\'s last version back?');">
        <button class="btn btn-xs" type="submit">Restore the author's version</button>
      </form>
    </div>
  </div>
  {% endif %}

  <div class="space-y-3">
    {% for v in versions %}
    <article class="card bg-base-200 border p-4 {% if v.current %}border-accent{% elif v.kind == 'moderation' %}border-warning/60{% else %}border-base-300{% endif %}"
             data-revision="{{ v.revision_number }}" data-kind="{{ v.kind }}">
      <header class="flex items-center justify-between text-sm mb-2">
        <span class="font-semibold">
          {% if v.kind == 'moderation' %}<i class="fas fa-shield-halved text-warning mr-1"></i>Moderated by staff
          {% elif v.kind == 'restore' %}<i class="fas fa-rotate-left mr-1"></i>Restored by staff
          {% elif v.revision_number == 1 %}Original{% else %}Revision {{ v.revision_number }}{% endif %}
          {% if v.current %}<span class="badge badge-accent badge-sm ml-1">current</span>{% endif %}
          {% if v.hidden and is_staff %}<span class="badge badge-warning badge-sm ml-1" title="Only staff can see this version">hidden from non-staff</span>{% endif %}
        </span>
        <span class="opacity-60 text-xs" title="{{ v.created_at_abs }}">{% if is_staff and v.editor_id %}<a href="/admin/users/{{ v.editor_id }}" class="link link-hover">{{ v.editor }}</a>{% else %}{{ v.editor }}{% endif %} · {{ v.created_at }}</span>
      </header>
      {% if v.cooked is none %}
        <p class="italic opacity-60 text-sm" data-hidden-by-staff><i class="fas fa-eye-slash mr-1"></i>Hidden by staff.</p>
      {% elif v.kind == 'moderation' %}
        <div class="rounded-box border-l-4 border-warning bg-warning/10 px-3 py-2">
          <p class="text-xs font-semibold uppercase tracking-wide mb-1">staff:</p>
          <div class="prose prose-sm max-w-none">{{ v.cooked | safe }}</div>
        </div>
      {% else %}
        <div class="prose prose-sm max-w-none">{{ v.cooked | safe }}</div>
      {% endif %}
    </article>
    {% endfor %}
  </div>
</div>
{% endblock %}