{% extends 'base.html' %}
{% load url from future %}

{% block contents %}
<h1>Entry list</h1>

<section id="entry-list">
    {% for object in object_list %}
    <article class="entry">
        <h1><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></h1>
        {% if user.is_authenticated %}
        <nav>
            <ul>
                <li class="entry-update"><a href="{% url 'blog-entry-update' pk=object.pk %}">Update</a></li>
                <li class="entry-delete"><a href="{% url 'blog-entry-delete' pk=object.pk %}">Delete</a></li>
            </ul>
        </nav>
        {% endif %}

        {% if object.author == object.updated_by %}
            <p class="subscription">Written by {{ object.author }}</p>
        {% else %}
            <p class="subscription">Originally written by {{ object.author }} and updated by {{ object.updated_by|default:'Anonymous' }}</p>
        {% endif %}

        <section class="body">
            {{ object.body|linebreaks|truncatewords_html:50 }}
        </section>
    </article>
    {% endfor %}
</section>
{% endblock %}

