{% extends "base.html" %}
{% block title %}Recent changes — Wiki{% endblock %}
{% block content %}
{% include "wiki/_layout.html" %}

<div class="bbs-header">
    <h1><i class="bi bi-clock-history"></i> Recent changes</h1>
    <p class="text-muted">Every edit, newest first.</p>
</div>

{% if pagination.items %}
<div class="card">
    <table class="table table-sm mb-0">
        <thead>
            <tr>
                <th>When</th>
                <th>Page</th>
                <th>Rev</th>
                <th>Who</th>
                <th>Edit summary</th>
            </tr>
        </thead>
        <tbody>
            {% for r in pagination.items %}
            <tr>
                <td><small>{{ r.created_at.strftime('%Y-%m-%d %H:%M') }}</small></td>
                <td><a href="{{ url_for('wiki.view', slug=r.page.slug) }}">{{ r.title }}</a></td>
                <td><a href="{{ url_for('wiki.view_revision', slug=r.page.slug, rev_num=r.rev_num) }}">r{{ r.rev_num }}</a></td>
                <td>
                    {% if r.author %}<a href="{{ url_for('profile.view_user', username=r.author.username) }}">{{ r.author.username }}</a>
                    {% else %}<small class="text-muted">{{ r.author_ip or 'anon' }}</small>{% endif %}
                </td>
                <td><small>{{ r.edit_summary or '' }}</small></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>

{% if pagination.pages > 1 %}
<nav class="mt-3">
    <ul class="pagination justify-content-center">
        {% if pagination.has_prev %}
        <li class="page-item"><a class="page-link" href="{{ url_for('wiki.recent', page=pagination.prev_num) }}">«</a></li>
        {% endif %}
        <li class="page-item disabled"><span class="page-link">Page {{ pagination.page }} of {{ pagination.pages }}</span></li>
        {% if pagination.has_next %}
        <li class="page-item"><a class="page-link" href="{{ url_for('wiki.recent', page=pagination.next_num) }}">»</a></li>
        {% endif %}
    </ul>
</nav>
{% endif %}

{% else %}
<div class="alert alert-info">No edits yet.</div>
{% endif %}
{% endblock %}
