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

{% block content %}
<div class="space-y-4 text-left">
  <div class="flex items-center justify-between">
    <h1 class="text-3xl font-bold">Manage categories</h1>
    <div class="flex flex-wrap items-center gap-2">
      {% set toggle_base = "/admin/categories" %}{% set view_mode = "classic" %}
      {% include "forum/_view_toggle.html" %}
      <a href="/admin/categories/new" class="btn btn-primary btn-sm">
        <i class="fas fa-plus mr-1"></i> New category
      </a>
    </div>
  </div>

  {% if categories|length == 0 %}
    <p class="opacity-70">No categories yet.</p>
  {% else %}
  <div class="overflow-x-auto">
    <table class="table">
      <thead>
        <tr>
          <th>Category</th>
          <th>Slug</th>
          <th>Visibility</th>
          <th>Posting</th>
          <th class="text-right">Position</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for c in categories %}
        <tr class="hover">
          <td>
            <span class="inline-flex items-center gap-2" style="padding-left: {{ (c.depth - 1) * 1.25 }}rem">
              {% if c.depth > 1 %}<span class="opacity-40">└</span>{% endif %}
              <span class="size-3 rounded-full border border-base-content/20" style="background: {{ c.color }}"></span>
              <a href="/c/{{ c.slug }}" class="font-medium link link-hover">{{ c.name }}</a>
            </span>
          </td>
          <td><code class="text-xs">{{ c.slug }}</code></td>
          <td class="text-xs">
            {% if c.min_trust is none %}<span class="badge badge-ghost badge-sm">Public</span>
            {% elif c.min_trust == 0 %}<span class="badge badge-warning badge-sm">Logged-in</span>
            {% else %}<span class="badge badge-warning badge-sm">TL{{ c.min_trust }}+</span>{% endif %}
          </td>
          <td class="text-xs">{% for r in c.rules %}<span class="badge badge-info badge-sm mr-1">{{ r }}</span>{% else %}<span class="opacity-50">anyone who can read</span>{% endfor %}</td>
          <td class="text-right font-mono">{{ c.position }}</td>
          <td class="text-right whitespace-nowrap">
            <a href="/admin/categories/{{ c.id }}/edit" class="btn btn-ghost btn-xs">Edit</a>
            <form method="post" action="/admin/categories/{{ c.id }}/delete" class="inline"
                  hx-boost="false" onsubmit="return confirm('Delete &quot;{{ c.name }}&quot;? Subcategories move up a level; this category\'s own topics and posts are deleted.');">
              <button type="submit" class="btn btn-error btn-xs">Delete</button>
            </form>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  {% endif %}
</div>
{% endblock %}