add: "town square" community option
with a town square community, users can post directly from their profiles!
This commit is contained in:
parent
ca0c4b9e0b
commit
48e0b02198
7 changed files with 90 additions and 9 deletions
|
@ -1,5 +1,73 @@
|
|||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
||||
content %}
|
||||
content %} {% if config.town_square %}
|
||||
<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 %}
|
||||
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ icon "clock" }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue