- Amplia la estructura "Page" para trabajar el renderizado con regiones de componentes para componer la página. - Añade acciones "BeforeRenderBody" y "AfterRenderBody" para alterar el contenido de la página antes y después del renderizado. - Actualiza "Context" para admitir parámetros dinámicos y mejorar la gestión de temas. - Implementa el manejo de errores HTTP respondiendo páginas. - Mejora la documentación y reorganiza el código en varios módulos.
33 lines
1.1 KiB
Rust
33 lines
1.1 KiB
Rust
use crate::core::theme::ThemeRef;
|
|
use crate::global;
|
|
|
|
use parking_lot::RwLock;
|
|
|
|
use std::sync::LazyLock;
|
|
|
|
// TEMAS *******************************************************************************************
|
|
|
|
pub static THEMES: LazyLock<RwLock<Vec<ThemeRef>>> = LazyLock::new(|| RwLock::new(Vec::new()));
|
|
|
|
// TEMA PREDETERMINADO *****************************************************************************
|
|
|
|
pub static DEFAULT_THEME: LazyLock<ThemeRef> =
|
|
LazyLock::new(|| match theme_by_short_name(&global::SETTINGS.app.theme) {
|
|
Some(theme) => theme,
|
|
None => &crate::base::theme::Basic,
|
|
});
|
|
|
|
// TEMA POR NOMBRE *********************************************************************************
|
|
|
|
/// Devuelve el tema identificado por su [`short_name`](AnyInfo::short_name).
|
|
pub fn theme_by_short_name(short_name: &'static str) -> Option<ThemeRef> {
|
|
let short_name = short_name.to_lowercase();
|
|
match THEMES
|
|
.read()
|
|
.iter()
|
|
.find(|t| t.short_name().to_lowercase() == short_name)
|
|
{
|
|
Some(theme) => Some(*theme),
|
|
_ => None,
|
|
}
|
|
}
|