aboutsummaryrefslogtreecommitdiff
path: root/ui/src/lib.rs
blob: 9509129d16f40f263c148253e60f128b615882cb (plain)
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
/*
    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::*;

use crate::{components::View, scaffold::Scaffold};
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 {
    Scaffold {
        ri: &ri,
        main: View { ri: &ri, view },
        title: view.get(VIEW_TITLE).unwrap_or_default(),
        class: "theme-purple",
    }
    .to_string()
}