2025-03-25 23:58:27 -04:00
|
|
|
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
2025-04-03 22:36:58 -04:00
|
|
|
content %} {% if config.town_square and is_self %}
|
2025-04-03 20:25:00 -04:00
|
|
|
<div class="card-nest">
|
|
|
|
<div class="card small flex flex-col">
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
{{ icon "pencil" }}
|
|
|
|
<span>{{ text "communities:label.create_post" }}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<span class="fade"
|
|
|
|
>Posts created here go to the
|
|
|
|
<a href="/api/v1/communities/find/{{ config.town_square }}"
|
|
|
|
>town square</a
|
|
|
|
>
|
|
|
|
community!</span
|
|
|
|
>
|
|
|
|
</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>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
async function create_post_from_form(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
await trigger("atto::debounce", ["posts::create"]);
|
|
|
|
fetch("/api/v1/posts", {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
content: e.target.content.value,
|
|
|
|
community: "{{ config.town_square }}",
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
.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>
|
|
|
|
{% endif %}
|
|
|
|
|
2025-03-29 00:26:56 -04:00
|
|
|
<div class="card-nest">
|
|
|
|
<div class="card small flex gap-2 items-center">
|
|
|
|
{{ icon "clock" }}
|
|
|
|
<span>{{ text "auth:label.recent_posts" }}</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card flex flex-col gap-4">
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
{% for post in posts %}
|
|
|
|
{{ components::post(post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true) }}
|
|
|
|
{% endfor %}
|
2025-04-01 16:12:13 -04:00
|
|
|
|
|
|
|
{{ components::pagination(page=page, items=posts|length) }}
|
2025-03-29 00:26:56 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|