{% load i18n static marcus_tags %}
{% include "marcus/blocks/comments.html" %}

<a name="comment-form"></a>
{% if form %}
    <form action="{% iurl 'marcus-article' article.published.year article.published.month article.published.day article.slug %}#comment-form"
          method="post" id="comment-form">
        <div class="comment-form-input">
            {% if request.user.is_authenticated %}
                <div style="float:left;margin-right:5px">{{ request.user }}</div>
            {% else %}
                <div style="float:left;margin-right:5px">
                    <input id="{{ form.name.auto_id }}" name="{{ form.name.name }}" placeholder="{% trans form.name.label %}"
                           value="{{ form.name.value|default:guest_name }}"
                           class="{% if form.errors.name %}form-error{% endif %}" />
                    <div class="form-errors">
                        {% for error in form.errors.name %}
                            <small>{{ error }}</small>
                        {% endfor %}
                    </div>
                </div>
                <div>
                    <input id="{{ form.xemail.auto_id }}" name="{{ form.xemail.name }}" placeholder="{% trans form.xemail.label %}"
                           value="{{ form.xemail.value|default:guest_email }}"
                           class="{% if form.errors.xemail %}form-error{% endif %}" />
                    <div class="form-errors">
                        {% for error in form.errors.xemail %}
                            <small>{{ error }}</small>
                        {% endfor %}
                    </div>
                </div>
            {% endif %}
        </div>
        <div class="comment-form-input">
            <textarea id="{{ form.text.auto_id }}" name="{{ form.text.name }}" placeholder="{% trans form.text.label %}"
                      class="{% if form.errors.text %}form-error{% endif %}">{{ form.text.value|default:"" }}</textarea>
            <div class="form-errors">
                {% for error in form.errors.text %}
                    <small>{{ error }}</small>
                {% endfor %}
            </div>
        </div>
        <input type="submit" value="{% trans "Send to moderation" %}" />
    </form>
    <div style="margin-left: 800px;">
        <img src="{% static "images/markdown-legend.png" %}" alt="Markdown" />
    </div>
    <br clear="all" />
    <script type="text/javascript">
        var form = document.getElementById('comment-form');
        form.innerHTML = form.innerHTML + "{% csrf_token %}";
    </script>
{% else %}
    <p>{% trans "The article is closed for comments" %}</p>
{% endif %}
