summaryrefslogtreecommitdiff
path: root/src/templates/blog/post.html
blob: 92c48a2e8c7369d1fd785563277902d7ab871cf0 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{% extends "base.html" %}

{% block head %}
{{ super() }}

<style>
    article {
        width: 600px;
        text-align: left;
    }

    header {
        padding: 14px;
        background-color: rgba(255, 255, 255, 0.6);
        border-bottom: 2px solid black;
    }

    textarea {
        resize: none;
        width: 250px;
        height: 90px;
    }

    #comments {
        background-color: rgba(255, 255, 255, 0.6);
        padding: 12px 20px;
        width: 400px;
    }

    .comment {
        border-bottom: 1px solid black;
    }

    .comment:last-child {
        border-bottom: none;
    }

    .created-at {
        font-size: 10px;
        color: #333;
    }
</style>

<script src="/static/js/htmx.min.js"></script>
{% endblock %}

{% block content %}

<article>
    <header>
        <h1>{{ post.title }}</h1>

        {% if post.description %}
        <p>{{ post.description }}</p>
        {% endif %}

        <p>posted {{ post.created_at.strftime("%a %d %b %Y at %H:%M:%S") }}</p>
    </header>

    {{ post.text|safe }}
</article>

<h3>comments</h3>

<form
    hx-post="/blog/{{ post.id.hex }}/comments"
    hx-target="#comments"
    hx-on::after-request="if(event.detail.successful) this.reset()"
    class="flex-col"
    style="gap: 6px; margin-bottom: 12px;"
>
    <span class="flex-col">
        <input type="text" name="author" placeholder="author" />
    </span>

    <span class="flex-col">
        <textarea placeholder="text" name="text"></textarea>
    </span>

    <input type="submit" value="create" />
</form>

<div
    id="comments"
    hx-get="/blog/{{ post.id.hex }}/comments"
    hx-trigger="revealed, newPost from:body"
></div>

{% endblock %}