diff --git a/crates/app/src/assets.rs b/crates/app/src/assets.rs index a6bff19..866c8b5 100644 --- a/crates/app/src/assets.rs +++ b/crates/app/src/assets.rs @@ -240,6 +240,7 @@ pub(crate) async fn initial_context( let mut ctx = Context::new(); ctx.insert("config", &config); ctx.insert("user", &user); + ctx.insert("use_user_theme", &true); if let Some(ua) = user { ctx.insert("is_helper", &ua.permissions.check_helper()); diff --git a/crates/app/src/public/html/auth/base.html b/crates/app/src/public/html/auth/base.html index c1531c0..40ebd28 100644 --- a/crates/app/src/public/html/auth/base.html +++ b/crates/app/src/public/html/auth/base.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block body %} +{% extends "root.html" %} {% block body %}

{% block title %}{% endblock %}

diff --git a/crates/app/src/public/html/communities/base.html b/crates/app/src/public/html/communities/base.html index 74000d4..a98c6ff 100644 --- a/crates/app/src/public/html/communities/base.html +++ b/crates/app/src/public/html/communities/base.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} {{ community.context.display_name }} - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav() }}
diff --git a/crates/app/src/public/html/communities/feed.html b/crates/app/src/public/html/communities/feed.html index e09afdf..1d61c85 100644 --- a/crates/app/src/public/html/communities/feed.html +++ b/crates/app/src/public/html/communities/feed.html @@ -1,5 +1,5 @@ -{% import "macros.html" as macros %} {% import "components.html" as components -%} {% extends "communities/base.html" %} {% block content %} +{% import "components.html" as components %} {% extends "communities/base.html" +%} {% block content %}
{% if user and can_post %}
diff --git a/crates/app/src/public/html/communities/list.html b/crates/app/src/public/html/communities/list.html index 437e391..8a6191b 100644 --- a/crates/app/src/public/html/communities/list.html +++ b/crates/app/src/public/html/communities/list.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} My communities - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav(selected="communities") }}
diff --git a/crates/app/src/public/html/communities/members.html b/crates/app/src/public/html/communities/members.html index 3ff15c5..cd88993 100644 --- a/crates/app/src/public/html/communities/members.html +++ b/crates/app/src/public/html/communities/members.html @@ -1,5 +1,5 @@ -{% import "macros.html" as macros %} {% import "components.html" as components -%} {% extends "communities/base.html" %} {% block content %} +{% import "components.html" as components %} {% extends "communities/base.html" +%} {% block content %}
diff --git a/crates/app/src/public/html/communities/post.html b/crates/app/src/public/html/communities/post.html index b573e1d..21a85d6 100644 --- a/crates/app/src/public/html/communities/post.html +++ b/crates/app/src/public/html/communities/post.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} Post - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav() }}
diff --git a/crates/app/src/public/html/communities/settings.html b/crates/app/src/public/html/communities/settings.html index dbba102..d987d88 100644 --- a/crates/app/src/public/html/communities/settings.html +++ b/crates/app/src/public/html/communities/settings.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} Community settings - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav() }}
diff --git a/crates/app/src/public/html/components.html b/crates/app/src/public/html/components.html index b532f78..1223eae 100644 --- a/crates/app/src/public/html/components.html +++ b/crates/app/src/public/html/components.html @@ -445,4 +445,23 @@ config.town_square and user %} }); } +{% endif %} {%- endmacro %} {% macro theme(user) -%} {% if +user.settings.theme_hue %} + +{% endif %} {% if user.settings.theme_sat %} + +{% endif %} {% if user.settings.theme_lit %} + {% endif %} {%- endmacro %} diff --git a/crates/app/src/public/html/macros.html b/crates/app/src/public/html/macros.html index 761d30e..e3b5539 100644 --- a/crates/app/src/public/html/macros.html +++ b/crates/app/src/public/html/macros.html @@ -1,5 +1,4 @@ -{% import "components.html" as components %} {% macro nav(selected="", -show_lhs=true) -%} +{% macro nav(selected="", show_lhs=true) -%}
-{% endblock %} + +{% if not use_user_theme %} {{ components::theme(user=profile) }} {% endif %} {% +endblock %} diff --git a/crates/app/src/public/html/profile/followers.html b/crates/app/src/public/html/profile/followers.html index 8e3233a..0cdadb9 100644 --- a/crates/app/src/public/html/profile/followers.html +++ b/crates/app/src/public/html/profile/followers.html @@ -1,5 +1,4 @@ -{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block -content %} +{% extends "profile/base.html" %} {% block content %}
{{ icon "users-round" }} diff --git a/crates/app/src/public/html/profile/following.html b/crates/app/src/public/html/profile/following.html index 806c44f..2d0f1e7 100644 --- a/crates/app/src/public/html/profile/following.html +++ b/crates/app/src/public/html/profile/following.html @@ -1,5 +1,4 @@ -{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block -content %} +{% extends "profile/base.html" %} {% block content %}
{{ icon "users-round" }} diff --git a/crates/app/src/public/html/profile/posts.html b/crates/app/src/public/html/profile/posts.html index b5a6532..88bef12 100644 --- a/crates/app/src/public/html/profile/posts.html +++ b/crates/app/src/public/html/profile/posts.html @@ -1,5 +1,5 @@ -{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block -content %} {% if pinned|length != 0 %} +{% extends "profile/base.html" %} {% block content %} {% if pinned|length != 0 +%}
{{ icon "pin" }} diff --git a/crates/app/src/public/html/profile/settings.html b/crates/app/src/public/html/profile/settings.html index 2171405..1b8a73f 100644 --- a/crates/app/src/public/html/profile/settings.html +++ b/crates/app/src/public/html/profile/settings.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} Settings - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav() }}
@@ -690,6 +690,14 @@ "{{ profile.settings.theme_lit }}", "input", ], + [ + [ + "disable_other_themes", + "Disable the profile theme of other users", + ], + "{{ profile.settings.disable_other_themes }}", + "checkbox", + ], ], settings, ); diff --git a/crates/app/src/public/html/root.html b/crates/app/src/public/html/root.html index eb0b1ae..43f3044 100644 --- a/crates/app/src/public/html/root.html +++ b/crates/app/src/public/html/root.html @@ -1,3 +1,5 @@ +{%- import "components.html" as components -%} {%- import "macros.html" as +macros -%} @@ -315,26 +317,7 @@
- {% endif %} {% if user %} - - {% if user.settings.theme_hue %} - - {% endif %} {% if user.settings.theme_sat %} - - {% endif %} {% if user.settings.theme_lit %} - - {% endif %} {% endif %} + {% endif %} {% if user and use_user_theme %} {{ + components::theme(user=user) }} {% endif %} diff --git a/crates/app/src/public/html/timelines/home.html b/crates/app/src/public/html/timelines/home.html index 5b2938b..b1f76ab 100644 --- a/crates/app/src/public/html/timelines/home.html +++ b/crates/app/src/public/html/timelines/home.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} {{ config.name }} {% endblock %} {% block body %} {{ macros::nav(selected="home") }}
diff --git a/crates/app/src/public/html/timelines/popular.html b/crates/app/src/public/html/timelines/popular.html index c5bca83..a163421 100644 --- a/crates/app/src/public/html/timelines/popular.html +++ b/crates/app/src/public/html/timelines/popular.html @@ -1,4 +1,4 @@ -{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %} +{% extends "root.html" %} {% block head %} Popular - {{ config.name }} {% endblock %} {% block body %} {{ macros::nav(selected="popular") }}
diff --git a/crates/app/src/routes/pages/profile.rs b/crates/app/src/routes/pages/profile.rs index a6a8759..137eedc 100644 --- a/crates/app/src/routes/pages/profile.rs +++ b/crates/app/src/routes/pages/profile.rs @@ -72,6 +72,7 @@ pub async fn settings_request( pub fn profile_context( context: &mut Context, + user: &Option, profile: &User, communities: &Vec, is_self: bool, @@ -90,6 +91,14 @@ pub fn profile_context( "is_supporter", &profile.permissions.check(FinePermission::SUPPORTER), ); + + if let Some(ua) = user { + if !ua.settings.disable_other_themes | is_self { + context.insert("use_user_theme", &false); + } + } else { + context.insert("use_user_theme", &false); + } } /// `/@{username}` @@ -214,6 +223,7 @@ pub async fn posts_request( context.insert("pinned", &pinned); profile_context( &mut context, + &user, &other_user, &communities, is_self, @@ -338,6 +348,7 @@ pub async fn following_request( context.insert("page", &props.page); profile_context( &mut context, + &user, &other_user, &communities, is_self, @@ -464,6 +475,7 @@ pub async fn followers_request( context.insert("page", &props.page); profile_context( &mut context, + &user, &other_user, &communities, is_self, diff --git a/crates/core/src/model/auth.rs b/crates/core/src/model/auth.rs index 2ceff17..6058986 100644 --- a/crates/core/src/model/auth.rs +++ b/crates/core/src/model/auth.rs @@ -68,6 +68,8 @@ pub struct UserSettings { pub theme_sat: String, #[serde(default)] pub theme_lit: String, + #[serde(default)] + pub disable_other_themes: bool, } impl Default for UserSettings { @@ -83,6 +85,7 @@ impl Default for UserSettings { theme_hue: String::new(), theme_sat: String::new(), theme_lit: String::new(), + disable_other_themes: false, } } }