<!DOCTYPE html>
{% extends BASE_TEMPLATE %}
{% load staticfiles %}
{% load djeddit_tags %}
{% block title %}
    <ol class="breadcrumb">
        <li><a href="{% url 'topics' %}">Home</a></li>
        <li><a href="{% url 'topicPage' thread.topic.urlTitle %}">{{ thread.topic.title }}</a></li>
    </ol>
{% endblock %}
{% block content %}
    <div class="row">
                <div class="bs-callout">
                    <div class="bs-callout-heading">
                        <h3>
                            {% if thread.url %}
                                <a href="{{ thread.url }}">{{ thread.title }}</a>
                            {% else %}
                                {{ thread.title }}
                            {% endif %}
                        </h3>
                        <div class="text-muted inline">
                            Submitted by {% postUserName thread.op.created_by %} on {{ thread.op.created_on }}
                        </div>
                    </div>
                    {% with thread.op as node %}
                        {% include 'djeddit/post_item.html' %}
                    {% endwith %}
                </div>
        <div id="comments-callout" class="bs-callout">
            <h4 class="callout-title">{% getAmount nodes|length 'comment' %}</h4>
            {% include 'djeddit/thread_recursetree.html' %}
            {% with thread.op|missingRepliesCount:nodes as missingCount %}
                {% if missingCount %}
                    <div class="full-line additional-replies" style="margin-left:15px">
                        <br>
                        <a href="javascript:window.postFuncs.loadAdditionalReplies(
                        $('#comments-callout').find('>.additional-replies'), null, '{{ thread.op.uid }}')">
                            Load {% getAmount missingCount 'comment' infix='more' %}
                        </a>
                    </div>
                {% endif %}
            {% endwith %}
        </div>
    </div>
{% endblock %}
{% block scripts %}
    <script src="{% static 'djeddit/js/util.js' %}"></script>
    <script src="{% static 'djeddit/js/thread.js' %}"></script>
    <script type="text/javascript">
    window.THREAD_URLS = {
        editPost: "{% url 'editPost' %}",
        deletePost: "{% url 'deletePost'  %}",
        votePost: "{% url 'votePost' %}",
        loadAdditionalReplies: "{% url 'loadAdditionalReplies' %}"
      };

</script>
{% endblock %}
