aboutsummaryrefslogtreecommitdiff
path: root/ui/src/lib.rs
blob: 72109d420f87a21ef8e4e9b9bba7b714245bda0a (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
41
42
43
/*
    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;
pub(crate) mod locale;
mod scaffold;

use crate::{components::View, scaffold::Scaffold};
use jellycommon::{
    jellyobject::{Object, Tag},
    *,
};
use serde::{Deserialize, Serialize};

pub type FlashM = Option<(String, String)>;

#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct Config {
    brand: String,
    slogan: String,
    logo: bool,
}

pub struct RenderInfo<'a> {
    pub user: Option<Object<'a>>,
    pub lang: Tag,
    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: "",
    }
    .to_string()
}