From a0c61b008a8a15bdc5d18b55cd2c7a69965a6d71 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Thu, 13 Jul 2023 20:20:30 +0200 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=20Revierte=20el=20cambio=20de=20Basic?= =?UTF-8?q?=20por=20Monster?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop-aliner/src/lib.rs | 2 +- pagetop-bootsier/src/lib.rs | 2 +- pagetop-bulmix/src/lib.rs | 2 +- pagetop/build.rs | 4 +- pagetop/src/core/module/all.rs | 2 +- pagetop/src/core/theme.rs | 5 +- pagetop/src/core/theme/all.rs | 2 +- .../src/core/theme/{monster.rs => basic.rs} | 20 ++++---- pagetop/src/core/theme/definition.rs | 2 +- pagetop/src/util.rs | 44 +++++++++++------- .../{monster => theme}/css/normalize.min.css | 0 pagetop/static/{monster => theme}/favicon.ico | Bin 12 files changed, 47 insertions(+), 38 deletions(-) rename pagetop/src/core/theme/{monster.rs => basic.rs} (59%) rename pagetop/static/{monster => theme}/css/normalize.min.css (100%) rename pagetop/static/{monster => theme}/favicon.ico (100%) diff --git a/pagetop-aliner/src/lib.rs b/pagetop-aliner/src/lib.rs index f5551088..f532eef1 100644 --- a/pagetop-aliner/src/lib.rs +++ b/pagetop-aliner/src/lib.rs @@ -22,7 +22,7 @@ impl ModuleTrait for Aliner { impl ThemeTrait for Aliner { fn before_prepare_body(&self, page: &mut Page) { - page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico"))) + page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( StyleSheet::at("/aliner/css/styles.css").with_weight(-99), )); diff --git a/pagetop-bootsier/src/lib.rs b/pagetop-bootsier/src/lib.rs index 7f4abe0d..338cc6cf 100644 --- a/pagetop-bootsier/src/lib.rs +++ b/pagetop-bootsier/src/lib.rs @@ -44,7 +44,7 @@ impl ThemeTrait for Bootsier { } fn before_prepare_body(&self, page: &mut Page) { - page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico"))) + page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( StyleSheet::at("/bootsier/css/bootstrap.min.css") .with_version("5.1.3") diff --git a/pagetop-bulmix/src/lib.rs b/pagetop-bulmix/src/lib.rs index 988d97f0..9059ed56 100644 --- a/pagetop-bulmix/src/lib.rs +++ b/pagetop-bulmix/src/lib.rs @@ -32,7 +32,7 @@ impl ModuleTrait for Bulmix { impl ThemeTrait for Bulmix { fn before_prepare_body(&self, page: &mut Page) { - page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico"))) + page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( StyleSheet::at("/bulmix/css/bulma.min.css") .with_version("0.9.4") diff --git a/pagetop/build.rs b/pagetop/build.rs index d1a5030f..3e2d9749 100644 --- a/pagetop/build.rs +++ b/pagetop/build.rs @@ -1,7 +1,7 @@ use pagetop_build::StaticFilesBundle; fn main() -> std::io::Result<()> { - StaticFilesBundle::from_dir("./static/monster") - .with_name("monster") + StaticFilesBundle::from_dir("./static/theme") + .with_name("theme") .build() } diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index e3dfac8e..6575b3a9 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -28,7 +28,7 @@ pub fn register_modules(app: ModuleStaticRef) { let mut list: Vec = Vec::new(); // Enable basic theme. - add_to_enabled(&mut list, &crate::core::theme::monster::Monster); + add_to_enabled(&mut list, &crate::core::theme::Basic); // Enable application modules. add_to_enabled(&mut list, app); diff --git a/pagetop/src/core/theme.rs b/pagetop/src/core/theme.rs index 84bc68dc..e12f7d21 100644 --- a/pagetop/src/core/theme.rs +++ b/pagetop/src/core/theme.rs @@ -5,6 +5,7 @@ mod regions; pub use regions::add_component_to; pub(crate) use regions::ComponentsRegions; -pub(crate) mod all; +mod basic; +pub(crate) use basic::Basic; -pub(crate) mod monster; +pub(crate) mod all; diff --git a/pagetop/src/core/theme/all.rs b/pagetop/src/core/theme/all.rs index eabc66e3..fcc09467 100644 --- a/pagetop/src/core/theme/all.rs +++ b/pagetop/src/core/theme/all.rs @@ -14,7 +14,7 @@ pub static THEMES: LazyStatic>> = pub static THEME: LazyStatic = LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) { Some(theme) => theme, - None => &crate::core::theme::monster::Monster, + None => &crate::core::theme::Basic, }); // THEME BY NAME *********************************************************************************** diff --git a/pagetop/src/core/theme/monster.rs b/pagetop/src/core/theme/basic.rs similarity index 59% rename from pagetop/src/core/theme/monster.rs rename to pagetop/src/core/theme/basic.rs index c90471db..0a2091b6 100644 --- a/pagetop/src/core/theme/monster.rs +++ b/pagetop/src/core/theme/basic.rs @@ -6,31 +6,31 @@ use crate::response::page::Page; use crate::service; use crate::{serve_static_files, use_handle, use_static, Handle}; -use_handle!(THEME_MONSTER); +use_handle!(THEME_BASIC); -use_static!(monster); +use_static!(theme); -pub struct Monster; +pub struct Basic; -impl ModuleTrait for Monster { +impl ModuleTrait for Basic { fn handle(&self) -> Handle { - THEME_MONSTER + THEME_BASIC } fn theme(&self) -> Option { - Some(&Monster) + Some(&Basic) } fn configure_service(&self, cfg: &mut service::web::ServiceConfig) { - serve_static_files!(cfg, "/monster", monster); + serve_static_files!(cfg, "/theme", theme); } } -impl ThemeTrait for Monster { +impl ThemeTrait for Basic { fn before_prepare_body(&self, page: &mut Page) { - page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico"))) + page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( - StyleSheet::at("/monster/css/normalize.min.css").with_version("8.0.1"), + StyleSheet::at("/theme/css/normalize.min.css").with_version("8.0.1"), )); } } diff --git a/pagetop/src/core/theme/definition.rs b/pagetop/src/core/theme/definition.rs index 2a6c7d09..cb347ef6 100644 --- a/pagetop/src/core/theme/definition.rs +++ b/pagetop/src/core/theme/definition.rs @@ -37,7 +37,7 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync { fn after_prepare_body(&self, page: &mut Page) { if page.favicon().is_none() { - page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico"))); + page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))); } } diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index 43cd925f..06f70f16 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -155,35 +155,43 @@ macro_rules! use_locale { #[macro_export] macro_rules! use_static { ( $bundle:ident ) => { - mod static_bundle { - include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); + $crate::paste! { + mod [] { + include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); + } } }; ( $bundle:ident => $STATIC:ident ) => { - mod static_bundle { - include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); + $crate::paste! { + mod [] { + include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); + } + static $STATIC: LazyStatic = LazyStatic::new([ + ]::$bundle + ); } - static $STATIC: LazyStatic = LazyStatic::new(static_bundle::$bundle); }; } #[macro_export] macro_rules! serve_static_files { ( $cfg:ident, $path:expr, $bundle:ident ) => {{ - let static_files = &$crate::config::SETTINGS.dev.static_files; - if static_files.is_empty() { - $cfg.service($crate::service::ResourceFiles::new( - $path, - static_bundle::$bundle(), - )); - } else { - $cfg.service( - $crate::service::ActixFiles::new( + $crate::paste! { + let static_files = &$crate::config::SETTINGS.dev.static_files; + if static_files.is_empty() { + $cfg.service($crate::service::ResourceFiles::new( $path, - $crate::concat_string!(static_files, $path), - ) - .show_files_listing(), - ); + []::$bundle(), + )); + } else { + $cfg.service( + $crate::service::ActixFiles::new( + $path, + $crate::concat_string!(static_files, $path), + ) + .show_files_listing(), + ); + } } }}; } diff --git a/pagetop/static/monster/css/normalize.min.css b/pagetop/static/theme/css/normalize.min.css similarity index 100% rename from pagetop/static/monster/css/normalize.min.css rename to pagetop/static/theme/css/normalize.min.css diff --git a/pagetop/static/monster/favicon.ico b/pagetop/static/theme/favicon.ico similarity index 100% rename from pagetop/static/monster/favicon.ico rename to pagetop/static/theme/favicon.ico