41 lines
1.2 KiB
HTML
41 lines
1.2 KiB
HTML
{% extends 'base.html' %}
|
|
|
|
{% block header %}
|
|
<h1>{% block title %}Today in history{% 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>
|
|
<h1>{{ post['title'] }}</h1>
|
|
<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 %}
|
|
<button class="toggle-content" onclick="toggleContent(this)">Expand</button>
|
|
</header>
|
|
<p class="body" style="display: none;">{{ post['body'] }}</p>
|
|
</article>
|
|
{% if not loop.last %}
|
|
<hr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
<script>
|
|
function toggleContent(button) {
|
|
const body = button.parentElement.nextElementSibling;
|
|
if (body.style.display === "none") {
|
|
body.style.display = "block";
|
|
button.textContent = "Collapse";
|
|
} else {
|
|
body.style.display = "none";
|
|
button.textContent = "Expand";
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|