From 918d47d8732d396d7f139d43dc3fa7f203f2d0d5 Mon Sep 17 00:00:00 2001 From: trisua Date: Mon, 1 Sep 2025 20:17:55 -0400 Subject: [PATCH] add: tawny beta --- Cargo.lock | 4 +- crates/app/src/public/css/root.css | 44 +------------------ crates/app/src/public/html/auth/register.lisp | 2 +- crates/app/src/public/html/body.lisp | 3 ++ crates/app/src/public/html/components.lisp | 14 +++--- crates/app/src/public/html/macros.lisp | 7 +++ crates/app/src/public/html/profile/base.lisp | 22 ++++++---- crates/app/src/public/html/profile/posts.lisp | 1 - .../app/src/public/html/profile/replies.lisp | 1 - crates/app/src/public/html/root.lisp | 1 + crates/app/src/public/js/atto.js | 3 +- crates/app/src/public/js/me.js | 9 ++++ crates/core/Cargo.toml | 2 +- crates/core/src/config.rs | 4 ++ crates/core/src/database/auth.rs | 5 +++ .../src/database/drivers/sql/create_users.sql | 3 +- .../drivers/sql/version_migrations.sql | 4 ++ crates/core/src/model/auth.rs | 4 ++ example/tetratto.toml | 1 + 19 files changed, 69 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b3f536..d99ebb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3452,7 +3452,7 @@ dependencies = [ "serde", "serde_json", "tera", - "tetratto-core 16.0.0", + "tetratto-core 16.0.2", "tetratto-l10n 12.0.0", "tetratto-shared 12.0.6", "tokio", @@ -3489,7 +3489,7 @@ dependencies = [ [[package]] name = "tetratto-core" -version = "16.0.0" +version = "16.0.2" dependencies = [ "async-recursion", "base16ct", diff --git a/crates/app/src/public/css/root.css b/crates/app/src/public/css/root.css index 5c82cbf..144dd9a 100644 --- a/crates/app/src/public/css/root.css +++ b/crates/app/src/public/css/root.css @@ -1,4 +1,5 @@ @import url("utility.css"); +@import url("https://repodelivery.tetratto.com/tetratto-aux/lexend.css"); :root { color-scheme: light dark; @@ -85,12 +86,6 @@ box-sizing: border-box; } -@font-face { - font-family: "Lexend"; - src: url("https://repodelivery.tetratto.com/fonts/lexend_variable.woff2") - format("woff2"); -} - html, body { line-height: 1.5; @@ -193,43 +188,6 @@ p { margin-bottom: var(--pad-4); } -body:not(.use_system_font) { - & p:not(b *), - & span:not(.notification, .name, b *, button *, a *, .dropdown *, nav *), - & input, - & textarea { - font-variation-settings: "wght" 325; - - & h1 { - font-variation-settings: "wght" 600; - } - - & h2 { - font-variation-settings: "wght" 550; - } - - & h3 { - font-variation-settings: "wght" 500; - } - - & h4 { - font-variation-settings: "wght" 450; - } - - & h5 { - font-variation-settings: "wght" 400; - } - - & h6 { - font-variation-settings: "wght" 350; - } - - & b { - font-variation-settings: "wght" 500; - } - } -} - .no_p_margin p:last-child { margin-bottom: 0; } diff --git a/crates/app/src/public/html/auth/register.lisp b/crates/app/src/public/html/auth/register.lisp index 0fd9ae9..1fa5da1 100644 --- a/crates/app/src/public/html/auth/register.lisp +++ b/crates/app/src/public/html/auth/register.lisp @@ -174,5 +174,5 @@ (text "Or, ") (a ("href" "/auth/login") - (text "login"))) + (text "log in"))) (text "{% endblock %}") diff --git a/crates/app/src/public/html/body.lisp b/crates/app/src/public/html/body.lisp index 599106e..f021e8b 100644 --- a/crates/app/src/public/html/body.lisp +++ b/crates/app/src/public/html/body.lisp @@ -101,6 +101,9 @@ atto[\"hooks::spotify_time_text\"](); // spotify durations atto[\"hooks::verify_emoji\"](); + globalThis.CURRENT_USER = \"{% if user -%} {{ user.username }} {%- endif %}\"; + trigger(\"me::token_links\"); + fix_atto_links(); if (document.getElementById(\"tokens\")) { diff --git a/crates/app/src/public/html/components.lisp b/crates/app/src/public/html/components.lisp index 9dea998..41cd037 100644 --- a/crates/app/src/public/html/components.lisp +++ b/crates/app/src/public/html/components.lisp @@ -706,7 +706,9 @@ ("cy" "12") ("r" "6")))) -(text "{%- endif %} {%- endmacro %} {% macro theme(user, theme_preference) -%} {% if user %} {% if user.settings.theme_hue -%}") +(text "{%- endif %} {%- endmacro %}") + +(text "{% macro theme(user, theme_preference) -%} {% if user %} {% if user.settings.theme_hue -%}") (style (text ":root, * { --hue: {{ user.settings.theme_hue }} !important; @@ -739,7 +741,6 @@ setTimeout(() => { match_user_theme(); }, 150);")) - (text "{%- endif %}") (div ("style" "display: none;") @@ -748,7 +749,6 @@ (style (text "{{ user.settings.theme_custom_css|remove_script_tags|safe }}")) (text "{%- endif %}")) - (text "{%- endif %} {%- endmacro %} {% macro theme_color(color, css) -%} {% if color -%}") (style (text ":root, @@ -756,7 +756,9 @@ --{{ css }}: {{ color|color }} !important; }")) -(text "{%- endif %} {%- endmacro %} {% macro question(question, owner, asking_about=false, show_community=true, secondary=false, profile=false) -%}") +(text "{%- endif %} {%- endmacro %}") + +(text "{% macro question(question, owner, asking_about=false, show_community=true, secondary=false, profile=false) -%}") (div ("class" "card question {% if secondary -%}secondary{%- endif %} flex gap_2") (text "{% if owner.id == 0 or question.context.mask_owner -%}") @@ -860,8 +862,8 @@ (div ("class" "card_nest") (div - ("class" "card small flex items_center gap_2") - (text "{{ icon \"message-circle-heart\" }}") + ("class" "card small flex items_center gap_2 flex_wrap") + (icon (text "message-circle-heart")) (span ("class" "no_p_margin") (text "{% if header -%} {{ header|markdown|safe }} {% else %} {{ text \"requests:label.ask_question\" }} {%- endif %}"))) diff --git a/crates/app/src/public/html/macros.lisp b/crates/app/src/public/html/macros.lisp index e989794..040ffc9 100644 --- a/crates/app/src/public/html/macros.lisp +++ b/crates/app/src/public/html/macros.lisp @@ -72,6 +72,13 @@ ("href" "/chats/0/0") (icon (text "message-circle")) (str (text "communities:label.chats"))) + (text "{% if config.service_hosts.tawny -%}") + (a + ("href" "{{ config.service_hosts.tawny }}/api/v1/auth/set_token?token=") + (icon (text "message-circle")) + (str (text "communities:label.chats")) + (span ("class" "chip") (text "beta"))) + (text "{%- endif %}") (a ("href" "/mail") (icon (text "mail")) diff --git a/crates/app/src/public/html/profile/base.lisp b/crates/app/src/public/html/profile/base.lisp index fdc6c1c..399ce39 100644 --- a/crates/app/src/public/html/profile/base.lisp +++ b/crates/app/src/public/html/profile/base.lisp @@ -162,12 +162,12 @@ (text "{{ profile.settings.biography|markdown|safe }}") (text "{% if profile.settings.location|length > 0 -%}") - (span ("class" "flex items_center gap_2") (icon (text "map-pin")) (text "{{ profile.settings.location }}")) + (span ("class" "flex items_center gap_2 flex_wrap") (icon (text "map-pin")) (text "{{ profile.settings.location }}")) (text "{%- endif %}") (text "{% for link in profile.settings.links -%}") (span - ("class" "flex items_center gap_2") + ("class" "flex items_center gap_2 flex_wrap") (icon (text "link")) (a ("href" "{{ link[1] }}") @@ -278,12 +278,18 @@ (span (text "{{ text \"auth:action.unblock\" }}"))) (text "{%- endif %} {% if not profile.settings.private_chats or is_following_you %}") - (button - ("onclick" "create_group_chat()") - ("class" "lowered") - (text "{{ icon \"message-circle\" }}") - (span - (text "{{ text \"auth:action.message\" }}"))) + (text "{% if config.service_hosts.tawny -%}") + (a + ("href" "{{ config.service_hosts.tawny }}/@{{ profile.username }}") + ("class" "button lowered") + (icon (text "egg")) + (span (text "Tawny"))) + (a + ("href" "{{ config.service_hosts.tawny }}/@{{ profile.username }}/confirm_dm") + ("class" "button lowered") + (icon (text "message-circle")) + (span (str (text "auth:action.message")))) + (text "{%- endif %}") (text "{%- endif %} {% if not profile.settings.private_mails or is_following_you %}") (a ("href" "/mail/compose?receivers={{ profile.username }}") diff --git a/crates/app/src/public/html/profile/posts.lisp b/crates/app/src/public/html/profile/posts.lisp index 7e1ee28..ee24aaf 100644 --- a/crates/app/src/public/html/profile/posts.lisp +++ b/crates/app/src/public/html/profile/posts.lisp @@ -2,7 +2,6 @@ (div ("style" "display: contents") (text "{{ components::create_question_form(receiver=profile.id, header=profile.settings.motivational_header, drawing_enabled=profile.settings.enable_drawings, allow_anonymous=profile.settings.allow_anonymous_questions) }}")) - (text "{%- endif %}") (text "{{ macros::profile_nav(selected=\"posts\") }}") (div diff --git a/crates/app/src/public/html/profile/replies.lisp b/crates/app/src/public/html/profile/replies.lisp index 66b5ec3..0494e2a 100644 --- a/crates/app/src/public/html/profile/replies.lisp +++ b/crates/app/src/public/html/profile/replies.lisp @@ -24,5 +24,4 @@ (div ("class" "card flex flex_col gap_4") (text "{% for post in posts %} {% if post[2].read_access == \"Everybody\" -%} {% if post[0].context.repost and post[0].context.repost.reposting -%} {{ components::repost(repost=post[3], post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true, can_manage_post=is_self) }} {% else %} {{ components::post(post=post[0], owner=post[1], question=post[4], secondary=true, community=post[2], can_manage_post=is_self, poll=post[5]) }} {%- endif %} {%- endif %} {% endfor %} {{ components::pagination(page=page, items=posts|length) }}"))) - (text "{% endblock %}") diff --git a/crates/app/src/public/html/root.lisp b/crates/app/src/public/html/root.lisp index 5073670..6af46ef 100644 --- a/crates/app/src/public/html/root.lisp +++ b/crates/app/src/public/html/root.lisp @@ -33,6 +33,7 @@ classes: {}, service_hosts: { buckets: \"{{ config.service_hosts.buckets|safe }}\", + tawny: \"{{ config.service_hosts.tawny|safe }}\", } }; diff --git a/crates/app/src/public/js/atto.js b/crates/app/src/public/js/atto.js index 847baad..08b3f5c 100644 --- a/crates/app/src/public/js/atto.js +++ b/crates/app/src/public/js/atto.js @@ -860,7 +860,8 @@ media_theme_pref(); anchor.href.startsWith("https://buy.stripe.com") || anchor.href.startsWith("https://billing.stripe.com") || anchor.href.startsWith("https://last.fm") || - anchor.href.startsWith("atto://") + anchor.href.startsWith("atto://") || + anchor.href.startsWith(_app_base.service_hosts.tawny) ) { continue; } diff --git a/crates/app/src/public/js/me.js b/crates/app/src/public/js/me.js index ef41ad8..e9b3649 100644 --- a/crates/app/src/public/js/me.js +++ b/crates/app/src/public/js/me.js @@ -662,6 +662,15 @@ }); // token switcher + self.define("token_links", ({ $ }) => { + for (const anchor of Array.from(document.querySelectorAll("a"))) { + if (anchor.href.endsWith("/set_token?token=")) { + anchor.href += $.LOGIN_ACCOUNT_TOKENS[globalThis.CURRENT_USER]; + continue; + } + } + }); + self.define("append_associations", (_, tokens) => { fetch("/api/v1/auth/user/me/append_associations", { method: "PUT", diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index ef6f7c4..2a3f47b 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tetratto-core" description = "The core behind Tetratto" -version = "16.0.0" +version = "16.0.2" edition = "2024" readme = "../../README.md" authors.workspace = true diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index 5c852a3..0e3af22 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -264,6 +264,9 @@ pub struct ServiceHostsConfig { /// Littleweb browser host. #[serde(default)] pub littleweb: String, + /// Tawny host . + #[serde(default)] + pub tawny: String, } impl Default for ServiceHostsConfig { @@ -271,6 +274,7 @@ impl Default for ServiceHostsConfig { Self { buckets: String::new(), littleweb: String::new(), + tawny: String::new(), } } } diff --git a/crates/core/src/database/auth.rs b/crates/core/src/database/auth.rs index b736d61..c7ec572 100644 --- a/crates/core/src/database/auth.rs +++ b/crates/core/src/database/auth.rs @@ -131,6 +131,7 @@ impl DataManager { applied_configurations: serde_json::from_str(&get!(x->33(String)).to_string()).unwrap(), last_policy_consent: get!(x->34(i64)) as usize, close_friends_stack: get!(x->35(i64)) as usize, + missed_messages_count: get!(x->36(i32)) as usize, } } @@ -1165,4 +1166,8 @@ impl DataManager { auto_method!(decr_user_request_count()@get_user_by_id -> "UPDATE users SET request_count = request_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --decr=request_count); auto_method!(get_user_by_invite_code(i64)@get_user_from_row -> "SELECT * FROM users WHERE invite_code = $1" --name="user" --returns=User); + + auto_method!(update_user_missed_messages_count(i32)@get_user_by_id -> "UPDATE users SET missed_messages_count = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_user); + auto_method!(incr_user_missed_messages()@get_user_by_id -> "UPDATE users SET missed_messages_count = missed_messages_count + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --incr); + auto_method!(decr_user_missed_messages()@get_user_by_id -> "UPDATE users SET missed_messages_count = missed_messages_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --decr=notification_count); } diff --git a/crates/core/src/database/drivers/sql/create_users.sql b/crates/core/src/database/drivers/sql/create_users.sql index 11b97f8..7e20e55 100644 --- a/crates/core/src/database/drivers/sql/create_users.sql +++ b/crates/core/src/database/drivers/sql/create_users.sql @@ -34,5 +34,6 @@ CREATE TABLE IF NOT EXISTS users ( checkouts TEXT NOT NULL, applied_configurations TEXT NOT NULL, last_policy_consent BIGINT NOT NULL, - close_friends_stack BIGINT NOT NULL + close_friends_stack BIGINT NOT NULL, + missed_messages_count INT NOT NULL ) diff --git a/crates/core/src/database/drivers/sql/version_migrations.sql b/crates/core/src/database/drivers/sql/version_migrations.sql index e9e731f..f9d9afd 100644 --- a/crates/core/src/database/drivers/sql/version_migrations.sql +++ b/crates/core/src/database/drivers/sql/version_migrations.sql @@ -85,3 +85,7 @@ ADD COLUMN IF NOT EXISTS close_friends_stack BIGINT DEFAULT 0; -- stacks is_locked ALTER TABLE stacks ADD COLUMN IF NOT EXISTS is_locked INT DEFAULT 0; + +-- users missed_messages_count +ALTER TABLE users +ADD COLUMN IF NOT EXISTS missed_messages_count INT DEFAULT 0; diff --git a/crates/core/src/model/auth.rs b/crates/core/src/model/auth.rs index 8983e68..104107c 100644 --- a/crates/core/src/model/auth.rs +++ b/crates/core/src/model/auth.rs @@ -116,6 +116,9 @@ pub struct User { /// (the user) to post to it. #[serde(default)] pub close_friends_stack: usize, + /// The number of messages this user has missed. + #[serde(default)] + pub missed_messages_count: usize, } pub type UserConnections = @@ -466,6 +469,7 @@ impl User { applied_configurations: Vec::new(), last_policy_consent: created, close_friends_stack: 0, + missed_messages_count: 0, } } diff --git a/example/tetratto.toml b/example/tetratto.toml index 21b2932..df898a6 100644 --- a/example/tetratto.toml +++ b/example/tetratto.toml @@ -24,6 +24,7 @@ system_user = 211903918383300608 [service_hosts] buckets = "http://localhost:8020" littleweb = "http://localhost:4119" +tawny = "http://localhost:8021" [security] registration_enabled = true