add: ability to disable profile theme of other users
This commit is contained in:
parent
e8ae7902b6
commit
a8282a113d
29 changed files with 77 additions and 52 deletions
|
@ -240,6 +240,7 @@ pub(crate) async fn initial_context(
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
ctx.insert("config", &config);
|
ctx.insert("config", &config);
|
||||||
ctx.insert("user", &user);
|
ctx.insert("user", &user);
|
||||||
|
ctx.insert("use_user_theme", &true);
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
ctx.insert("is_helper", &ua.permissions.check_helper());
|
ctx.insert("is_helper", &ua.permissions.check_helper());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block body %}
|
{% extends "root.html" %} {% block body %}
|
||||||
<main class="flex flex-col gap-2" style="max-width: 25rem">
|
<main class="flex flex-col gap-2" style="max-width: 25rem">
|
||||||
<h2 class="w-full text-center">{% block title %}{% endblock %}</h2>
|
<h2 class="w-full text-center">{% block title %}{% endblock %}</h2>
|
||||||
<div class="card w-full flex flex-col gap-4 justify-center align-center">
|
<div class="card w-full flex flex-col gap-4 justify-center align-center">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ community.context.display_name }} - {{ config.name }}</title>
|
<title>{{ community.context.display_name }} - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<article>
|
<article>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% import "macros.html" as macros %} {% import "components.html" as components
|
{% import "components.html" as components %} {% extends "communities/base.html"
|
||||||
%} {% extends "communities/base.html" %} {% block content %}
|
%} {% block content %}
|
||||||
<div class="flex flex-col gap-4 w-full">
|
<div class="flex flex-col gap-4 w-full">
|
||||||
{% if user and can_post %}
|
{% if user and can_post %}
|
||||||
<div class="card-nest">
|
<div class="card-nest">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>My communities - {{ config.name }}</title>
|
<title>My communities - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="communities") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="communities") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% import "macros.html" as macros %} {% import "components.html" as components
|
{% import "components.html" as components %} {% extends "communities/base.html"
|
||||||
%} {% extends "communities/base.html" %} {% block content %}
|
%} {% block content %}
|
||||||
<div class="flex flex-col gap-4 w-full">
|
<div class="flex flex-col gap-4 w-full">
|
||||||
<div class="card-nest">
|
<div class="card-nest">
|
||||||
<div class="card small flex gap-2 items-center">
|
<div class="card small flex gap-2 items-center">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Post - {{ config.name }}</title>
|
<title>Post - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Community settings - {{ config.name }}</title>
|
<title>Community settings - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -445,4 +445,23 @@ config.town_square and user %}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
{% endif %} {%- endmacro %} {% macro theme(user) -%} {% 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 %} {%- endmacro %}
|
{% endif %} {%- endmacro %}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{% import "components.html" as components %} {% macro nav(selected="",
|
{% macro nav(selected="", show_lhs=true) -%}
|
||||||
show_lhs=true) -%}
|
|
||||||
<nav>
|
<nav>
|
||||||
<div class="content_container">
|
<div class="content_container">
|
||||||
<div class="flex nav_side">
|
<div class="flex nav_side">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ error_text }} - {{ config.name }}</title>
|
<title>{{ error_text }} - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ config.name }}</title>
|
<title>{{ config.name }}</title>
|
||||||
{% endblock %} {% block body %}
|
{% endblock %} {% block body %}
|
||||||
<main class="flex justify-center" style="padding-top: 2rem">
|
<main class="flex justify-center" style="padding-top: 2rem">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ file_name }} - {{ config.name }}</title>
|
<title>{{ file_name }} - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Notifications - {{ config.name }}</title>
|
<title>Notifications - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Audit log - {{ config.name }}</title>
|
<title>Audit log - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>File report - {{ config.name }}</title>
|
<title>File report - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>IP Bans - {{ config.name }}</title>
|
<title>IP Bans - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Manage profile - {{ config.name }}</title>
|
<title>Manage profile - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Reports - {{ config.name }}</title>
|
<title>Reports - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ profile.username }} - {{ config.name }}</title>
|
<title>{{ profile.username }} - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<article>
|
<article>
|
||||||
|
@ -211,4 +211,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
{% endblock %}
|
|
||||||
|
{% if not use_user_theme %} {{ components::theme(user=profile) }} {% endif %} {%
|
||||||
|
endblock %}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
{% extends "profile/base.html" %} {% block content %}
|
||||||
content %}
|
|
||||||
<div class="card-nest">
|
<div class="card-nest">
|
||||||
<div class="card small flex gap-2 items-center">
|
<div class="card small flex gap-2 items-center">
|
||||||
{{ icon "users-round" }}
|
{{ icon "users-round" }}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
{% extends "profile/base.html" %} {% block content %}
|
||||||
content %}
|
|
||||||
<div class="card-nest">
|
<div class="card-nest">
|
||||||
<div class="card small flex gap-2 items-center">
|
<div class="card small flex gap-2 items-center">
|
||||||
{{ icon "users-round" }}
|
{{ icon "users-round" }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
{% extends "profile/base.html" %} {% block content %} {% if pinned|length != 0
|
||||||
content %} {% if pinned|length != 0 %}
|
%}
|
||||||
<div class="card-nest">
|
<div class="card-nest">
|
||||||
<div class="card small flex gap-2 items-center">
|
<div class="card small flex gap-2 items-center">
|
||||||
{{ icon "pin" }}
|
{{ icon "pin" }}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Settings - {{ config.name }}</title>
|
<title>Settings - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
@ -690,6 +690,14 @@
|
||||||
"{{ profile.settings.theme_lit }}",
|
"{{ profile.settings.theme_lit }}",
|
||||||
"input",
|
"input",
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"disable_other_themes",
|
||||||
|
"Disable the profile theme of other users",
|
||||||
|
],
|
||||||
|
"{{ profile.settings.disable_other_themes }}",
|
||||||
|
"checkbox",
|
||||||
|
],
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{%- import "components.html" as components -%} {%- import "macros.html" as
|
||||||
|
macros -%}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -315,26 +317,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
{% endif %} {% if user %}
|
{% endif %} {% if user and use_user_theme %} {{
|
||||||
<!-- theming -->
|
components::theme(user=user) }} {% endif %}
|
||||||
{% 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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>{{ config.name }}</title>
|
<title>{{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="home") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="home") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
{% extends "root.html" %} {% block head %}
|
||||||
<title>Popular - {{ config.name }}</title>
|
<title>Popular - {{ config.name }}</title>
|
||||||
{% endblock %} {% block body %} {{ macros::nav(selected="popular") }}
|
{% endblock %} {% block body %} {{ macros::nav(selected="popular") }}
|
||||||
<main class="flex flex-col gap-2">
|
<main class="flex flex-col gap-2">
|
||||||
|
|
|
@ -72,6 +72,7 @@ pub async fn settings_request(
|
||||||
|
|
||||||
pub fn profile_context(
|
pub fn profile_context(
|
||||||
context: &mut Context,
|
context: &mut Context,
|
||||||
|
user: &Option<User>,
|
||||||
profile: &User,
|
profile: &User,
|
||||||
communities: &Vec<Community>,
|
communities: &Vec<Community>,
|
||||||
is_self: bool,
|
is_self: bool,
|
||||||
|
@ -90,6 +91,14 @@ pub fn profile_context(
|
||||||
"is_supporter",
|
"is_supporter",
|
||||||
&profile.permissions.check(FinePermission::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}`
|
/// `/@{username}`
|
||||||
|
@ -214,6 +223,7 @@ pub async fn posts_request(
|
||||||
context.insert("pinned", &pinned);
|
context.insert("pinned", &pinned);
|
||||||
profile_context(
|
profile_context(
|
||||||
&mut context,
|
&mut context,
|
||||||
|
&user,
|
||||||
&other_user,
|
&other_user,
|
||||||
&communities,
|
&communities,
|
||||||
is_self,
|
is_self,
|
||||||
|
@ -338,6 +348,7 @@ pub async fn following_request(
|
||||||
context.insert("page", &props.page);
|
context.insert("page", &props.page);
|
||||||
profile_context(
|
profile_context(
|
||||||
&mut context,
|
&mut context,
|
||||||
|
&user,
|
||||||
&other_user,
|
&other_user,
|
||||||
&communities,
|
&communities,
|
||||||
is_self,
|
is_self,
|
||||||
|
@ -464,6 +475,7 @@ pub async fn followers_request(
|
||||||
context.insert("page", &props.page);
|
context.insert("page", &props.page);
|
||||||
profile_context(
|
profile_context(
|
||||||
&mut context,
|
&mut context,
|
||||||
|
&user,
|
||||||
&other_user,
|
&other_user,
|
||||||
&communities,
|
&communities,
|
||||||
is_self,
|
is_self,
|
||||||
|
|
|
@ -68,6 +68,8 @@ pub struct UserSettings {
|
||||||
pub theme_sat: String,
|
pub theme_sat: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub theme_lit: String,
|
pub theme_lit: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub disable_other_themes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for UserSettings {
|
impl Default for UserSettings {
|
||||||
|
@ -83,6 +85,7 @@ impl Default for UserSettings {
|
||||||
theme_hue: String::new(),
|
theme_hue: String::new(),
|
||||||
theme_sat: String::new(),
|
theme_sat: String::new(),
|
||||||
theme_lit: String::new(),
|
theme_lit: String::new(),
|
||||||
|
disable_other_themes: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue