{% extends base %}
{% from 'macro.html' import breadcrumbs with context %}
{% block content %}
<div class="row">
    <div class="span8">
        {{- breadcrumbs() }}
        <h2>{{ page_title }}</h2>

        <div class="news-list">
        {% for newsitem in news %}
        <div class="newsitem newsitem-listitem" id="newsitem_{{ newsitem.id }}">
            <a href="{{ url_for('news.show', name=newsitem.name) }}" class="newsitem-title-link">{{ newsitem.title }}</a>
            {% if current_user.is_staff -%}
                <a class="btn btn-warning btn-mini" href="{{ url_for('admin_news.update', pk=newsitem.id) }}">{{ _('Edit') }}</a>
            {%- endif %}
            <br/>
            <time datetime="{{ newsitem.date.strftime('%Y-%m-%dT%H:%M:%SZ') }}" class="newsitem-date">
                {{- newsitem.date|datetimeformat('d MMMM Y') -}}, {{ ngettext("%(num)d comment", "%(num)d comments", newsitem.comments_count) }}
            </time>
        </div>
        {% endfor %}
        </div>

        <div class="pagination center">
            {% for page_id in page_obj.iter_pages() %}
                <a href="{{ url_for('news.index', page=page_id) }}" class="btn{% if page_id == page_obj.number %} btn-primary{% endif %}" name="page">{{ page_id }}</a>
            {% endfor %}
        </div>

        {{- breadcrumbs() }}
    </div>
</div>
{% endblock %}
