{% set page_title = "Topic Tracker" %}
{% set active_forum_nav=True %}

{% extends theme("layout.html") %}
{% from theme('macros.html') import render_pagination %}

{% block content %}
<ul class="breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">Forum</a></li>
    <li class="active">Tracked Topics</li>
</ul>

<div class="pull-left" style="padding-bottom: 10px">
    {{ render_pagination(topics, url_for('forum.topictracker')) }}
</div> <!-- end span pagination -->


<table class="table table-bordered">
    <thead>
        <tr>
            <th colspan="5">
                Topic Tracker
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="2">Thread</td>

            <td>Posts</td>

            <td>Views</td>

            <td>Last Post</td>
        </tr>

        {% for topic, topicread in topics.items %}
        <tr>
            <td width="4%">

            {% if topic|topic_is_unread(topicread, current_user) %}
                <span class="fa fa-comment" style="font-size: 2em"></span>
            {% else %}
                <span class="fa fa-comment-o" style="font-size: 2em"></span>
            {% endif %}

            </td>
            <td>
                <div>
                    <a href="{{ topic.url }}">{{ topic.title }}</a> <br />
                    {% if topic.user_id %}
                    <small>by <a href="{{ topic.user.url }}">{{ topic.user.username }}</a></small>
                    {% else %}
                    <small>by {{ topic.username }}</small>
                    {% endif %}
                </div>
            </td>
            <td>
                {{ topic.post_count }}
            </td>
            <td>
                {{ topic.views }}
            </td>
            <td>
                <a href="{{ topic.last_post.url }}">{{ topic.last_post.date_created|time_since }}</a><br />
                {% if topic.last_post.user_id %}
                <small>by <a href="{{ topic.last_post.user.url }}">{{ topic.last_post.user.username }}</a></small>
                {% else %}
                {{ topic.last_post.username }}
                {% endif %}
            </td>
        </tr>
        {% else %}
        <tr>
            <td colspan="5">
                No Topics so far.
            </td>
        </tr>
        {% endfor %}

    </tbody>
</table>

{% endblock %}
