summaryrefslogtreecommitdiff
path: root/src/templates/admin/blog_edit.html
blob: 99c3d9c183f02f2a4c17ec1f0bd3a866d64e0710 (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
{% extends "base.html" %}

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

<link rel="stylesheet" href="/static/stylesheets/admin_blog.css">
{% endblock %}

{% block content %}

<h1>edit a post!</h1>

<button id="delete-post">delete</button>

<form class="flex-col" method="post">
    <div class="flex-col" style="margin-bottom: 12px;">
        <label for="title">title:</label>
        <input type="text" name="title" value="{{ post.title }}" />

        <label for="description">description:</label>
        <input type="text" name="description" value="{{ post.description or '' }}" />
    </div>

    <textarea placeholder="edit here" name="text">{{ post.original }}</textarea>

    <div class="flex-row" style="margin: 12px 0; gap: 6px;">
        <input type="checkbox" name="public" {{ "checked" if post.public else "" }}  />
        <label for="public">make public</label>
    </div>

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

<script>
document.getElementById("delete-post").onclick = async (e) => {
  origin = window.location.origin
  await fetch(`${origin}/admin/blog/{{ post.id }}`, { method: "DELETE" });
  window.location.href = `${origin}/admin/blog`;
};
</script>

{% endblock %}