summaryrefslogtreecommitdiff
path: root/templates/categories.html
blob: bc124f8daf16a822d64d17e5bc7e70008dbcea6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{% extends "base.html" %}

{% block meta %}
  {{ super() }}
  <meta property="og:type" content="website">
{% endblock %}
{% block styles %}
  {{ super() }}
  <link rel="stylesheet"
        type="text/css"
        href="{{ '/static/css/categories.css'|asseturl }}">
{% endblock %}
{% set title = "Categories" %}
{% set description = "Browse the main themes and categories of posts on Still Thinking About It." %}
{% block content %}
  <article>
    <header>
      <h2>Categories</h2>
    </header>
    <ul>
      {% set sorted = [] %}
      {% for category in this.children.order_by('name') %}
        {% set post_count = category.children.count() %}
        {% if post_count > 0 %}
          {% set _ = sorted.append((post_count, category)) %}
        {% endif %}
      {% endfor %}
      {% for post_count, category in sorted|sort(attribute='0', reverse=True) %}
        {% set last_post = category.children.order_by('-publication_date').first() %}
        <li>
          <a href="{{ category|url }}">
            <h3>{{ category.name }}</h3>
            <dl>
              <div>
                <dt>Posts:</dt>
                <dd>
                  {{ post_count }}
                </dd>
              </div>
              {% if last_post %}
                <div>
                  <dt>Last post:</dt>
                  <dd>
                    <time datetime="{{ last_post.publication_date }}">{{ last_post.publication_date }}</time>
                  </dd>
                </div>
              {% endif %}
            </dl>
          </a>
        </li>
      {% endfor %}
    </ul>
  </article>
{% endblock %}