{% extends 'base.html' %}
{% load i18n %}

{% block title %}
{% trans 'Blog' %}
{% endblock %}

{% block body %}
{% for post in post_list %}
<article class"media">
  <div class="media-body">
    <h3 class="media-heading"><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h3>
    <p><a class="btn btn-default btn-xs" href="{{ post.category.get_absolute_url }}">{{ post.category }}</a></p>
    <p>{{ post.description }}</p>
  </div>
</article>
{% empty %}
<h2>{% trans 'Sorry, nothing to see yet.' %}</h2>
{% endfor %}

<nav>
  <ul class="pager">
    {% if page_obj.has_previous %}
    <li class="previous"><a href="{% url 'post_list' page=page_obj.previous_page_number %}">&larr; {% trans 'Previous' %}</a></li>
    {% endif %}

    {% if page_obj.has_next %}
    <li class="next"><a href="{% url 'post_list' page=page_obj.next_page_number %}">{% trans 'Next' %} &rarr;</a></li>
    {% endif %}
  </ul>
</nav>

<div>
{% if category_list %}
{% trans 'Categories' %}:
  <ul class="list-inline">
  {% for category in category_list %}
    <li><a class="btn btn-default btn-xs" href="{% url 'category_detail' pk=category.pk %}">{{ category.name }}</a></li>
  {% endfor %}
    <li><a class="btn btn-info btn-xs" href="{% url 'category_list' %}">{% trans 'See all categories' %}</a></li>
  </ul>
</div>
{% endif %}

{% if user.is_staff %}

<hr>

<a href="{% url 'post_create' %}">
  <button class="btn btn-primary">
    <i class="glyphicon glyphicon-plus"></i> {% trans 'New post' %}
  </button>
</a>
{% endif %}

{% endblock %}
