Corrige errores de asignación de identificadores
This commit is contained in:
parent
fcc022d164
commit
897ce6bb64
12 changed files with 22 additions and 24 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<fn(&mut dyn ComponentTrait, &mut Assets)>,
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ static ACTIONS: Lazy<RwLock<HashMap<&str, HooksHolder>>> = 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ pub trait HookTrait: AnyHook + Send + Sync {
|
|||
fn as_ref_any(&self) -> &dyn AnyHook;
|
||||
}
|
||||
|
||||
pub fn hook_ref<A: 'static>(action: &dyn HookTrait) -> &A {
|
||||
action.as_ref_any().downcast_ref::<A>().unwrap()
|
||||
pub fn hook_ref<A: 'static>(hook: &dyn HookTrait) -> &A {
|
||||
hook.as_ref_any().downcast_ref::<A>().unwrap()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ pub type HookItem = Box<dyn HookTrait>;
|
|||
|
||||
#[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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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<fn(&mut Page)>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue