{% extends "blogorama/base.html" %}

{% load static %}
{% load i18n %}
{% load crispy_forms_tags %}
{% load markdownify %}

{% block title %}
    - Blog Posts
{% endblock title %}
{% comment %} {% block extra_css %}
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
{% endblock extra_css %}

{% block extra_head_js %}
    <script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
{% endblock extra_head_js %} {% endcomment %}

{% block content %}
    <h1>{{ object.title }}</h1>
    <p>{{ object.content|markdownify }}</p>
    {% if request.user.is_authenticated and request.user.id == object.author_id %}
        <p>
            <a href={% url "blogorama_post-update" slug=object.slug %}>Edit Post</a>
        </p>
    {% endif %}
    {% if comments and not object.hide_responses %}
        <hr>
        <h3>Comments</h3>
        {% for comment in comments %}
            <div class="row">
                <div class="col">{{ comment.content|markdownify }}</div>
            </div>
        {% endfor %}
        <hr>
    {% endif %}
    {% if request.user.is_authenticated and perms.blogorama.add_comment and not object.locked %}
        <form method="post">
            {% csrf_token %}
            {{ form|crispy }}
            <input class="btn btn-primary" type="submit" value="Add Comment"/>
            <a class="btn btn-outline-secondary" href={{ object.get_absolute_url }}>Cancel</a>
        </form>
    {% endif %}
{% endblock content %}
{% comment %} {% block extra_js %}
    <script>const easyMDE = new EasyMDE();</script>
{% endblock extra_js %} {% endcomment %}
