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();
|
||||
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());
|
||||
|
|
|
@ -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">
|
||||
<h2 class="w-full text-center">{% block title %}{% endblock %}</h2>
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<article>
|
||||
|
|
|
@ -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 %}
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
{% if user and can_post %}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="communities") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
|
|
|
@ -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 %}
|
||||
<div class="flex flex-col gap-4 w-full">
|
||||
<div class="card-nest">
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
|
|
|
@ -445,4 +445,23 @@ config.town_square and user %}
|
|||
});
|
||||
}
|
||||
</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 %}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% import "components.html" as components %} {% macro nav(selected="",
|
||||
show_lhs=true) -%}
|
||||
{% macro nav(selected="", show_lhs=true) -%}
|
||||
<nav>
|
||||
<div class="content_container">
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<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>
|
||||
{% endblock %} {% block body %}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<article>
|
||||
|
@ -211,4 +211,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</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
|
||||
content %}
|
||||
{% extends "profile/base.html" %} {% block content %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ icon "users-round" }}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% import "macros.html" as macros %} {% extends "profile/base.html" %} {% block
|
||||
content %}
|
||||
{% extends "profile/base.html" %} {% block content %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ icon "users-round" }}
|
||||
|
|
|
@ -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
|
||||
%}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ 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>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
{%- import "components.html" as components -%} {%- import "macros.html" as
|
||||
macros -%}
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
@ -315,26 +317,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
{% endif %} {% if user %}
|
||||
<!-- theming -->
|
||||
{% 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 %}
|
||||
{% endif %} {% if user and use_user_theme %} {{
|
||||
components::theme(user=user) }} {% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
||||
{% extends "root.html" %} {% block head %}
|
||||
<title>{{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="home") }}
|
||||
<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>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="popular") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
|
|
|
@ -72,6 +72,7 @@ pub async fn settings_request(
|
|||
|
||||
pub fn profile_context(
|
||||
context: &mut Context,
|
||||
user: &Option<User>,
|
||||
profile: &User,
|
||||
communities: &Vec<Community>,
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue