From 48e0b0219899f3baa5fbf629800c1f0fb434d3bb Mon Sep 17 00:00:00 2001 From: trisua Date: Thu, 3 Apr 2025 20:25:00 -0400 Subject: [PATCH] add: "town square" community option with a town square community, users can post directly from their profiles! --- .../app/src/public/html/communities/feed.html | 5 +- crates/app/src/public/html/components.html | 5 +- crates/app/src/public/html/profile/posts.html | 70 ++++++++++++++++++- crates/app/src/public/html/root.html | 1 + crates/app/src/public/js/atto.js | 10 +-- crates/core/src/config.rs | 7 ++ example/tetratto.toml | 1 + 7 files changed, 90 insertions(+), 9 deletions(-) diff --git a/crates/app/src/public/html/communities/feed.html b/crates/app/src/public/html/communities/feed.html index 3135630..e09afdf 100644 --- a/crates/app/src/public/html/communities/feed.html +++ b/crates/app/src/public/html/communities/feed.html @@ -3,8 +3,9 @@
{% if user and can_post %}
-
- {{ text "communities:label.create_post" }} +
+ {{ icon "pencil" }} + {{ text "communities:label.create_post" }}
{%- endmacro %} {% macro post(post, owner, secondary=false, community=false, show_community=true, can_manage_post=false) -%} {% if community and -show_community %} +show_community and post.community != config.town_square %} - {% if community and show_community %} + {% if community and show_community and post.community != config.town_square + %}
{% endif %} {%- endmacro %} {% macro notification(notification) -%}
diff --git a/crates/app/src/public/html/profile/posts.html b/crates/app/src/public/html/profile/posts.html index 7a4f3ed..23d7a6c 100644 --- a/crates/app/src/public/html/profile/posts.html +++ b/crates/app/src/public/html/profile/posts.html @@ -1,5 +1,73 @@ {% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block -content %} +content %} {% if config.town_square %} +
+ + + +
+ + +
+ + + +
+ + +{% endif %} +
{{ icon "clock" }} diff --git a/crates/app/src/public/html/root.html b/crates/app/src/public/html/root.html index ff0fe51..7693306 100644 --- a/crates/app/src/public/html/root.html +++ b/crates/app/src/public/html/root.html @@ -95,6 +95,7 @@ const atto = ns("atto"); atto.disconnect_observers(); + atto.remove_false_options(); atto.clean_date_codes(); atto.link_filter(); diff --git a/crates/app/src/public/js/atto.js b/crates/app/src/public/js/atto.js index 0e3f751..aec59eb 100644 --- a/crates/app/src/public/js/atto.js +++ b/crates/app/src/public/js/atto.js @@ -36,10 +36,6 @@ media_theme_pref(); (() => { const self = reg_ns("atto"); - for (const element of document.querySelectorAll('[selected="false"]')) { - element.removeAttribute("selected"); - } - // init use("me", () => {}); @@ -74,6 +70,12 @@ media_theme_pref(); }); }); + self.define("remove_false_options", () => { + for (const element of document.querySelectorAll('[selected="false"]')) { + element.removeAttribute("selected"); + } + }); + self.define("rel_date", (_, date) => { // stolen and slightly modified because js dates suck const diff = (new Date().getTime() - date.getTime()) / 1000; diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index 36a4917..1b0e5de 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -187,6 +187,12 @@ pub struct Config { /// Configuration for Cloudflare Turnstile. #[serde(default = "default_turnstile")] pub turnstile: TurnstileConfig, + /// The ID of the "town square" community. This community is required to allow + /// people to post from their profiles. + /// + /// This community **must** have open write access. + #[serde(default)] + pub town_square: String, } fn default_name() -> String { @@ -261,6 +267,7 @@ impl Default for Config { banned_usernames: default_banned_usernames(), policies: default_policies(), turnstile: default_turnstile(), + town_square: String::new(), } } } diff --git a/example/tetratto.toml b/example/tetratto.toml index 3f74b30..1ecc882 100644 --- a/example/tetratto.toml +++ b/example/tetratto.toml @@ -15,6 +15,7 @@ banned_usernames = [ "post", "void", ] +town_square = "166340372315581657" [security] registration_enabled = true