samey/templates/pages/posts.html
2025-04-14 23:12:14 -03:00

80 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Posts - {{ application_name }}</title>
<meta property="og:site_name" content="{{ application_name }}" />
{% include "fragments/common_headers.html" %}
</head>
<body>
{% if age_confirmation %}{% include "fragments/age_restricted_check.html"
%}{% endif %}
<div><a href="/">&lt; To home</a></div>
<article>
<h2>Search</h2>
<form method="get" action="/posts">
{% let tags_value = tags_text.clone().unwrap_or("".into()) %} {% include "fragments/tags_input.html" %}
<div
hx-trigger="keyup[key=='Escape'] from:previous .tags"
hx-target="next .tags-autocomplete"
hx-swap="innerHTML"
hx-delete="/remove"
hidden
></div>
<ul class="reset tags-autocomplete" id="search-autocomplete"></ul>
<button type="submit">Search</button>
</form>
</article>
{% if let Some(tags) = tags %}
{% if !tags.is_empty() %}
<article>
<h2>Tags</h2>
<ul>
{% for tag in tags %}
<li><a href="/posts?tags={{ tag }}">{{ tag }}</a></li>
{% endfor %}
</ul>
</article>
{% endif %}
{% endif %}
<main>
<h1>Posts</h1>
{% if posts.is_empty() %}
<div>No posts found!</div>
{% else %}
<div>
<ul class="reset flex">
{% 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="{% if let Some(tags) = post.tags %}{{ tags }}{% endif %}"
>
<img src="/files/{{ post.thumbnail }}" />
<div class="flex">
<div>{{ post.rating | upper }}</div>
<div>{{ post.media_type }}</div>
</div>
</a>
</li>
{% endfor %}
</ul>
</div>
<hr>
<div>
<div class="flex"><span>Pages</span></div>
<ul class="reset flex">
{% for i in 1..=page_count %}
<li>
{% if i == page as u64 %}
<b>{{ i }}</b>
{% else %}
<a href="{% if let Some(tags_text) = tags_text %}/posts/{{ i }}?tags={{ tags_text.replace(' ', "+") }}{% else %}/posts/{{ i }}{% endif %}">{{ i }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</main>
</body>
</html>