samey/templates/index.html
2025-04-10 07:06:34 -03:00

76 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<title>Samey</title>
</head>
<body>
<main>
<article>
<h2>Search</h2>
<form method="get" action="/posts/1">
<input
class="tags"
type="text"
id="search-tags"
name="tags"
hx-post="/search_tags"
hx-trigger="input changed delay:400ms"
hx-target="next .tags-autocomplete"
hx-on::after-settle="this.focus(); this.setSelectionRange(-1, -1);"
value=""
autofocus
/>
<ul class="tags-autocomplete" id="search-autocomplete"></ul>
<button type="submit">Search</button>
</form>
</article>
{% if let Some(user) = user %}
<article>
<h2>Upload media</h2>
<form method="post" action="/upload" enctype="multipart/form-data">
<input
class="tags"
type="text"
id="upload-tags"
name="tags"
hx-post="/search_tags"
hx-trigger="input changed delay:400ms"
hx-target="next .tags-autocomplete"
hx-on::after-settle="this.focus(); this.setSelectionRange(-1, -1);"
value=""
/>
<ul class="tags-autocomplete" id="upload-autocomplete"></ul>
<input
type="file"
id="media-file"
name="media-file"
accept=".jpg, .jpeg, .png, .webp, .gif"
/>
<button type="submit">Submit</button>
</form>
</article>
<article>
<a href="/logout">Log out</a>
</article>
{% else %}
<article>
<h2>Log in</h2>
<form method="post" action="/login">
<div>
<label>Username</label>
<input id="username" type="text" name="username" />
</div>
<div>
<label>Password</label>
<input id="password" type="password" name="password" />
</div>
<button type="submit">Submit</button>
</form>
</article>
{% endif %}
</main>
</body>
</html>