diff --git a/drust/src/main.rs b/drust/src/main.rs index 0eb6cef6..a6944ba9 100644 --- a/drust/src/main.rs +++ b/drust/src/main.rs @@ -9,7 +9,7 @@ impl ModuleTrait for Drust { APP_DRUST } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![ // Themes. &pagetop_aliner::Aliner, @@ -23,7 +23,7 @@ impl ModuleTrait for Drust { ] } - fn drop_modules(&self) -> Vec { + fn drop_modules(&self) -> Vec { vec![ // &pagetop_node::Node ] diff --git a/pagetop-admin/src/lib.rs b/pagetop-admin/src/lib.rs index 52d6233d..ed3e8474 100644 --- a/pagetop-admin/src/lib.rs +++ b/pagetop-admin/src/lib.rs @@ -22,7 +22,7 @@ impl ModuleTrait for Admin { } #[rustfmt::skip] - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![ &pagetop_minimal::Minimal, &pagetop_megamenu::MegaMenu, diff --git a/pagetop-aliner/src/lib.rs b/pagetop-aliner/src/lib.rs index 92079cfd..479ab499 100644 --- a/pagetop-aliner/src/lib.rs +++ b/pagetop-aliner/src/lib.rs @@ -11,7 +11,7 @@ impl ModuleTrait for Aliner { THEME_ALINER } - fn theme(&self) -> Option { + fn theme(&self) -> Option { Some(&Aliner) } diff --git a/pagetop-bootsier/src/lib.rs b/pagetop-bootsier/src/lib.rs index 31dfd56e..f8ce573c 100644 --- a/pagetop-bootsier/src/lib.rs +++ b/pagetop-bootsier/src/lib.rs @@ -14,11 +14,11 @@ impl ModuleTrait for Bootsier { THEME_BOOTSIER } - fn theme(&self) -> Option { + fn theme(&self) -> Option { Some(&Bootsier) } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![&pagetop_jquery::JQuery] } diff --git a/pagetop-bulmix/src/lib.rs b/pagetop-bulmix/src/lib.rs index 9905b05d..0cadab56 100644 --- a/pagetop-bulmix/src/lib.rs +++ b/pagetop-bulmix/src/lib.rs @@ -13,12 +13,12 @@ impl ModuleTrait for Bulmix { THEME_BULMIX } - fn theme(&self) -> Option { + fn theme(&self) -> Option { Some(&Bulmix) } #[rustfmt::skip] - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![ &pagetop_jquery::JQuery, &pagetop_minimal::Minimal, diff --git a/pagetop-homedemo/src/lib.rs b/pagetop-homedemo/src/lib.rs index 308d6873..28e4c056 100644 --- a/pagetop-homedemo/src/lib.rs +++ b/pagetop-homedemo/src/lib.rs @@ -22,7 +22,7 @@ impl ModuleTrait for HomeDemo { L10n::t("module_description", &LOCALES_HOMEDEMO) } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![&pagetop_minimal::Minimal] } diff --git a/pagetop-megamenu/src/lib.rs b/pagetop-megamenu/src/lib.rs index b1bd6593..89e8345b 100644 --- a/pagetop-megamenu/src/lib.rs +++ b/pagetop-megamenu/src/lib.rs @@ -13,7 +13,7 @@ impl ModuleTrait for MegaMenu { MODULE_MEGAMENU } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![&pagetop_jquery::JQuery, &pagetop_minimal::Minimal] } diff --git a/pagetop-user/src/lib.rs b/pagetop-user/src/lib.rs index 3b45b3a5..60384843 100644 --- a/pagetop-user/src/lib.rs +++ b/pagetop-user/src/lib.rs @@ -22,7 +22,7 @@ impl ModuleTrait for User { L10n::t("module_description", &LOCALES_USER) } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![&pagetop_minimal::Minimal] } diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index 1895089e..ae1d3b42 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -2,7 +2,7 @@ mod figfont; -use crate::core::{module, module::ModuleStaticRef}; +use crate::core::{module, module::ModuleRef}; use crate::html::Markup; use crate::response::fatal_error::FatalError; use crate::response::page::ResultPage; @@ -26,7 +26,7 @@ pub struct Application { } impl Application { - pub fn prepare(app: ModuleStaticRef) -> Result { + pub fn prepare(app: ModuleRef) -> Result { // Rótulo de presentación. print_on_startup(); diff --git a/pagetop/src/core/component/context.rs b/pagetop/src/core/component/context.rs index 16a077a7..c79e109b 100644 --- a/pagetop/src/core/component/context.rs +++ b/pagetop/src/core/component/context.rs @@ -1,5 +1,5 @@ use crate::core::theme::all::{theme_by_single_name, THEME}; -use crate::core::theme::ThemeStaticRef; +use crate::core::theme::ThemeRef; use crate::html::{html, Assets, HeadScript, HeadStyles, JavaScript, Markup, StyleSheet}; use crate::locale::{LanguageIdentifier, LANGID}; use crate::service::HttpRequest; @@ -29,7 +29,7 @@ pub enum ContextOp { pub struct Context { request : HttpRequest, langid : &'static LanguageIdentifier, - theme : ThemeStaticRef, + theme : ThemeRef, stylesheet: Assets, // Stylesheets. headstyles: Assets, // Styles in head. javascript: Assets, // JavaScripts. @@ -99,7 +99,7 @@ impl Context { self.langid } - pub(crate) fn theme(&self) -> ThemeStaticRef { + pub(crate) fn theme(&self) -> ThemeRef { self.theme } diff --git a/pagetop/src/core/module.rs b/pagetop/src/core/module.rs index 3bfd99c8..4da03e01 100644 --- a/pagetop/src/core/module.rs +++ b/pagetop/src/core/module.rs @@ -1,4 +1,4 @@ mod definition; -pub use definition::{ModuleBase, ModuleStaticRef, ModuleTrait}; +pub use definition::{ModuleBase, ModuleRef, ModuleTrait}; pub(crate) mod all; diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index 9bd74c79..b50f8dfd 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -1,5 +1,5 @@ use crate::core::action::add_action; -use crate::core::module::ModuleStaticRef; +use crate::core::module::ModuleRef; use crate::core::theme::all::THEMES; use crate::{service, trace, LazyStatic}; @@ -10,22 +10,22 @@ use std::sync::RwLock; // MODULES ***************************************************************************************** -static ENABLED_MODULES: LazyStatic>> = +static ENABLED_MODULES: LazyStatic>> = LazyStatic::new(|| RwLock::new(Vec::new())); -static DROPPED_MODULES: LazyStatic>> = +static DROPPED_MODULES: LazyStatic>> = LazyStatic::new(|| RwLock::new(Vec::new())); // REGISTER MODULES ******************************************************************************** -pub fn register_modules(app: ModuleStaticRef) { +pub fn register_modules(app: ModuleRef) { // List of modules to drop. - let mut list: Vec = Vec::new(); + let mut list: Vec = Vec::new(); add_to_dropped(&mut list, app); DROPPED_MODULES.write().unwrap().append(&mut list); // List of modules to enable. - let mut list: Vec = Vec::new(); + let mut list: Vec = Vec::new(); // Enable basic theme. add_to_enabled(&mut list, &crate::core::theme::Basic); @@ -37,7 +37,7 @@ pub fn register_modules(app: ModuleStaticRef) { ENABLED_MODULES.write().unwrap().append(&mut list); } -fn add_to_dropped(list: &mut Vec, module: ModuleStaticRef) { +fn add_to_dropped(list: &mut Vec, module: ModuleRef) { for d in module.drop_modules().iter() { if !list.iter().any(|m| m.handle() == d.handle()) { list.push(*d); @@ -49,7 +49,7 @@ fn add_to_dropped(list: &mut Vec, module: ModuleStaticRef) { } } -fn add_to_enabled(list: &mut Vec, module: ModuleStaticRef) { +fn add_to_enabled(list: &mut Vec, module: ModuleRef) { if !list.iter().any(|m| m.handle() == module.handle()) { if DROPPED_MODULES .read() diff --git a/pagetop/src/core/module/definition.rs b/pagetop/src/core/module/definition.rs index ab405d80..deaa3c7f 100644 --- a/pagetop/src/core/module/definition.rs +++ b/pagetop/src/core/module/definition.rs @@ -1,12 +1,12 @@ use crate::core::action::Action; use crate::core::component::l10n::L10n; -use crate::core::theme::ThemeStaticRef; +use crate::core::theme::ThemeRef; use crate::{service, util, Handle}; #[cfg(feature = "database")] use crate::db::MigrationItem; -pub type ModuleStaticRef = &'static dyn ModuleTrait; +pub type ModuleRef = &'static dyn ModuleTrait; pub trait ModuleBase { fn single_name(&self) -> &'static str; @@ -24,15 +24,15 @@ pub trait ModuleTrait: ModuleBase + Send + Sync { L10n::default() } - fn theme(&self) -> Option { + fn theme(&self) -> Option { None } - fn dependencies(&self) -> Vec { + fn dependencies(&self) -> Vec { vec![] } - fn drop_modules(&self) -> Vec { + fn drop_modules(&self) -> Vec { vec![] } diff --git a/pagetop/src/core/theme.rs b/pagetop/src/core/theme.rs index e12f7d21..35a6ff2f 100644 --- a/pagetop/src/core/theme.rs +++ b/pagetop/src/core/theme.rs @@ -1,5 +1,5 @@ mod definition; -pub use definition::{ThemeStaticRef, ThemeTrait}; +pub use definition::{ThemeRef, ThemeTrait}; mod regions; pub use regions::add_component_to; diff --git a/pagetop/src/core/theme/all.rs b/pagetop/src/core/theme/all.rs index fcc09467..2b6d56b1 100644 --- a/pagetop/src/core/theme/all.rs +++ b/pagetop/src/core/theme/all.rs @@ -1,17 +1,16 @@ use crate::config; -use crate::core::theme::ThemeStaticRef; +use crate::core::theme::ThemeRef; use crate::LazyStatic; use std::sync::RwLock; // THEMES ****************************************************************************************** -pub static THEMES: LazyStatic>> = - LazyStatic::new(|| RwLock::new(Vec::new())); +pub static THEMES: LazyStatic>> = LazyStatic::new(|| RwLock::new(Vec::new())); // DEFAULT THEME *********************************************************************************** -pub static THEME: LazyStatic = +pub static THEME: LazyStatic = LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) { Some(theme) => theme, None => &crate::core::theme::Basic, @@ -19,7 +18,7 @@ pub static THEME: LazyStatic = // THEME BY NAME *********************************************************************************** -pub fn theme_by_single_name(single_name: &str) -> Option { +pub fn theme_by_single_name(single_name: &str) -> Option { let single_name = single_name.to_lowercase(); match THEMES .read() diff --git a/pagetop/src/core/theme/basic.rs b/pagetop/src/core/theme/basic.rs index 2a581bec..2217fbd9 100644 --- a/pagetop/src/core/theme/basic.rs +++ b/pagetop/src/core/theme/basic.rs @@ -1,6 +1,6 @@ use crate::core::component::ContextOp; use crate::core::module::ModuleTrait; -use crate::core::theme::{ThemeStaticRef, ThemeTrait}; +use crate::core::theme::{ThemeRef, ThemeTrait}; use crate::html::{Favicon, StyleSheet}; use crate::response::page::Page; use crate::service; @@ -17,7 +17,7 @@ impl ModuleTrait for Basic { THEME_BASIC } - fn theme(&self) -> Option { + fn theme(&self) -> Option { Some(&Basic) } diff --git a/pagetop/src/core/theme/definition.rs b/pagetop/src/core/theme/definition.rs index 71ee358e..aec9fe61 100644 --- a/pagetop/src/core/theme/definition.rs +++ b/pagetop/src/core/theme/definition.rs @@ -5,7 +5,7 @@ use crate::html::{html, Favicon, Markup}; use crate::response::page::Page; use crate::{config, LOCALES_PAGETOP}; -pub type ThemeStaticRef = &'static dyn ThemeTrait; +pub type ThemeRef = &'static dyn ThemeTrait; /// Los temas deben implementar este "trait". pub trait ThemeTrait: ModuleTrait + Send + Sync {