1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
mod components;
pub(crate) mod format;
mod scaffold;
pub use jellyui_client_scripts::*;
pub use jellyui_client_style::*;
pub use components::admin_log::ServerLogPage;
pub use components::admin_log::render_log_line;
pub use jellyui_locale::tr;
pub use scaffold::Scaffold;
use crate::components::View;
use jellycommon::{jellyobject::Object, *};
use serde::{Deserialize, Serialize};
#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct Config {
pub brand: String,
pub slogan: String,
pub logo: bool,
}
pub struct RenderInfo<'a> {
pub user: Option<Object<'a>>,
pub lang: &'a str,
pub status_message: Option<&'a str>,
pub config: &'a Config,
}
pub fn render_view(ri: RenderInfo<'_>, view: Object<'_>) -> String {
let theme = ri
.user
.and_then(|u| u.get(USER_THEME_PRESET))
.unwrap_or(THEME_DARK);
Scaffold {
ri: &ri,
main: View { ri: &ri, view },
title: view.get(VIEW_TITLE).unwrap_or_default(),
class: match (theme, view.has(VIEW_PLAYER.0)) {
(THEME_DARK, true) => "theme-dark player",
(THEME_DARK, false) => "theme-dark",
(THEME_LIGHT, true) => "theme-light player",
(THEME_LIGHT, false) => "theme-light",
_ => "theme-dark",
},
}
.to_string()
}
|