flask/flaskr/templates/blog/index.html

49 lines
1.5 KiB
HTML
Raw Normal View History

2018-02-09 14:39:05 -08:00
{% extends 'base.html' %}
{% block header %}
<h1 id="toggle-all">Posts</h1>
2018-02-09 14:39:05 -08:00
{% 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 class="post-header">
2018-02-09 14:39:05 -08:00
<div>
<h1 onclick="togglePostBody({{ post['id'] }})">{{ post['title'] }}</h1>
2018-02-09 14:39:05 -08:00
<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>
2024-09-09 23:35:40 +01:00
<p class="body" id="post-body-{{ post['id'] }}">{{ post['body']|safe }}</p>
2018-02-09 14:39:05 -08:00
</article>
{% if not loop.last %}
<hr>
{% endif %}
{% endfor %}
<div class="pagination">
{% if page > 1 %}
<a href="{{ url_for('blog.index', page=1) }}"><<</a>
<a href="{{ url_for('blog.index', page=page-1) }}"><</a>
{% endif %}
{% for p in range(1, total_pages + 1) %}
{% if p == page %}
<strong>{{ p }}</strong>
{% else %}
<a href="{{ url_for('blog.index', page=p) }}">{{ p }}</a>
{% endif %}
{% endfor %}
{% if page < total_pages %}
<a href="{{ url_for('blog.index', page=page+1) }}">></a>
<a href="{{ url_for('blog.index', page=total_pages) }}">>></a>
{% endif %}
</div>
<script src="{{ url_for('static', filename='collapse.js') }}"></script>
2018-02-09 14:39:05 -08:00
{% endblock %}