add: post editing, profile pinned posts, theme settings
TODO: nsfw profile/community options
This commit is contained in:
parent
31f63c90cd
commit
f83cfa3756
10 changed files with 255 additions and 8 deletions
|
@ -46,6 +46,13 @@
|
|||
<span>{{ text "communities:label.replies" }}</span>
|
||||
</a>
|
||||
|
||||
{% if user.id == post.owner %}
|
||||
<a href="#/edit" data-tab-button="edit">
|
||||
{{ icon "pen" }}
|
||||
<span>{{ text "communities:label.edit_content" }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a href="#/configure" data-tab-button="configure">
|
||||
{{ icon "settings" }}
|
||||
<span>{{ text "communities:action.configure" }}</span>
|
||||
|
@ -98,6 +105,8 @@
|
|||
ui.refresh_container(element, []);
|
||||
|
||||
const can_manage_pins = "{{ can_manage_pins }}" === "true";
|
||||
const is_owner = "{{ user.id == post.owner }}" === "true";
|
||||
|
||||
const settings_fields = [
|
||||
[
|
||||
[
|
||||
|
@ -117,11 +126,74 @@
|
|||
]);
|
||||
}
|
||||
|
||||
if (is_owner) {
|
||||
settings_fields.push([
|
||||
["is_profile_pinned", "Pinned to your profile"],
|
||||
"{{ post.context.is_profile_pinned }}",
|
||||
"checkbox",
|
||||
]);
|
||||
}
|
||||
|
||||
ui.generate_settings_ui(element, settings_fields, settings);
|
||||
}, 250);
|
||||
</script>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if user.id == post.owner %}
|
||||
<div class="card-nest w-full hidden" data-tab="edit">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "pen" }}
|
||||
<span>{{ text "communities:label.edit_content" }}</span>
|
||||
</div>
|
||||
|
||||
<form
|
||||
class="card flex flex-col gap-2"
|
||||
onsubmit="edit_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"
|
||||
>
|
||||
{{ post.content }}</textarea
|
||||
>
|
||||
</div>
|
||||
|
||||
<button class="primary">{{ text "general:action.save" }}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function edit_post_from_form(e) {
|
||||
e.preventDefault();
|
||||
await trigger("atto::debounce", ["posts::edit"]);
|
||||
fetch("/api/v1/posts/{{ post.id }}/content", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: e.target.content.value,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endif %} {% endif %}
|
||||
|
||||
<div class="card-nest w-full" data-tab="replies">
|
||||
<div class="card small flex items-center gap-2">
|
||||
|
|
|
@ -143,9 +143,14 @@ show_community and post.community != config.town_square %}
|
|||
>{{ components::full_username(user=owner) }}</span
|
||||
>
|
||||
|
||||
{% if post.context.edited != 0 %}
|
||||
<div class="flex">
|
||||
<span class="fade date">{{ post.context.edited }}</span>
|
||||
<sup title="Edited">*</sup>
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="fade date">{{ post.created }}</span>
|
||||
|
||||
{% if show_community %}
|
||||
{% endif %} {% if show_community %}
|
||||
<a href="/api/v1/communities/find/{{ post.community }}">
|
||||
<!-- prettier-ignore -->
|
||||
{% if not community %}
|
||||
|
@ -211,6 +216,23 @@ show_community and post.community != config.town_square %}
|
|||
{% endif %} {% if (user.id == post.owner) or is_helper
|
||||
or can_manage_post %}
|
||||
<b class="title">{{ text "general:action.manage" }}</b>
|
||||
{% if user.id == post.owner %}
|
||||
<a href="/post/{{ post.id }}#/edit">
|
||||
{{ icon "pen" }}
|
||||
<span
|
||||
>{{ text "communities:label.edit_content"
|
||||
}}</span
|
||||
>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<a href="/post/{{ post.id }}#/configure">
|
||||
{{ icon "settings" }}
|
||||
<span
|
||||
>{{ text "communities:action.configure" }}</span
|
||||
>
|
||||
</a>
|
||||
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::remove_post', ['{{ post.id }}'])"
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
||||
content %}
|
||||
content %} {% 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, community=post[2], show_community=true, can_manage_post=is_self) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ icon "clock" }}
|
||||
|
@ -9,7 +24,7 @@ content %}
|
|||
<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) }}
|
||||
{{ components::post(post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true, can_manage_post=is_self) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=posts|length) }}
|
||||
|
|
|
@ -675,6 +675,21 @@
|
|||
"{{ profile.settings.private_last_seen }}",
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
["theme_hue", "Theme hue (integer 0-255)"],
|
||||
"{{ profile.settings.theme_hue }}",
|
||||
"input",
|
||||
],
|
||||
[
|
||||
["theme_sat", "Theme sat (percentage 0%-100%)"],
|
||||
"{{ profile.settings.theme_sat }}",
|
||||
"input",
|
||||
],
|
||||
[
|
||||
["theme_lit", "Theme lit (percentage 0%-100%)"],
|
||||
"{{ profile.settings.theme_lit }}",
|
||||
"input",
|
||||
],
|
||||
],
|
||||
settings,
|
||||
);
|
||||
|
|
|
@ -315,6 +315,26 @@
|
|||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
{% endif %} {% if user %}
|
||||
<!-- theming -->
|
||||
{% if user.settings.theme_hue %}
|
||||
<style>
|
||||
:root, * {
|
||||
--hue: {{ user.settings.theme_hue }} !important;
|
||||
}
|
||||
</style>
|
||||
{% endif %} {% if user.settings.theme_sat %}
|
||||
<style>
|
||||
:root, * {
|
||||
--sat: {{ user.settings.theme_sat }} !important;
|
||||
}
|
||||
</style>
|
||||
{% endif %} {% if user.settings.theme_lit %}
|
||||
<style>
|
||||
:root, * {
|
||||
--lit: {{ user.settings.theme_lit }} !important;
|
||||
}
|
||||
</style>
|
||||
{% endif %} {% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue