From 897ce6bb64ade574f9878059e28b670b286d77f8 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Sun, 8 May 2022 11:23:11 +0200 Subject: [PATCH] =?UTF-8?q?Corrige=20errores=20de=20asignaci=C3=B3n=20de?= =?UTF-8?q?=20identificadores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop/src/base/component/form/form.rs | 2 +- pagetop/src/base/theme/aliner/mod.rs | 2 +- pagetop/src/base/theme/bootsier/mod.rs | 2 +- pagetop/src/base/theme/bulmix/mod.rs | 2 +- pagetop/src/core/component/hook.rs | 2 +- pagetop/src/core/component/mod.rs | 6 ++---- pagetop/src/core/hook/all.rs | 8 ++++---- pagetop/src/core/hook/definition.rs | 4 ++-- pagetop/src/core/hook/holder.rs | 12 ++++++------ pagetop/src/core/theme/all.rs | 2 +- pagetop/src/core/theme/definition.rs | 2 +- pagetop/src/response/page/hook.rs | 2 +- 12 files changed, 22 insertions(+), 24 deletions(-) diff --git a/pagetop/src/base/component/form/form.rs b/pagetop/src/base/component/form/form.rs index 189eb0c4..dcf209b0 100644 --- a/pagetop/src/base/component/form/form.rs +++ b/pagetop/src/base/component/form/form.rs @@ -95,7 +95,7 @@ impl Form { self } - pub fn with_hook(mut self, action: &str) -> Self { + pub fn with_action(mut self, action: &str) -> Self { self.alter_action(action); self } diff --git a/pagetop/src/base/theme/aliner/mod.rs b/pagetop/src/base/theme/aliner/mod.rs index f3c90f9b..d27c4632 100644 --- a/pagetop/src/base/theme/aliner/mod.rs +++ b/pagetop/src/base/theme/aliner/mod.rs @@ -11,7 +11,7 @@ impl ThemeTrait for Aliner { ALINER_THEME } - fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { + fn configure_service(&self, cfg: &mut app::web::ServiceConfig) { theme_static_files!(cfg, "/aliner"); } diff --git a/pagetop/src/base/theme/bootsier/mod.rs b/pagetop/src/base/theme/bootsier/mod.rs index a8be7118..5471b5cf 100644 --- a/pagetop/src/base/theme/bootsier/mod.rs +++ b/pagetop/src/base/theme/bootsier/mod.rs @@ -13,7 +13,7 @@ impl ThemeTrait for Bootsier { BOOTSIER_THEME } - fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { + fn configure_service(&self, cfg: &mut app::web::ServiceConfig) { theme_static_files!(cfg, "/bootsier"); } diff --git a/pagetop/src/base/theme/bulmix/mod.rs b/pagetop/src/base/theme/bulmix/mod.rs index 477dbbf7..e047b214 100644 --- a/pagetop/src/base/theme/bulmix/mod.rs +++ b/pagetop/src/base/theme/bulmix/mod.rs @@ -11,7 +11,7 @@ impl ThemeTrait for Bulmix { BULMIX_THEME } - fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { + fn configure_service(&self, cfg: &mut app::web::ServiceConfig) { theme_static_files!(cfg, "/bulmix"); } diff --git a/pagetop/src/core/component/hook.rs b/pagetop/src/core/component/hook.rs index a35e09ad..f52d755b 100644 --- a/pagetop/src/core/component/hook.rs +++ b/pagetop/src/core/component/hook.rs @@ -1,7 +1,7 @@ use crate::core::hook::{HookTrait, AnyHook}; use super::{Assets, ComponentTrait}; -pub const BEFORE_RENDER_COMPONENT_HOOK: &str = "pagetop::action::before_render_component"; +pub const BEFORE_RENDER_COMPONENT_HOOK: &str = "pagetop::hook::before_render_component"; pub struct BeforeRenderComponentHook { hook: Option, diff --git a/pagetop/src/core/component/mod.rs b/pagetop/src/core/component/mod.rs index 1f710deb..c0c78a57 100644 --- a/pagetop/src/core/component/mod.rs +++ b/pagetop/src/core/component/mod.rs @@ -25,10 +25,8 @@ mod holder; pub use holder::ComponentsHolder; mod all; -pub use all::{ - add_component_to, - common_components, -}; +pub use all::add_component_to; +pub(crate) use all::common_components; pub fn render_always() -> bool { true } diff --git a/pagetop/src/core/hook/all.rs b/pagetop/src/core/hook/all.rs index 2329b251..5c6f28d9 100644 --- a/pagetop/src/core/hook/all.rs +++ b/pagetop/src/core/hook/all.rs @@ -9,13 +9,13 @@ static ACTIONS: Lazy>> = Lazy::new(|| { RwLock::new(HashMap::new()) }); -pub fn add_hook(action: HookItem) { +pub fn add_hook(hook: HookItem) { let mut hmap = ACTIONS.write().unwrap(); - let action_handler = action.handler(); + let action_handler = hook.handler(); if let Some(actions) = hmap.get_mut(action_handler) { - actions.add(action); + actions.add(hook); } else { - hmap.insert(action_handler, HooksHolder::new_with(action)); + hmap.insert(action_handler, HooksHolder::new_with(hook)); } } diff --git a/pagetop/src/core/hook/definition.rs b/pagetop/src/core/hook/definition.rs index 823e830e..e21ea10f 100644 --- a/pagetop/src/core/hook/definition.rs +++ b/pagetop/src/core/hook/definition.rs @@ -12,6 +12,6 @@ pub trait HookTrait: AnyHook + Send + Sync { fn as_ref_any(&self) -> &dyn AnyHook; } -pub fn hook_ref(action: &dyn HookTrait) -> &A { - action.as_ref_any().downcast_ref::().unwrap() +pub fn hook_ref(hook: &dyn HookTrait) -> &A { + hook.as_ref_any().downcast_ref::().unwrap() } diff --git a/pagetop/src/core/hook/holder.rs b/pagetop/src/core/hook/holder.rs index 3cd6d369..cd138c67 100644 --- a/pagetop/src/core/hook/holder.rs +++ b/pagetop/src/core/hook/holder.rs @@ -6,8 +6,8 @@ pub type HookItem = Box; #[macro_export] macro_rules! hook_item { - ( $action:ident => $f:ident $(, $weight:expr)? ) => {{ - Box::new($action::new().with_hook($f)$(.with_weight($weight))?) + ( $hook:ident => $f:ident $(, $weight:expr)? ) => {{ + Box::new($hook::new().with_hook($f)$(.with_weight($weight))?) }}; } @@ -18,15 +18,15 @@ impl HooksHolder { HooksHolder(Arc::new(RwLock::new(Vec::new()))) } - pub fn new_with(action: HookItem) -> Self { + pub fn new_with(hook: HookItem) -> Self { let mut container = HooksHolder::new(); - container.add(action); + container.add(hook); container } - pub fn add(&mut self, action: HookItem) { + pub fn add(&mut self, hook: HookItem) { let mut actions = self.0.write().unwrap(); - actions.push(action); + actions.push(hook); actions.sort_by_key(|a| a.weight()); } diff --git a/pagetop/src/core/theme/all.rs b/pagetop/src/core/theme/all.rs index 2a54f578..ba725b71 100644 --- a/pagetop/src/core/theme/all.rs +++ b/pagetop/src/core/theme/all.rs @@ -38,6 +38,6 @@ pub fn themes(cfg: &mut app::web::ServiceConfig) { theme_static_files!(cfg, "/theme"); for t in THEMES.read().unwrap().iter() { - t.configure_theme(cfg); + t.configure_service(cfg); } } diff --git a/pagetop/src/core/theme/definition.rs b/pagetop/src/core/theme/definition.rs index 697f52ea..74457e19 100644 --- a/pagetop/src/core/theme/definition.rs +++ b/pagetop/src/core/theme/definition.rs @@ -23,7 +23,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync { } #[allow(unused_variables)] - fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { + fn configure_service(&self, cfg: &mut app::web::ServiceConfig) { } #[allow(unused_variables)] diff --git a/pagetop/src/response/page/hook.rs b/pagetop/src/response/page/hook.rs index e63a189c..d482fb56 100644 --- a/pagetop/src/response/page/hook.rs +++ b/pagetop/src/response/page/hook.rs @@ -1,7 +1,7 @@ use crate::core::hook::{HookTrait, AnyHook}; use super::Page; -pub const BEFORE_RENDER_PAGE_HOOK: &str = "pagetop::action::before_render_page"; +pub const BEFORE_RENDER_PAGE_HOOK: &str = "pagetop::hook::before_render_page"; pub struct BeforeRenderPageHook { hook: Option,