Corrige errores de asignación de identificadores

This commit is contained in:
Manuel Cillero 2022-05-08 11:23:11 +02:00
parent fcc022d164
commit 897ce6bb64
12 changed files with 22 additions and 24 deletions

View file

@ -95,7 +95,7 @@ impl Form {
self self
} }
pub fn with_hook(mut self, action: &str) -> Self { pub fn with_action(mut self, action: &str) -> Self {
self.alter_action(action); self.alter_action(action);
self self
} }

View file

@ -11,7 +11,7 @@ impl ThemeTrait for Aliner {
ALINER_THEME 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"); theme_static_files!(cfg, "/aliner");
} }

View file

@ -13,7 +13,7 @@ impl ThemeTrait for Bootsier {
BOOTSIER_THEME 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"); theme_static_files!(cfg, "/bootsier");
} }

View file

@ -11,7 +11,7 @@ impl ThemeTrait for Bulmix {
BULMIX_THEME 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"); theme_static_files!(cfg, "/bulmix");
} }

View file

@ -1,7 +1,7 @@
use crate::core::hook::{HookTrait, AnyHook}; use crate::core::hook::{HookTrait, AnyHook};
use super::{Assets, ComponentTrait}; 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 { pub struct BeforeRenderComponentHook {
hook: Option<fn(&mut dyn ComponentTrait, &mut Assets)>, hook: Option<fn(&mut dyn ComponentTrait, &mut Assets)>,

View file

@ -25,10 +25,8 @@ mod holder;
pub use holder::ComponentsHolder; pub use holder::ComponentsHolder;
mod all; mod all;
pub use all::{ pub use all::add_component_to;
add_component_to, pub(crate) use all::common_components;
common_components,
};
pub fn render_always() -> bool { true } pub fn render_always() -> bool { true }

View file

@ -9,13 +9,13 @@ static ACTIONS: Lazy<RwLock<HashMap<&str, HooksHolder>>> = Lazy::new(|| {
RwLock::new(HashMap::new()) RwLock::new(HashMap::new())
}); });
pub fn add_hook(action: HookItem) { pub fn add_hook(hook: HookItem) {
let mut hmap = ACTIONS.write().unwrap(); 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) { if let Some(actions) = hmap.get_mut(action_handler) {
actions.add(action); actions.add(hook);
} else { } else {
hmap.insert(action_handler, HooksHolder::new_with(action)); hmap.insert(action_handler, HooksHolder::new_with(hook));
} }
} }

View file

@ -12,6 +12,6 @@ pub trait HookTrait: AnyHook + Send + Sync {
fn as_ref_any(&self) -> &dyn AnyHook; fn as_ref_any(&self) -> &dyn AnyHook;
} }
pub fn hook_ref<A: 'static>(action: &dyn HookTrait) -> &A { pub fn hook_ref<A: 'static>(hook: &dyn HookTrait) -> &A {
action.as_ref_any().downcast_ref::<A>().unwrap() hook.as_ref_any().downcast_ref::<A>().unwrap()
} }

View file

@ -6,8 +6,8 @@ pub type HookItem = Box<dyn HookTrait>;
#[macro_export] #[macro_export]
macro_rules! hook_item { macro_rules! hook_item {
( $action:ident => $f:ident $(, $weight:expr)? ) => {{ ( $hook:ident => $f:ident $(, $weight:expr)? ) => {{
Box::new($action::new().with_hook($f)$(.with_weight($weight))?) Box::new($hook::new().with_hook($f)$(.with_weight($weight))?)
}}; }};
} }
@ -18,15 +18,15 @@ impl HooksHolder {
HooksHolder(Arc::new(RwLock::new(Vec::new()))) 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(); let mut container = HooksHolder::new();
container.add(action); container.add(hook);
container container
} }
pub fn add(&mut self, action: HookItem) { pub fn add(&mut self, hook: HookItem) {
let mut actions = self.0.write().unwrap(); let mut actions = self.0.write().unwrap();
actions.push(action); actions.push(hook);
actions.sort_by_key(|a| a.weight()); actions.sort_by_key(|a| a.weight());
} }

View file

@ -38,6 +38,6 @@ pub fn themes(cfg: &mut app::web::ServiceConfig) {
theme_static_files!(cfg, "/theme"); theme_static_files!(cfg, "/theme");
for t in THEMES.read().unwrap().iter() { for t in THEMES.read().unwrap().iter() {
t.configure_theme(cfg); t.configure_service(cfg);
} }
} }

View file

@ -23,7 +23,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
} }
#[allow(unused_variables)] #[allow(unused_variables)]
fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { fn configure_service(&self, cfg: &mut app::web::ServiceConfig) {
} }
#[allow(unused_variables)] #[allow(unused_variables)]

View file

@ -1,7 +1,7 @@
use crate::core::hook::{HookTrait, AnyHook}; use crate::core::hook::{HookTrait, AnyHook};
use super::Page; 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 { pub struct BeforeRenderPageHook {
hook: Option<fn(&mut Page)>, hook: Option<fn(&mut Page)>,