♻️ Diferencia módulos y temas
This commit is contained in:
parent
163302f4ea
commit
772546c164
10 changed files with 40 additions and 29 deletions
|
|
@ -6,8 +6,11 @@ pub mod action;
|
||||||
// API to build new components.
|
// API to build new components.
|
||||||
pub mod component;
|
pub mod component;
|
||||||
|
|
||||||
// API to add new features with modules and themes.
|
// API to add new features with modules.
|
||||||
pub mod module;
|
pub mod module;
|
||||||
|
|
||||||
|
// API to add new layouts with themes.
|
||||||
|
pub mod theme;
|
||||||
|
|
||||||
// Basic theme.
|
// Basic theme.
|
||||||
pub(crate) mod basic;
|
pub(crate) mod basic;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::core::module::{ModuleTrait, ThemeStaticRef, ThemeTrait};
|
use crate::core::module::ModuleTrait;
|
||||||
|
use crate::core::theme::{ThemeStaticRef, ThemeTrait};
|
||||||
use crate::html::Favicon;
|
use crate::html::Favicon;
|
||||||
use crate::response::page::Page;
|
use crate::response::page::Page;
|
||||||
use crate::{define_handle, serve_static_files, server, Handle};
|
use crate::{define_handle, serve_static_files, server, Handle};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::core::module::{all::theme_by_single_name, ThemeStaticRef};
|
use crate::core::theme::{all::theme_by_single_name, ThemeStaticRef};
|
||||||
use crate::html::{html, Assets, IdentifierValue, JavaScript, Markup, StyleSheet};
|
use crate::html::{html, Assets, IdentifierValue, JavaScript, Markup, StyleSheet};
|
||||||
use crate::locale::{LanguageIdentifier, LANGID};
|
use crate::locale::{LanguageIdentifier, LANGID};
|
||||||
use crate::server::HttpRequest;
|
use crate::server::HttpRequest;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::{BaseModule, ModuleStaticRef, ModuleTrait, MODULE_UNNAMED};
|
pub use definition::{BaseModule, ModuleStaticRef, ModuleTrait, MODULE_UNNAMED};
|
||||||
|
|
||||||
mod theme;
|
|
||||||
pub use theme::{ThemeStaticRef, ThemeTrait};
|
|
||||||
|
|
||||||
pub(crate) mod all;
|
pub(crate) mod all;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::core::action::add_action;
|
use crate::core::action::add_action;
|
||||||
use crate::core::module::{ModuleStaticRef, ThemeStaticRef};
|
use crate::core::module::ModuleStaticRef;
|
||||||
|
use crate::core::theme::all::THEMES;
|
||||||
use crate::{server, trace, LazyStatic};
|
use crate::{server, trace, LazyStatic};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
|
|
@ -15,24 +16,6 @@ static ENABLED_MODULES: LazyStatic<RwLock<Vec<ModuleStaticRef>>> =
|
||||||
static DROPPED_MODULES: LazyStatic<RwLock<Vec<ModuleStaticRef>>> =
|
static DROPPED_MODULES: LazyStatic<RwLock<Vec<ModuleStaticRef>>> =
|
||||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||||
|
|
||||||
// THEMES ******************************************************************************************
|
|
||||||
|
|
||||||
static THEMES: LazyStatic<RwLock<Vec<ThemeStaticRef>>> =
|
|
||||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
|
||||||
|
|
||||||
pub fn theme_by_single_name(single_name: &str) -> Option<ThemeStaticRef> {
|
|
||||||
let single_name = single_name.to_lowercase();
|
|
||||||
match THEMES
|
|
||||||
.read()
|
|
||||||
.unwrap()
|
|
||||||
.iter()
|
|
||||||
.find(|t| t.single_name().to_lowercase() == single_name)
|
|
||||||
{
|
|
||||||
Some(theme) => Some(*theme),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// REGISTER MODULES ********************************************************************************
|
// REGISTER MODULES ********************************************************************************
|
||||||
|
|
||||||
pub fn register_modules(app: ModuleStaticRef) {
|
pub fn register_modules(app: ModuleStaticRef) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::core::action::Action;
|
use crate::core::action::Action;
|
||||||
use crate::core::component::L10n;
|
use crate::core::component::L10n;
|
||||||
use crate::core::module::ThemeStaticRef;
|
use crate::core::theme::ThemeStaticRef;
|
||||||
use crate::util::single_type_name;
|
use crate::util::single_type_name;
|
||||||
use crate::{define_handle, server, Handle};
|
use crate::{define_handle, server, Handle};
|
||||||
|
|
||||||
|
|
|
||||||
4
pagetop/src/core/theme.rs
Normal file
4
pagetop/src/core/theme.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
mod definition;
|
||||||
|
pub use definition::{ThemeStaticRef, ThemeTrait};
|
||||||
|
|
||||||
|
pub(crate) mod all;
|
||||||
24
pagetop/src/core/theme/all.rs
Normal file
24
pagetop/src/core/theme/all.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
use crate::core::theme::ThemeStaticRef;
|
||||||
|
use crate::LazyStatic;
|
||||||
|
|
||||||
|
use std::sync::RwLock;
|
||||||
|
|
||||||
|
// THEMES ******************************************************************************************
|
||||||
|
|
||||||
|
pub static THEMES: LazyStatic<RwLock<Vec<ThemeStaticRef>>> =
|
||||||
|
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||||
|
|
||||||
|
// THEME BY NAME ***********************************************************************************
|
||||||
|
|
||||||
|
pub fn theme_by_single_name(single_name: &str) -> Option<ThemeStaticRef> {
|
||||||
|
let single_name = single_name.to_lowercase();
|
||||||
|
match THEMES
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.find(|t| t.single_name().to_lowercase() == single_name)
|
||||||
|
{
|
||||||
|
Some(theme) => Some(*theme),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
use super::ModuleTrait;
|
|
||||||
|
|
||||||
use crate::app::LOCALE_PAGETOP;
|
use crate::app::LOCALE_PAGETOP;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::core::component::{ComponentTrait, L10n, RenderContext};
|
use crate::core::component::{ComponentTrait, L10n, RenderContext};
|
||||||
|
use crate::core::module::ModuleTrait;
|
||||||
use crate::html::{html, Favicon, Markup};
|
use crate::html::{html, Favicon, Markup};
|
||||||
use crate::response::page::Page;
|
use crate::response::page::Page;
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ pub use crate::html::*;
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
pub use crate::{db, db::*, migration_item, pub_migration};
|
pub use crate::{db, db::*, migration_item, pub_migration};
|
||||||
|
|
||||||
pub use crate::core::{action::*, component::*, module::*};
|
pub use crate::core::{action::*, component::*, module::*, theme::*};
|
||||||
|
|
||||||
pub use crate::{action, action_before_render_component};
|
pub use crate::{action, action_before_render_component};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue