/*
    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 {
    Scaffold {
        ri: &ri,
        main: View { ri: &ri, view },
        title: view.get(VIEW_TITLE).unwrap_or_default(),
        class: if view.has(VIEW_PLAYER.0) {
            "theme-purple player"
        } else {
            "theme-purple"
        },
    }
    .to_string()
}
