summaryrefslogtreecommitdiffstats
path: root/flaskr/templates/blog/index.html
blob: 0fb2e801cf03a93640d0b0ccfc01e483c95d51aa (plain)
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
{% extends 'base.html' %}


{% block header %}
  <h1>{% block title %}Posts{% endblock %}</h1>
  {% if g.user %}
    <a class="action" href="{{ url_for('blog.create') }}">New</a>
  {% endif %}
{% endblock %}

{% block content %}
  {% for post in posts %}
    <article class="post">
      <header>
        <div>
          {% if post['title'].__len__() > 80 %}
            <h1><abbr title="{{ post['title'] }}">{{ post['title'][:80] }}</abbr></h1>
          {% else %}
            <h1>{{ post['title'] }}</h1>
          {% endif %}
          <div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div>
        </div>
        {% if g.user['id'] == post['author_id'] %}
          <a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
        {% endif %}
      </header>
      <p class="body">{{ post['body'] }}</p>
    </article>
    {% if not loop.last %}
      {# Separate posts with a line #}
      <hr>
    {% endif %}
  {% endfor %}
{% endblock %}