Añade elección de tema específico por página

Característica útil para facilitar que el módulo Admin pueda renderizar
sus páginas siempre con el mismo tema, indepedientemente del tema por
defecto. También podrá ser decisivo para permitir a los usuarios usar un
tema diferente.
This commit is contained in:
Manuel Cillero 2022-02-26 21:15:00 +01:00
parent edf5ddf81b
commit 3764f707da
11 changed files with 127 additions and 86 deletions

View file

@ -1,4 +1,18 @@
use crate::core::all::THEMES;
pub use maud::{DOCTYPE, Markup, PreEscaped, html};
mod api;
pub use api::Theme;
pub fn register_theme(t: &'static (dyn Theme + 'static)) {
THEMES.write().unwrap().push(t);
}
pub fn find_theme(name: &str) -> Option<&'static (dyn Theme + 'static)> {
let themes = THEMES.write().unwrap();
match themes.iter().find(|t| t.name() == name) {
Some(theme) => Some(*theme),
_ => None,
}
}