{% extends "base.html" %}
{% load core_tags %}
{% load static from staticfiles %}

{% block title %}All snippets{% if months %} last {{ months }} months{% endif %}{% endblock %}

{% block content_header %}All snippets{% if months %} last {{ months }} months{% endif %}{% endblock %}

{% block content %}
  <ul class="snippet_filter">
    <li{% if not months %} class="active"{% endif %}><a href="{{ request.path }}">Any time</a></li>
    <li{% if months == 3 %} class="active"{% endif %}><a href="{{ request.path }}?months=3">3 months</a></li>
    <li{% if months == 6 %} class="active"{% endif %}><a href="{{ request.path }}?months=6">6 months</a></li>
    <li{% if months == 12 %} class="active"{% endif %}><a href="{{ request.path }}?months=12">1 year</a></li>
  </ul>
  {% if object_list %}
    <ul class="snippet_list">
    {% for snippet in object_list %}
      <li>
        <a href="{{ snippet.get_absolute_url }}">{% if not snippet.title|strip %}Untitled{% else %}{{ snippet.title }}{% endif %}</a> by <a href="{% url 'cab_author_snippets' username=snippet.author.username %}">{{ snippet.author.username }}</a>
        <p class="details">{{ snippet.pub_date|timesince }} ago, <span class="rating-{% if snippet.rating_score >= 0 %}positive{% else %}negative{% endif %}">{% if snippet.rating_score >= 0 %}+{% endif %}{{ snippet.rating_score }}</span></p>
      </li>
    {% endfor %}
    </ul>
    <p class="pagination">
      {% if has_previous %}
        <a href="?page={{ previous }}{% if months %}&amp;months={{ months }}{% endif %}">&lt; Previous {{ results_per_page }}</a>
      {% endif %}
      &nbsp;&nbsp;
      {% if has_next %}
        <a href="?page={{ next }}{% if months %}&amp;months={{ months }}{% endif %}">Next {{ results_per_page }} &gt;</a>
      {% endif %}
    </p>
  {% else %}
    <p class="empty">No snippets posted yet.</p>
  {% endif %}
{% endblock %}

{% block sidebar %}
  <p>{{ hits }} snippet{{ hits|pluralize }} posted so far.</p>
  <p><a rel="alternate" href="{% url 'cab_feed_latest' %}" type="application/atom+xml"><img src="{% static "img/feed-icon-10x10.png" %}" alt="" /> Feed of latest snippets</a></p>
{% endblock %}
