{% extends "base.html" %}
{% load i18n comments thumbnail %}

{% block title %}
 {% trans 'Article Archive' %}
 {% if active_category %} - {{active_category.name}}{% endif %}
 {% if month %}{{ month|date:'F Y' }}{% elif year %}{{year}}{% endif %}
{% endblock %}

{% block jumbotron_background %}{% spaceless %}
    {% if active_category %}
        {{ active_category.image.url }}
    {% else %}
        {{STATIC_URL}}img/teaser/{{current_top_page.slug}}.jpg
    {% endif %}
{% endspaceless %}{% endblock %}

{% block teaser %}
<h1>
   {% trans 'Article Archive' %}
   {% if active_category %} - {{active_category.name}}{% endif %}
   {% if month %}{{ month|date:'F Y' }}{% elif year %}{{year}}{% endif %}
</h1>
<div id="teaser_text">
    {% if active_category %}
        <p>{{ active_category.description }}</p>
    {% else %}
        {{current_page.content|safe}}
    {% endif %}
</div>
{% endblock %}

{% block redbox %}
  {% block date_list %}
  <h2>{% trans "Archive" %} {{year}}</h2>
  <ul class="fa-ul">
  {% if active_category %}
   {% for date in date_list %}
    <li><span class="fa fa-calendar-o fa-fw"></span> <a
      href="{% url 'article-archive' category=active_category.slug year=date|date:'Y' %}">{{active_category.name}}:
      {{ date|date:'Y' }}</a></li>
   {% endfor %}
  {% else %}
   {% for date in date_list %}
    <li><span class="fa fa-calendar-o fa-fw"></span> <a href="{% url 'article-archive' year=date|date:'Y' %}">
      {{ date|date:'Y' }}</a></li>
   {% endfor %}
  {% endif %}
  </ul>
     {% endblock %}
{% endblock %}

{% block navigation %}
 <ul id="navigation">
  <li><a href="{{current_top_page.get_absolute_url}}"
         {% if not active_category %} class="active" {% endif %}>{% trans 'All Categories' %}</a></li>
 {% for category in categories %}
  <li><a href="{% url 'article-archive' category=category.slug %}"
       {% ifequal category.slug active_category.slug  %} class="active"{% endifequal %}>{{ category.name }}</a></li>
{% endfor %}
 </ul>
{% endblock %}

{% block maincontent %}
 <div class="grid_8">
  {% for article in article_list %}
    {% get_comment_count for article as comment_count %}
    <article class="article">
    <h3><a href="{{article.get_absolute_url}}">{{article.headline}}</a></h3>
    <ul class="info">
     <li><span class="fa fa-calendar-o" title="{% trans 'created on' %}"></span> <time
       datetime="{{article.date_created|date:'c'}}">{{ article.date_created|date }}</time></li>
     <li><span class="fa fa-user" title="{% trans 'by' %}"></span> {{ article.author }}</li>
     <li><span class="fa fa-comments" title="{% trans 'comments' %}"></span> <a
       href="{{article.get_absolute_url}}#comments" >{{comment_count}} {% trans "comments" %}</a></li>
    </ul>
    <a href="{{article.get_absolute_url}}"><img src="{{article.get_image|thumbnail_url:'article'}}"
                                                alt="{{article.category}}:" class="posting_image" width="200"
                                                height="120"/></a>
    {{article.content|truncatewords_html:50}}
    <p class="more_link"><a href="{{article.get_absolute_url}}" class="button">{% trans "Read More"%}
      <span class="fa fa-arrow-right"></span></a>
    </p>
    </article>
  {% empty %}
    <p>{% trans "We're sorry. Your search yielded no results." %}</p>
  {% endfor %}
</div>
<aside class="grid_4">
 {% for feed in feeds %}
  <h2><a href="{{feed.public_url}}">{{feed.title}}</a></h2>
  <ul>
  {% for item in feed.feed_items.all|slice:":10" %}
   <li><a href="{{item.link}}">{{item.title}}</a></li>
  {% endfor %}
  </ul>
{% endfor %}
</aside>

{% endblock %}

{% block additional_buttonbar %}
{% if perms.content.add_article %}
 <a href="{% url 'add-article' %}" class="button"><span class="fa fa-newspaper-o"></span> {% trans "Add Article" %}</a>
{% endif %}
{% endblock %}
