Skip to main content

nextcloud_users/capabilities/
theming.rs

1use serde::{Deserialize, Serialize};
2
3use crate::wire::lossy_bool;
4
5/// Theming and branding customization capabilities exposed by the server.
6///
7/// Nextcloud instances with the `theming` app enabled return visual styling
8/// parameters including instance title, primary brand color, and asset URLs.
9///
10/// See the [Nextcloud Theming Documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/theming.html).
11#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
12pub struct ThemingCapabilities {
13    /// Instance product name or custom server name.
14    #[serde(default)]
15    pub name: Option<String>,
16    /// Organization or website URL.
17    #[serde(default)]
18    pub url: Option<String>,
19    /// Slogan or tagline displayed on the login page.
20    #[serde(default)]
21    pub slogan: Option<String>,
22    /// Primary theme color in hexadecimal format (e.g. `"#0082c9"`).
23    #[serde(default)]
24    pub color: Option<String>,
25    /// Secondary or element highlight color in hex format.
26    #[serde(default, alias = "color-element", alias = "color_element")]
27    pub color_element: Option<String>,
28    /// Element color adjusted for bright backgrounds.
29    #[serde(
30        default,
31        alias = "color-element-bright",
32        alias = "color_element_bright"
33    )]
34    pub color_element_bright: Option<String>,
35    /// Element color adjusted for dark backgrounds.
36    #[serde(default, alias = "color-element-dark", alias = "color_element_dark")]
37    pub color_element_dark: Option<String>,
38    /// Header or button text contrast color in hex format.
39    #[serde(default, alias = "color-text", alias = "color_text")]
40    pub color_text: Option<String>,
41    /// URL to the server's custom logo image.
42    #[serde(default)]
43    pub logo: Option<String>,
44    /// URL to the server's login background image.
45    #[serde(default)]
46    pub background: Option<String>,
47    /// Whether plain background coloring is enforced.
48    #[serde(
49        default,
50        alias = "background-plain",
51        alias = "background_plain",
52        deserialize_with = "lossy_bool"
53    )]
54    pub background_plain: bool,
55    /// Whether default server background is used.
56    #[serde(
57        default,
58        alias = "background-default",
59        alias = "background_default",
60        deserialize_with = "lossy_bool"
61    )]
62    pub background_default: bool,
63}
64
65impl ThemingCapabilities {
66    /// Instance title or branding name.
67    pub fn name(&self) -> Option<&str> {
68        self.name.as_deref()
69    }
70
71    /// Primary website link.
72    pub fn url(&self) -> Option<&str> {
73        self.url.as_deref()
74    }
75
76    /// Marketing slogan or login tagline.
77    pub fn slogan(&self) -> Option<&str> {
78        self.slogan.as_deref()
79    }
80
81    /// Primary brand color.
82    pub fn color(&self) -> Option<&str> {
83        self.color.as_deref()
84    }
85
86    /// Element accent color.
87    pub fn color_element(&self) -> Option<&str> {
88        self.color_element.as_deref()
89    }
90
91    /// Element accent color on bright backgrounds.
92    pub fn color_element_bright(&self) -> Option<&str> {
93        self.color_element_bright.as_deref()
94    }
95
96    /// Element accent color on dark backgrounds.
97    pub fn color_element_dark(&self) -> Option<&str> {
98        self.color_element_dark.as_deref()
99    }
100
101    /// Contrast text color.
102    pub fn color_text(&self) -> Option<&str> {
103        self.color_text.as_deref()
104    }
105
106    /// URL to the instance logo.
107    pub fn logo(&self) -> Option<&str> {
108        self.logo.as_deref()
109    }
110
111    /// URL to the instance background.
112    pub fn background(&self) -> Option<&str> {
113        self.background.as_deref()
114    }
115
116    /// Whether a plain solid background is enabled.
117    pub const fn is_background_plain(&self) -> bool {
118        self.background_plain
119    }
120
121    /// Whether the default background image is in use.
122    pub const fn is_background_default(&self) -> bool {
123        self.background_default
124    }
125}