2025-03-29 00:26:56 -04:00
|
|
|
{% import "macros.html" as macros %} {% import "components.html" as components
|
|
|
|
%} {% extends "communities/base.html" %} {% block content %}
|
|
|
|
<div class="flex flex-col gap-4 w-full">
|
2025-03-31 15:39:49 -04:00
|
|
|
{% if user and can_post %}
|
2025-03-29 00:26:56 -04:00
|
|
|
<div class="card-nest">
|
|
|
|
<div class="card small">
|
|
|
|
<b>{{ text "communities:label.create_post" }}</b>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<form
|
|
|
|
class="card flex flex-col gap-2"
|
|
|
|
onsubmit="create_post_from_form(event)"
|
|
|
|
>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
|
|
<label for="content"
|
|
|
|
>{{ text "communities:label.content" }}</label
|
|
|
|
>
|
|
|
|
<textarea
|
|
|
|
type="text"
|
|
|
|
name="content"
|
|
|
|
id="content"
|
|
|
|
placeholder="content"
|
|
|
|
required
|
|
|
|
minlength="2"
|
|
|
|
maxlength="4096"
|
|
|
|
></textarea>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="primary">
|
|
|
|
{{ text "communities:action.create" }}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2025-04-03 12:43:36 -04:00
|
|
|
{% endif %} {% if pinned|length != 0 %}
|
|
|
|
<div class="card-nest">
|
|
|
|
<div class="card small flex gap-2 items-center">
|
|
|
|
{{ icon "pin" }}
|
|
|
|
<span>{{ text "communities:label.pinned" }}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card flex flex-col gap-4">
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
{% for post in pinned %}
|
|
|
|
{{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false, can_manage_post=can_manage_posts) }}
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-03-29 00:26:56 -04:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<div class="card-nest">
|
|
|
|
<div class="card small flex gap-2 items-center">
|
|
|
|
{{ icon "newspaper" }}
|
|
|
|
<span>{{ text "communities:label.posts" }}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card flex flex-col gap-4">
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
{% for post in feed %}
|
2025-04-03 12:43:36 -04:00
|
|
|
{{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false, can_manage_post=can_manage_posts) }}
|
2025-03-29 00:26:56 -04:00
|
|
|
{% endfor %}
|
2025-04-01 16:12:13 -04:00
|
|
|
|
|
|
|
{{ components::pagination(page=page, items=feed|length) }}
|
2025-03-29 00:26:56 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2025-04-03 16:47:48 -04:00
|
|
|
async function create_post_from_form(e) {
|
2025-03-29 00:26:56 -04:00
|
|
|
e.preventDefault();
|
2025-04-03 16:47:48 -04:00
|
|
|
await trigger("atto::debounce", ["posts::create"]);
|
2025-03-29 00:26:56 -04:00
|
|
|
fetch("/api/v1/posts", {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
content: e.target.content.value,
|
|
|
|
community: "{{ community.id }}",
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => {
|
|
|
|
trigger("atto::toast", [
|
|
|
|
res.ok ? "success" : "error",
|
|
|
|
res.message,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location.href = `/post/${res.payload}`;
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|