{% extends base %}
{% from 'macro.html' import breadcrumbs with context %}
{% block content %}

<div class="row">
    <div class="span12 story-page" id="story_{{ story.id }}">
        {{- breadcrumbs([[url_for('story.view', pk=story.id), story.title]]) }}

        {% include 'includes/story_control_buttons.html' %}
        <h1 id="story_title">{{ story.title }}
        {% if not story.original %} <sup class="translation">перевод</sup>{% endif %}
            {% if story.finished %} <sup class="complete">завершен</sup>{% endif %}{% if story.freezed %} <sup class="suspended">заморожен</sup>{% endif %}
          </h1>

        <!-- Вывод комментариев: начало -->
        <div id="comments">
            <h3>Комментарии бета-читателей и редакторов (<span id="comments-count">{{ comments_count }}</span>)</h3>
            <form method="POST" action="{{ url_for('story.local_comments_subscribe', pk=story.id) }}" class="subscription-form js-subscription-form">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                Получать новые:
                <label><input type="checkbox" name="email" value="1"{% if sub_comments.email %} checked{% endif %} /> в почте</label>
                <label><input type="checkbox" name="tracker" value="1"{% if sub_comments.tracker %} checked{% endif %} /> на сайте</label>
                <button type="submit" class="btn btn-mini js-subscription-form-submit">Сохранить</button>
            </form>
            <div id="comments-tree" class="comments-tree">
                {% if comments_count > 0 %}
                    {%- include 'includes/comments_tree.html' -%}
                {% endif %}
            </div>
            <div id="comments-pagination" class="pagination center">
                {%- if comments_count > 0 %}
                    {%- include 'includes/comments_pagination_story_local.html' -%}
                {% endif -%}
            </div>
        </div>

        {% if local.bl.can_comment_by(current_user) %}
            <a href="{{ url_for('story_local_comment.add', story_id=story.id) }}" id="comment-add-link" class="comment-add-link">Добавить новый комментарий</a>

            <form id="comment-form" class="comment-form" method="POST" enctype="multipart/form-data" action="{{ url_for('story_local_comment.add', story_id=story.id) }}">
            {% from 'macro.html' import comment_form_content with context %}
            {{ comment_form_content(comment_form, preview_html=preview_html) }}
            </form>
        {% elif current_user.is_authenticated %}
        <h3 id="banned">К сожалению, Вы не можете добавлять комментарии</h3>
        {% else %}
        <a href="{{ url_for('auth.login', next=url_for('story_local_comment.view', story_id=story.id)) }}">Авторизуйтесь</a> для отправки комментария.
        {% endif %}
        <!-- Вывод комментариев: конец -->
    </div>
</div>
{% endblock %}
