From eea3d08e1fabed8e336bd284daa144aa21f9b1b3 Mon Sep 17 00:00:00 2001 From: trisua Date: Thu, 3 Apr 2025 12:43:36 -0400 Subject: [PATCH] add: pinned posts --- crates/app/src/langs/en-US.toml | 1 + .../app/src/public/html/communities/feed.html | 16 +- .../app/src/public/html/communities/post.html | 87 +++++++- .../src/public/html/communities/settings.html | 2 +- crates/app/src/public/html/components.html | 7 +- crates/app/src/public/js/atto.js | 7 +- crates/app/src/routes/pages/communities.rs | 50 ++++- crates/core/src/database/posts.rs | 188 ++++++++++++++---- crates/core/src/model/communities.rs | 20 +- .../core/src/model/communities_permissions.rs | 1 + 10 files changed, 324 insertions(+), 55 deletions(-) diff --git a/crates/app/src/langs/en-US.toml b/crates/app/src/langs/en-US.toml index c6cf324..52a1c6a 100644 --- a/crates/app/src/langs/en-US.toml +++ b/crates/app/src/langs/en-US.toml @@ -70,6 +70,7 @@ version = "1.0.0" "communities:label.delete_community" = "Delete community" "communities:label.change_title" = "Change title" "communities:label.new_title" = "New title" +"communities:label.pinned" = "Pinned" "notifs:action.mark_as_read" = "Mark as read" "notifs:action.mark_as_unread" = "Mark as unread" diff --git a/crates/app/src/public/html/communities/feed.html b/crates/app/src/public/html/communities/feed.html index 7ee80da..e2141d9 100644 --- a/crates/app/src/public/html/communities/feed.html +++ b/crates/app/src/public/html/communities/feed.html @@ -31,6 +31,20 @@ + {% endif %} {% if pinned|length != 0 %} +
+
+ {{ icon "pin" }} + {{ text "communities:label.pinned" }} +
+ +
+ + {% for post in pinned %} + {{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false, can_manage_post=can_manage_posts) }} + {% endfor %} +
+
{% endif %}
@@ -42,7 +56,7 @@
{% for post in feed %} - {{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false) }} + {{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false, can_manage_post=can_manage_posts) }} {% endfor %} {{ components::pagination(page=page, items=feed|length) }} diff --git a/crates/app/src/public/html/communities/post.html b/crates/app/src/public/html/communities/post.html index e406520..b7baf07 100644 --- a/crates/app/src/public/html/communities/post.html +++ b/crates/app/src/public/html/communities/post.html @@ -8,7 +8,8 @@ {{ text "communities:action.continue_thread" }} {% endif %} {{ components::post(post=post, owner=owner, community=community, - show_community=true) }} {% if user %} + show_community=true, can_manage_post=can_manage_posts) }} {% if user and + post.context.comments_enabled %}
{{ text "communities:label.create_reply" }} @@ -38,9 +39,91 @@
+ {% endif %} {% if user and user.id == post.owner or can_manage_posts %} + + + {% endif %} -
+
{{ icon "newspaper" }} {{ text "communities:label.replies" }} diff --git a/crates/app/src/public/html/communities/settings.html b/crates/app/src/public/html/communities/settings.html index 7daadb2..16973b5 100644 --- a/crates/app/src/public/html/communities/settings.html +++ b/crates/app/src/public/html/communities/settings.html @@ -346,7 +346,7 @@ role: (new_role) => { return update_user_role( e.target.uid.value, - user_role, + new_role, ); }, }, diff --git a/crates/app/src/public/html/components.html b/crates/app/src/public/html/components.html index f7ae592..251a337 100644 --- a/crates/app/src/public/html/components.html +++ b/crates/app/src/public/html/components.html @@ -105,7 +105,8 @@ community %} {% endif %}
{%- endmacro %} {% macro post(post, owner, secondary=false, community=false, -show_community=true) -%} {% if community and show_community %} +show_community=true, can_manage_post=false) -%} {% if community and +show_community %}
{% endif %} @@ -197,7 +200,7 @@ show_community=true) -%} {% if community and show_community %} {{ text "general:action.report" }} {% endif %} {% if (user.id == post.owner) or is_helper - %} + or can_manage_post %} {{ text "general:action.manage" }}