diff options
| author | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-13 13:49:15 -0700 |
|---|---|---|
| committer | Emma Terzioglu <emreterzioglu49@gmail.com> | 2026-03-13 13:49:15 -0700 |
| commit | 7a33856a527aebbd8d2a624c6d5937c25c9a1d90 (patch) | |
| tree | 855c642394e7ba1de40b8bb8737be12bec0aedaf /src/templates/admin | |
initial commit
new website repo yay!!!
Diffstat (limited to 'src/templates/admin')
| -rw-r--r-- | src/templates/admin/blog.html | 37 | ||||
| -rw-r--r-- | src/templates/admin/blog_create.html | 32 | ||||
| -rw-r--r-- | src/templates/admin/blog_edit.html | 42 | ||||
| -rw-r--r-- | src/templates/admin/index.html | 11 | ||||
| -rw-r--r-- | src/templates/admin/login.html | 36 |
5 files changed, 158 insertions, 0 deletions
diff --git a/src/templates/admin/blog.html b/src/templates/admin/blog.html new file mode 100644 index 0000000..8cb1433 --- /dev/null +++ b/src/templates/admin/blog.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} + +{% block head %} +{{ super() }} + +<style> +#main { + gap: 12px; +} + +#create-new { + background-color: white; + color: black; + border: 1px white solid; +} + +a.container { + color: inherit; +} +</style> +{% endblock %} + +{% block content %} + +<a id="create-new" href="/admin/blog/create">create new post</a> + +{% for post in posts|sort(attribute="id", reverse=True) %} + +<a class="container" href="/admin/blog/{{ post.id }}"> + <p>id: {{ post.id }}</p> + <h2>{{ post.title }}</h2> + <p>{{ post.description or "" }}</p> +</a> + +{% endfor %} + +{% endblock %} diff --git a/src/templates/admin/blog_create.html b/src/templates/admin/blog_create.html new file mode 100644 index 0000000..ac4740b --- /dev/null +++ b/src/templates/admin/blog_create.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block head %} +{{ super() }} + +<link rel="stylesheet" href="/static/stylesheets/admin_blog.css"> +{% endblock %} + +{% block content %} + +<h1>create a post!</h1> + +<form class="flex-col" method="post"> + <div class="flex-col" style="margin-bottom: 12px;"> + <label for="title">title:</label> + <input type="text" name="title" /> + + <label for="description">description:</label> + <input type="text" name="description" /> + </div> + + <textarea placeholder="edit here" name="text"></textarea> + + <div class="flex-row" style="margin: 12px 0; gap: 6px;"> + <input type="checkbox" name="public" /> + <label for="public">make public</label> + </div> + + <input type="submit" value="create" /> +</form> + +{% endblock %} diff --git a/src/templates/admin/blog_edit.html b/src/templates/admin/blog_edit.html new file mode 100644 index 0000000..99c3d9c --- /dev/null +++ b/src/templates/admin/blog_edit.html @@ -0,0 +1,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 %} diff --git a/src/templates/admin/index.html b/src/templates/admin/index.html new file mode 100644 index 0000000..11e414d --- /dev/null +++ b/src/templates/admin/index.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block content %} + +<h1>welcome to admin mode, me!</h1> + +<p>safety button to sign out:</p> + +<a href="/admin/logout">here</a> + +{% endblock %} diff --git a/src/templates/admin/login.html b/src/templates/admin/login.html new file mode 100644 index 0000000..e37e046 --- /dev/null +++ b/src/templates/admin/login.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} + +{% block head %} + +{{ super() }} + +<script src="/static/js/htmx.min.js"></script> + +<script> +htmx.config.responseHandling = [ + {code: "204", swap: false}, + {code: "3..", swap: false}, + {code: "[45]..", swap: true, error: false}, + {code: "...", swap: false}, +]; +</script> + +<style> +#error-msg p { + color: red; + max-width: 400px; + text-align: center; +} +</style> +{% endblock %} + +{% block content %} +<form hx-post="/admin/login" hx-swap="innerHTML" hx-target="#error-msg"> + <label for="password">Password:</label> + <input type="password" name="password" /> + + <input type="submit" value="Submit" /> + + <div id="error-msg"></div> +</form> +{% endblock %} |
