60 lines
1.8 KiB
HTML
60 lines
1.8 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>Posts - {{ application_name }}</title>
|
|
<meta name="generator" content="Samey {{ env!("CARGO_PKG_VERSION") }}" />
|
|
</head>
|
|
<body>
|
|
<article>
|
|
<h2>Search</h2>
|
|
<form method="get" action="/posts">
|
|
<input
|
|
class="tags"
|
|
type="text"
|
|
id="search-tags"
|
|
name="tags"
|
|
hx-post="/search_tags"
|
|
hx-trigger="input changed"
|
|
hx-target="next .tags-autocomplete"
|
|
hx-vals="js:{selection_end: event.target.selectionEnd}"
|
|
hx-on::after-settle="this.focus(); this.setSelectionRange(-1, -1);"
|
|
autofocus
|
|
/>
|
|
<ul class="tags-autocomplete" id="search-autocomplete"></ul>
|
|
<button type="submit">Search</button>
|
|
</form>
|
|
</article>
|
|
<article>
|
|
<h2>Tags</h2>
|
|
<ul>
|
|
{% if let Some(tags) = tags %} {% for tag in tags %}
|
|
<li><a href="/posts?tags={{ tag }}">{{ tag }}</a></li>
|
|
{% endfor %} {% endif %}
|
|
</ul>
|
|
</article>
|
|
<main>
|
|
<h1>Viewing posts</h1>
|
|
{% if posts.is_empty() %}
|
|
<div>No posts found!</div>
|
|
{% else %}
|
|
<ul>
|
|
{% for post in posts %}
|
|
<li>
|
|
<a
|
|
href="{% if let Some(tags_text) = tags_text %}/post/{{ post.id }}?tags={{ tags_text.replace(' ', "+") }}{% else %}/post/{{ post.id }}{% endif %}"
|
|
title="{{ post.tags }}"
|
|
>
|
|
<img src="/files/{{ post.thumbnail }}" />
|
|
<div>{{ post.rating | upper }}</div>
|
|
</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
<div>Page {{ page }} of {{ page_count }}</div>
|
|
{% endif %}
|
|
</main>
|
|
</body>
|
|
</html>
|