Initial version of pools
This commit is contained in:
parent
fe7edb93ad
commit
2b6b1f30f4
21 changed files with 577 additions and 36 deletions
9
templates/add_post_to_pool.html
Normal file
9
templates/add_post_to_pool.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{% include "pool_posts.html" %}
|
||||
<input
|
||||
id="add-post-input"
|
||||
name="post_id"
|
||||
type="text"
|
||||
pattern="[0-9]*"
|
||||
hx-swap-oob="outerHTML"
|
||||
value=""
|
||||
/>
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<textarea name="description">{% if let Some(description) = post.description %}{{ description }}{% endif %}</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label>Is public?</label>
|
||||
<label>Is public post?</label>
|
||||
<input name="is_public" type="checkbox" {% if post.is_public %}checked{% endif %} value="true" />
|
||||
</div>
|
||||
<div>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
</div>
|
||||
<div>
|
||||
<label>Parent post</label>
|
||||
<input name="parent_post" type="text" value="{% if let Some(parent_id) = post.parent_id %}{{ parent_id }}{% endif %}" />
|
||||
<input name="parent_post" type="text" pattern="[0-9]*" value="{% if let Some(parent_id) = post.parent_id %}{{ parent_id }}{% endif %}" />
|
||||
</div>
|
||||
<div>
|
||||
<button>Submit</button>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Samey</h1>
|
||||
<article>
|
||||
<h2>Search</h2>
|
||||
<form method="get" action="/posts/1">
|
||||
|
|
@ -27,6 +28,10 @@
|
|||
<button type="submit">Search</button>
|
||||
</form>
|
||||
</article>
|
||||
<article>
|
||||
<a href="/posts/1">Posts</a>
|
||||
<a href="/pools/1">Pools</a>
|
||||
</article>
|
||||
{% if let Some(user) = user %}
|
||||
<article>
|
||||
<h2>Upload media</h2>
|
||||
|
|
@ -37,8 +42,9 @@
|
|||
id="upload-tags"
|
||||
name="tags"
|
||||
hx-post="/search_tags"
|
||||
hx-trigger="input changed delay:400ms"
|
||||
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);"
|
||||
/>
|
||||
<ul class="tags-autocomplete" id="upload-autocomplete"></ul>
|
||||
|
|
@ -54,7 +60,13 @@
|
|||
<article>
|
||||
<h2>Create pool</h2>
|
||||
<form method="post" action="/pool">
|
||||
<input class="tags" type="text" id="pool-name" name="name" />
|
||||
<input
|
||||
class="pool"
|
||||
type="text"
|
||||
id="pool"
|
||||
name="pool"
|
||||
maxlength="100"
|
||||
/>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</article>
|
||||
|
|
|
|||
65
templates/pool.html
Normal file
65
templates/pool.html
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!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>
|
||||
<script src=" https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js "></script>
|
||||
<title>Pool - {{ pool.name }} - Samey</title>
|
||||
<meta property="og:title" content="{{ pool.name }}" />
|
||||
<meta property="og:url" content="/pool/{{ pool.id }}" />
|
||||
<meta property="twitter:title" content="{{ pool.name }}" />
|
||||
<meta
|
||||
property="og:description"
|
||||
content="Pool with {{ posts.len() }} post(s)."
|
||||
/>
|
||||
{% if let Some(post) = posts.first() %}
|
||||
<meta property="og:image" content="/files/{{ post.thumbnail }}" />
|
||||
<meta property="twitter:image:src" content="/files/{{ post.thumbnail }}" />
|
||||
{% endif %}
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Pool - {{ pool.name }}</h1>
|
||||
</main>
|
||||
<article>
|
||||
<h2>Posts</h2>
|
||||
{% include "pool_posts.html" %}
|
||||
</article>
|
||||
{% if can_edit %}
|
||||
<article>
|
||||
<form
|
||||
hx-post="/pool/{{ pool.id }}/post"
|
||||
hx-target="#pool-posts"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
<div>
|
||||
<label>Add post</label>
|
||||
<input
|
||||
id="add-post-input"
|
||||
name="post_id"
|
||||
type="text"
|
||||
pattern="[0-9]*"
|
||||
/>
|
||||
<button>Add</button>
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
<label>Is public pool?</label>
|
||||
<input
|
||||
name="is_public"
|
||||
type="checkbox"
|
||||
hx-put="/pool/{{ pool.id }}/public"
|
||||
{%
|
||||
if
|
||||
pool.is_public
|
||||
%}checked{%
|
||||
endif
|
||||
%}
|
||||
value="true"
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
25
templates/pool_posts.html
Normal file
25
templates/pool_posts.html
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<div id="pool-posts">
|
||||
{% if posts.is_empty() %}
|
||||
<span>No posts in pool.</span>
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for post in posts %}
|
||||
<li class="pool-post" data-position="{{ post.position }}">
|
||||
<a href="/post/{{ post.id }}" title="{{ post.tags }}">
|
||||
<img src="/files/{{ post.thumbnail }}" />
|
||||
<div>{{ post.rating | upper }}</div>
|
||||
</a>
|
||||
{% if can_edit %}
|
||||
<button
|
||||
hx-delete="/pool_post/{{ post.pool_post_id }}"
|
||||
hx-target="closest .pool-post"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
26
templates/pools.html
Normal file
26
templates/pools.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<!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>Pools - Samey</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Viewing pools</h1>
|
||||
{% if pools.is_empty() %}
|
||||
<div>No pools found!</div>
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for pool in pools %}
|
||||
<li>
|
||||
<a href="/pool/{{ pool.id }}"> {{ pool.name }} </a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div>Page {{ page }} of {{ page_count }}</div>
|
||||
{% endif %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
{% for post in posts %}
|
||||
<li>
|
||||
<a
|
||||
href="{% if let Some(tags_text) = tags_text %}/view/{{ post.id }}?tags={{ tags_text.replace(' ', "+") }}{% else %}/view/{{ post.id }}{% endif %}"
|
||||
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 }}" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{% include "post_details.html" %} {% if let Some(parent_post) = parent_post %}
|
||||
<article id="parent-post" hx-swap-oob="outerHTML">
|
||||
<h2>Parent</h2>
|
||||
<a href="/view/{{ parent_post.id }}" title="{{ parent_post.tags }}">
|
||||
<a href="/post/{{ parent_post.id }}" title="{{ parent_post.tags }}">
|
||||
<img src="/files/{{ parent_post.thumbnail }}" />
|
||||
<div>{{ parent_post.rating }}</div>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
property="og:title"
|
||||
content="{% if let Some(title) = post.title %}{{ title }}{% endif %}"
|
||||
/>
|
||||
<meta property="og:url" content="/view/{{ post.id }}" />
|
||||
<meta property="og:url" content="/post/{{ post.id }}" />
|
||||
<meta property="og:image" content="/files/{{ post.media }}" />
|
||||
<meta property="og:image:width" content="{{ post.width }}" />
|
||||
<meta property="og:image:height" content="{{ post.height }}" />
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
{% if let Some(parent_post) = parent_post %}
|
||||
<article id="parent-post">
|
||||
<h2>Parent</h2>
|
||||
<a href="/view/{{ parent_post.id }}" title="{{ parent_post.tags }}">
|
||||
<a href="/post/{{ parent_post.id }}" title="{{ parent_post.tags }}">
|
||||
<img src="/files/{{ parent_post.thumbnail }}" />
|
||||
<div>{{ parent_post.rating }}</div>
|
||||
</a>
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
<ul>
|
||||
{% for child_post in children_posts %}
|
||||
<li>
|
||||
<a href="/view/{{ child_post.id }}" title="{{ child_post.tags }}">
|
||||
<a href="/post/{{ child_post.id }}" title="{{ child_post.tags }}">
|
||||
<img src="/files/{{ child_post.thumbnail }}" />
|
||||
<div>{{ child_post.rating | upper }}</div>
|
||||
</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue