🚧 Working on actions
This commit is contained in:
parent
e732244a2e
commit
d99a5aa586
23 changed files with 480 additions and 323 deletions
|
|
@ -15,10 +15,10 @@ impl PackageTrait for Admin {
|
||||||
L10n::t("package_description", &LOCALES_ADMIN)
|
L10n::t("package_description", &LOCALES_ADMIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> Vec<Action> {
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
actions![
|
actions![
|
||||||
action::page::BeforePrepareBody::new(before_prepare_body),
|
action::page::BeforePrepareBody::new(before_prepare_body),
|
||||||
action::component::BeforePrepareComponent::<Menu>::new(before_prepare_menu)
|
action::component::BeforePrepare::<Menu>::new(before_prepare_menu)
|
||||||
.filter_by_referer_id("admin-menu-test"),
|
.filter_by_referer_id("admin-menu-test"),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,17 @@ impl PackageTrait for Bootsier {
|
||||||
Some(&Bootsier)
|
Some(&Bootsier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
|
actions![
|
||||||
|
action::theme::BeforePrepare::<Icon>::new(&Self, before_prepare_icon),
|
||||||
|
action::theme::BeforePrepare::<Button>::new(&Self, before_prepare_button),
|
||||||
|
action::theme::BeforePrepare::<Heading>::new(&Self, before_prepare_heading),
|
||||||
|
action::theme::BeforePrepare::<Paragraph>::new(&Self, before_prepare_paragraph),
|
||||||
|
action::theme::RenderComponent::<Layout>::new(&Self, render_layout),
|
||||||
|
action::theme::RenderComponent::<Error404>::new(&Self, render_error404),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||||
service_for_static_files!(scfg, bootsier => "/bootsier");
|
service_for_static_files!(scfg, bootsier => "/bootsier");
|
||||||
}
|
}
|
||||||
|
|
@ -49,15 +60,17 @@ impl ThemeTrait for Bootsier {
|
||||||
StyleSheet::at("/bootsier/css/styles.css").with_version("0.0.1"),
|
StyleSheet::at("/bootsier/css/styles.css").with_version("0.0.1"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
fn before_prepare_icon(i: &mut Icon, _cx: &mut Context) {
|
||||||
fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) {
|
|
||||||
if let Some(i) = component.downcast_mut::<Icon>() {
|
|
||||||
i.alter_classes(
|
i.alter_classes(
|
||||||
ClassesOp::Replace(i.font_size().to_string()),
|
ClassesOp::Replace(i.font_size().to_string()),
|
||||||
with_font(i.font_size()),
|
with_font(i.font_size()),
|
||||||
);
|
);
|
||||||
} else if let Some(b) = component.downcast_mut::<Button>() {
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
fn before_prepare_button(b: &mut Button, _cx: &mut Context) {
|
||||||
b.alter_classes(ClassesOp::Replace("button__tap".to_owned()), "btn");
|
b.alter_classes(ClassesOp::Replace("button__tap".to_owned()), "btn");
|
||||||
b.alter_classes(
|
b.alter_classes(
|
||||||
ClassesOp::Replace(b.style().to_string()),
|
ClassesOp::Replace(b.style().to_string()),
|
||||||
|
|
@ -76,7 +89,10 @@ impl ThemeTrait for Bootsier {
|
||||||
ClassesOp::Replace(b.font_size().to_string()),
|
ClassesOp::Replace(b.font_size().to_string()),
|
||||||
with_font(b.font_size()),
|
with_font(b.font_size()),
|
||||||
);
|
);
|
||||||
} else if let Some(h) = component.downcast_mut::<Heading>() {
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
fn before_prepare_heading(h: &mut Heading, _cx: &mut Context) {
|
||||||
h.alter_classes(
|
h.alter_classes(
|
||||||
ClassesOp::Replace(h.size().to_string()),
|
ClassesOp::Replace(h.size().to_string()),
|
||||||
match h.size() {
|
match h.size() {
|
||||||
|
|
@ -88,16 +104,16 @@ impl ThemeTrait for Bootsier {
|
||||||
_ => "",
|
_ => "",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else if let Some(p) = component.downcast_mut::<Paragraph>() {
|
}
|
||||||
|
|
||||||
|
fn before_prepare_paragraph(p: &mut Paragraph, _cx: &mut Context) {
|
||||||
p.alter_classes(
|
p.alter_classes(
|
||||||
ClassesOp::Replace(p.font_size().to_string()),
|
ClassesOp::Replace(p.font_size().to_string()),
|
||||||
with_font(p.font_size()),
|
with_font(p.font_size()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn render_component(&self, component: &dyn ComponentTrait, cx: &mut Context) -> Option<Markup> {
|
fn render_layout(_: &Layout, cx: &mut Context) -> Option<Markup> {
|
||||||
if component.downcast_ref::<Layout>().is_some() {
|
|
||||||
Some(
|
Some(
|
||||||
match cx.layout() {
|
match cx.layout() {
|
||||||
"admin" => Container::new().add_item(
|
"admin" => Container::new().add_item(
|
||||||
|
|
@ -121,7 +137,9 @@ impl ThemeTrait for Bootsier {
|
||||||
}
|
}
|
||||||
.render(cx),
|
.render(cx),
|
||||||
)
|
)
|
||||||
} else if component.downcast_ref::<Error404>().is_some() {
|
}
|
||||||
|
|
||||||
|
fn render_error404(_: &Error404, cx: &mut Context) -> Option<Markup> {
|
||||||
Some(html! {
|
Some(html! {
|
||||||
div class="jumbotron" {
|
div class="jumbotron" {
|
||||||
div class="media" {
|
div class="media" {
|
||||||
|
|
@ -153,10 +171,6 @@ impl ThemeTrait for Bootsier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,16 @@ impl PackageTrait for Bulmix {
|
||||||
Some(&Bulmix)
|
Some(&Bulmix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
|
actions![
|
||||||
|
action::theme::BeforePrepare::<Icon>::new(&Self, before_prepare_icon),
|
||||||
|
action::theme::BeforePrepare::<Button>::new(&Self, before_prepare_button),
|
||||||
|
action::theme::BeforePrepare::<Heading>::new(&Self, before_prepare_heading),
|
||||||
|
action::theme::BeforePrepare::<Paragraph>::new(&Self, before_prepare_paragraph),
|
||||||
|
action::theme::RenderComponent::<Icon>::new(&Self, render_icon),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||||
service_for_static_files!(scfg, bulmix => "/bulmix");
|
service_for_static_files!(scfg, bulmix => "/bulmix");
|
||||||
}
|
}
|
||||||
|
|
@ -38,15 +48,17 @@ impl ThemeTrait for Bulmix {
|
||||||
StyleSheet::at("/bulmix/css/styles.css").with_version("0.0.1"),
|
StyleSheet::at("/bulmix/css/styles.css").with_version("0.0.1"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
fn before_prepare_icon(i: &mut Icon, _cx: &mut Context) {
|
||||||
fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) {
|
|
||||||
if let Some(i) = component.downcast_mut::<Icon>() {
|
|
||||||
i.alter_classes(
|
i.alter_classes(
|
||||||
ClassesOp::Replace(i.font_size().to_string()),
|
ClassesOp::Replace(i.font_size().to_string()),
|
||||||
with_font(i.font_size()),
|
with_font(i.font_size()),
|
||||||
);
|
);
|
||||||
} else if let Some(b) = component.downcast_mut::<Button>() {
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
fn before_prepare_button(b: &mut Button, _cx: &mut Context) {
|
||||||
b.alter_classes(ClassesOp::Replace("button__tap".to_owned()), "button");
|
b.alter_classes(ClassesOp::Replace("button__tap".to_owned()), "button");
|
||||||
b.alter_classes(
|
b.alter_classes(
|
||||||
ClassesOp::Replace(b.style().to_string()),
|
ClassesOp::Replace(b.style().to_string()),
|
||||||
|
|
@ -65,36 +77,31 @@ impl ThemeTrait for Bulmix {
|
||||||
ClassesOp::Replace(b.font_size().to_string()),
|
ClassesOp::Replace(b.font_size().to_string()),
|
||||||
with_font(b.font_size()),
|
with_font(b.font_size()),
|
||||||
);
|
);
|
||||||
} else if let Some(h) = component.downcast_mut::<Heading>() {
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
fn before_prepare_heading(h: &mut Heading, _cx: &mut Context) {
|
||||||
match h.size() {
|
match h.size() {
|
||||||
HeadingSize::Subtitle => {
|
HeadingSize::Subtitle => {
|
||||||
h.alter_classes(ClassesOp::Replace(h.size().to_string()), "subtitle")
|
h.alter_classes(ClassesOp::Replace(h.size().to_string()), "subtitle")
|
||||||
}
|
}
|
||||||
_ => h.alter_classes(ClassesOp::Add, "title"),
|
_ => h.alter_classes(ClassesOp::Add, "title"),
|
||||||
};
|
};
|
||||||
} else if let Some(p) = component.downcast_mut::<Paragraph>() {
|
}
|
||||||
|
|
||||||
|
fn before_prepare_paragraph(p: &mut Paragraph, _cx: &mut Context) {
|
||||||
p.alter_classes(ClassesOp::Add, "block");
|
p.alter_classes(ClassesOp::Add, "block");
|
||||||
p.alter_classes(
|
p.alter_classes(
|
||||||
ClassesOp::Replace(p.font_size().to_string()),
|
ClassesOp::Replace(p.font_size().to_string()),
|
||||||
with_font(p.font_size()),
|
with_font(p.font_size()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn render_component(
|
fn render_icon(i: &Icon, _cx: &mut Context) -> Option<Markup> {
|
||||||
&self,
|
|
||||||
component: &dyn ComponentTrait,
|
|
||||||
_cx: &mut Context,
|
|
||||||
) -> Option<Markup> {
|
|
||||||
if let Some(i) = component.downcast_ref::<Icon>() {
|
|
||||||
return match i.icon_name().get() {
|
return match i.icon_name().get() {
|
||||||
None => None,
|
None => None,
|
||||||
_ => Some(html! { span class="icon" { i class=[i.classes().get()] {} } }),
|
_ => Some(html! { span class="icon" { i class=[i.classes().get()] {} } }),
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl PackageTrait for Node {
|
||||||
scfg.route("/node", service::web::get().to(node));
|
scfg.route("/node", service::web::get().to(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> Vec<Action> {
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
actions![action::page::BeforePrepareBody::new(before_prepare_body).with_weight(-1)]
|
actions![action::page::BeforePrepareBody::new(before_prepare_body).with_weight(-1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
pub mod component;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
pub type FnActionWithComponent<C> = fn(component: &mut C, cx: &mut Context);
|
||||||
|
|
||||||
pub mod page;
|
pub mod page;
|
||||||
|
|
||||||
|
pub mod theme;
|
||||||
|
|
||||||
|
pub mod component;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
pub type FnActionComponent<C> = fn(component: &mut C, cx: &mut Context);
|
|
||||||
|
|
||||||
mod before_prepare_component;
|
mod before_prepare_component;
|
||||||
pub use before_prepare_component::*;
|
pub use before_prepare_component::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use super::FnActionComponent;
|
use crate::base::action::FnActionWithComponent;
|
||||||
|
|
||||||
pub struct AfterPrepareComponent<C: ComponentTrait> {
|
pub struct AfterPrepare<C: ComponentTrait> {
|
||||||
f: FnActionComponent<C>,
|
f: FnActionWithComponent<C>,
|
||||||
referer_type_id: Option<TypeId>,
|
referer_type_id: Option<TypeId>,
|
||||||
referer_id: OptionId,
|
referer_id: OptionId,
|
||||||
weight: Weight,
|
weight: Weight,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ComponentTrait> ActionTrait for AfterPrepareComponent<C> {
|
impl<C: ComponentTrait> ActionTrait for AfterPrepare<C> {
|
||||||
fn referer_type_id(&self) -> Option<TypeId> {
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
self.referer_type_id
|
self.referer_type_id
|
||||||
}
|
}
|
||||||
|
|
@ -23,9 +23,9 @@ impl<C: ComponentTrait> ActionTrait for AfterPrepareComponent<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
impl<C: ComponentTrait> AfterPrepare<C> {
|
||||||
pub fn new(f: FnActionComponent<C>) -> Self {
|
pub fn new(f: FnActionWithComponent<C>) -> Self {
|
||||||
AfterPrepareComponent {
|
AfterPrepare {
|
||||||
f,
|
f,
|
||||||
referer_type_id: Some(TypeId::of::<C>()),
|
referer_type_id: Some(TypeId::of::<C>()),
|
||||||
referer_id: OptionId::default(),
|
referer_id: OptionId::default(),
|
||||||
|
|
@ -44,10 +44,25 @@ impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
pub(crate) fn dispatch(component: &mut C, cx: &mut Context) {
|
||||||
dispatch_actions(
|
dispatch_actions(
|
||||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
ActionKey::new(TypeId::of::<Self>(), None, Some(TypeId::of::<C>()), None),
|
||||||
|
|action: &Self| (action.f)(component, cx),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn dispatch_by_id(component: &mut C, cx: &mut Context) {
|
||||||
|
if component.id().is_some() {
|
||||||
|
dispatch_actions(
|
||||||
|
ActionKey::new(
|
||||||
|
TypeId::of::<Self>(),
|
||||||
|
None,
|
||||||
|
Some(TypeId::of::<C>()),
|
||||||
|
component.id(),
|
||||||
|
),
|
||||||
|action: &Self| (action.f)(component, cx),
|
|action: &Self| (action.f)(component, cx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use super::FnActionComponent;
|
use crate::base::action::FnActionWithComponent;
|
||||||
|
|
||||||
pub struct BeforePrepareComponent<C: ComponentTrait> {
|
pub struct BeforePrepare<C: ComponentTrait> {
|
||||||
f: FnActionComponent<C>,
|
f: FnActionWithComponent<C>,
|
||||||
referer_type_id: Option<TypeId>,
|
referer_type_id: Option<TypeId>,
|
||||||
referer_id: OptionId,
|
referer_id: OptionId,
|
||||||
weight: Weight,
|
weight: Weight,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ComponentTrait> ActionTrait for BeforePrepareComponent<C> {
|
impl<C: ComponentTrait> ActionTrait for BeforePrepare<C> {
|
||||||
fn referer_type_id(&self) -> Option<TypeId> {
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
self.referer_type_id
|
self.referer_type_id
|
||||||
}
|
}
|
||||||
|
|
@ -23,9 +23,9 @@ impl<C: ComponentTrait> ActionTrait for BeforePrepareComponent<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
impl<C: ComponentTrait> BeforePrepare<C> {
|
||||||
pub fn new(f: FnActionComponent<C>) -> Self {
|
pub fn new(f: FnActionWithComponent<C>) -> Self {
|
||||||
BeforePrepareComponent {
|
BeforePrepare {
|
||||||
f,
|
f,
|
||||||
referer_type_id: Some(TypeId::of::<C>()),
|
referer_type_id: Some(TypeId::of::<C>()),
|
||||||
referer_id: OptionId::default(),
|
referer_id: OptionId::default(),
|
||||||
|
|
@ -44,10 +44,25 @@ impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
pub(crate) fn dispatch(component: &mut C, cx: &mut Context) {
|
||||||
dispatch_actions(
|
dispatch_actions(
|
||||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
ActionKey::new(TypeId::of::<Self>(), None, Some(TypeId::of::<C>()), None),
|
||||||
|
|action: &Self| (action.f)(component, cx),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn dispatch_by_id(component: &mut C, cx: &mut Context) {
|
||||||
|
if component.id().is_some() {
|
||||||
|
dispatch_actions(
|
||||||
|
ActionKey::new(
|
||||||
|
TypeId::of::<Self>(),
|
||||||
|
None,
|
||||||
|
Some(TypeId::of::<C>()),
|
||||||
|
component.id(),
|
||||||
|
),
|
||||||
|action: &Self| (action.f)(component, cx),
|
|action: &Self| (action.f)(component, cx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
pub type FnActionPage = fn(page: &mut Page);
|
|
||||||
|
|
||||||
mod before_prepare_body;
|
mod before_prepare_body;
|
||||||
pub use before_prepare_body::*;
|
pub use before_prepare_body::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use super::FnActionPage;
|
pub type FnAfterPrepareBody = fn(page: &mut Page);
|
||||||
|
|
||||||
pub struct AfterPrepareBody {
|
pub struct AfterPrepareBody {
|
||||||
f: FnActionPage,
|
f: FnAfterPrepareBody,
|
||||||
weight: Weight,
|
weight: Weight,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl ActionTrait for AfterPrepareBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AfterPrepareBody {
|
impl AfterPrepareBody {
|
||||||
pub fn new(f: FnActionPage) -> Self {
|
pub fn new(f: FnAfterPrepareBody) -> Self {
|
||||||
AfterPrepareBody { f, weight: 0 }
|
AfterPrepareBody { f, weight: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,8 +25,9 @@ impl AfterPrepareBody {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn dispatch(page: &mut Page) {
|
pub(crate) fn dispatch(page: &mut Page) {
|
||||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action: &Self| {
|
dispatch_actions(
|
||||||
(action.f)(page)
|
ActionKey::new(TypeId::of::<Self>(), None, None, None),
|
||||||
});
|
|action: &Self| (action.f)(page),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use super::FnActionPage;
|
pub type FnBeforePrepareBody = fn(page: &mut Page);
|
||||||
|
|
||||||
pub struct BeforePrepareBody {
|
pub struct BeforePrepareBody {
|
||||||
f: FnActionPage,
|
f: FnBeforePrepareBody,
|
||||||
weight: Weight,
|
weight: Weight,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl ActionTrait for BeforePrepareBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BeforePrepareBody {
|
impl BeforePrepareBody {
|
||||||
pub fn new(f: FnActionPage) -> Self {
|
pub fn new(f: FnBeforePrepareBody) -> Self {
|
||||||
BeforePrepareBody { f, weight: 0 }
|
BeforePrepareBody { f, weight: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,8 +25,9 @@ impl BeforePrepareBody {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn dispatch(page: &mut Page) {
|
pub(crate) fn dispatch(page: &mut Page) {
|
||||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action: &Self| {
|
dispatch_actions(
|
||||||
(action.f)(page)
|
ActionKey::new(TypeId::of::<Self>(), None, None, None),
|
||||||
});
|
|action: &Self| (action.f)(page),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
src/base/action/theme.rs
Normal file
8
src/base/action/theme.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
mod before_prepare_component;
|
||||||
|
pub use before_prepare_component::*;
|
||||||
|
|
||||||
|
mod after_prepare_component;
|
||||||
|
pub use after_prepare_component::*;
|
||||||
|
|
||||||
|
mod render_component;
|
||||||
|
pub use render_component::*;
|
||||||
42
src/base/action/theme/after_prepare_component.rs
Normal file
42
src/base/action/theme/after_prepare_component.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
use crate::base::action::FnActionWithComponent;
|
||||||
|
|
||||||
|
pub struct AfterPrepare<C: ComponentTrait> {
|
||||||
|
f: FnActionWithComponent<C>,
|
||||||
|
theme_type_id: Option<TypeId>,
|
||||||
|
referer_type_id: Option<TypeId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> ActionTrait for AfterPrepare<C> {
|
||||||
|
fn theme_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.theme_type_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.referer_type_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> AfterPrepare<C> {
|
||||||
|
pub fn new(theme: ThemeRef, f: FnActionWithComponent<C>) -> Self {
|
||||||
|
AfterPrepare {
|
||||||
|
f,
|
||||||
|
theme_type_id: Some(theme.type_id()),
|
||||||
|
referer_type_id: Some(TypeId::of::<C>()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn dispatch(component: &mut C, cx: &mut Context) {
|
||||||
|
dispatch_actions(
|
||||||
|
ActionKey::new(
|
||||||
|
TypeId::of::<Self>(),
|
||||||
|
Some(cx.theme().type_id()),
|
||||||
|
Some(TypeId::of::<C>()),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
|action: &Self| (action.f)(component, cx),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/base/action/theme/before_prepare_component.rs
Normal file
42
src/base/action/theme/before_prepare_component.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
use crate::base::action::FnActionWithComponent;
|
||||||
|
|
||||||
|
pub struct BeforePrepare<C: ComponentTrait> {
|
||||||
|
f: FnActionWithComponent<C>,
|
||||||
|
theme_type_id: Option<TypeId>,
|
||||||
|
referer_type_id: Option<TypeId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> ActionTrait for BeforePrepare<C> {
|
||||||
|
fn theme_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.theme_type_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.referer_type_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> BeforePrepare<C> {
|
||||||
|
pub fn new(theme: ThemeRef, f: FnActionWithComponent<C>) -> Self {
|
||||||
|
BeforePrepare {
|
||||||
|
f,
|
||||||
|
theme_type_id: Some(theme.type_id()),
|
||||||
|
referer_type_id: Some(TypeId::of::<C>()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn dispatch(component: &mut C, cx: &mut Context) {
|
||||||
|
dispatch_actions(
|
||||||
|
ActionKey::new(
|
||||||
|
TypeId::of::<Self>(),
|
||||||
|
Some(cx.theme().type_id()),
|
||||||
|
Some(TypeId::of::<C>()),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
|action: &Self| (action.f)(component, cx),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/base/action/theme/render_component.rs
Normal file
48
src/base/action/theme/render_component.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
pub type FnRenderComponent<C> = fn(component: &C, cx: &mut Context) -> Option<Markup>;
|
||||||
|
|
||||||
|
pub struct RenderComponent<C: ComponentTrait> {
|
||||||
|
f: FnRenderComponent<C>,
|
||||||
|
theme_type_id: Option<TypeId>,
|
||||||
|
referer_type_id: Option<TypeId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> ActionTrait for RenderComponent<C> {
|
||||||
|
fn theme_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.theme_type_id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
|
self.referer_type_id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: ComponentTrait> RenderComponent<C> {
|
||||||
|
pub fn new(theme: ThemeRef, f: FnRenderComponent<C>) -> Self {
|
||||||
|
RenderComponent {
|
||||||
|
f,
|
||||||
|
theme_type_id: Some(theme.type_id()),
|
||||||
|
referer_type_id: Some(TypeId::of::<C>()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn dispatch(component: &C, cx: &mut Context) -> Option<Markup> {
|
||||||
|
let mut render_component: Option<Markup> = None;
|
||||||
|
dispatch_actions(
|
||||||
|
ActionKey::new(
|
||||||
|
TypeId::of::<Self>(),
|
||||||
|
Some(cx.theme().type_id()),
|
||||||
|
Some(TypeId::of::<C>()),
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
|action: &Self| {
|
||||||
|
if render_component.is_none() {
|
||||||
|
render_component = (action.f)(component, cx);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
render_component
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
mod definition;
|
mod definition;
|
||||||
pub use definition::ActionTrait;
|
pub use definition::{ActionBase, ActionBox, ActionKey, ActionTrait};
|
||||||
|
|
||||||
mod list;
|
mod list;
|
||||||
pub use list::Action;
|
|
||||||
use list::ActionsList;
|
use list::ActionsList;
|
||||||
|
|
||||||
mod all;
|
mod all;
|
||||||
pub(crate) use all::add_action;
|
pub(crate) use all::add_action;
|
||||||
pub use all::{dispatch_actions, KeyAction};
|
pub use all::dispatch_actions;
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! actions {
|
||||||
|
() => {
|
||||||
|
Vec::<ActionBox>::new()
|
||||||
|
};
|
||||||
|
( $($action:expr),+ $(,)? ) => {{
|
||||||
|
vec![$(Box::new($action),)+]
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,31 @@
|
||||||
use crate::core::action::{Action, ActionTrait, ActionsList};
|
use crate::core::action::{ActionBox, ActionKey, ActionTrait, ActionsList};
|
||||||
use crate::{LazyStatic, TypeId};
|
use crate::LazyStatic;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
pub type KeyAction = (TypeId, Option<TypeId>, Option<String>);
|
|
||||||
|
|
||||||
// Registered actions.
|
// Registered actions.
|
||||||
static ACTIONS: LazyStatic<RwLock<HashMap<KeyAction, ActionsList>>> =
|
static ACTIONS: LazyStatic<RwLock<HashMap<ActionKey, ActionsList>>> =
|
||||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
pub fn add_action(action: Action) {
|
pub fn add_action(action: ActionBox) {
|
||||||
|
let key = action.key();
|
||||||
let mut actions = ACTIONS.write().unwrap();
|
let mut actions = ACTIONS.write().unwrap();
|
||||||
let key_action = (
|
if let Some(list) = actions.get_mut(&key) {
|
||||||
action.type_id(),
|
|
||||||
action.referer_type_id(),
|
|
||||||
action.referer_id(),
|
|
||||||
);
|
|
||||||
if let Some(list) = actions.get_mut(&key_action) {
|
|
||||||
list.add(action);
|
list.add(action);
|
||||||
} else {
|
} else {
|
||||||
actions.insert(key_action, ActionsList::new(action));
|
let mut list = ActionsList::new();
|
||||||
|
list.add(action);
|
||||||
|
actions.insert(key, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_actions<A, B, F>(key_action: KeyAction, f: F)
|
pub fn dispatch_actions<A, B, F>(key: ActionKey, f: F)
|
||||||
where
|
where
|
||||||
A: ActionTrait,
|
A: ActionTrait,
|
||||||
F: FnMut(&A) -> B,
|
F: FnMut(&A) -> B,
|
||||||
{
|
{
|
||||||
if let Some(list) = ACTIONS.read().unwrap().get(&key_action) {
|
if let Some(list) = ACTIONS.read().unwrap().get(&key) {
|
||||||
list.iter_map(f)
|
list.iter_map(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,41 @@
|
||||||
use crate::core::AnyBase;
|
use crate::core::AnyBase;
|
||||||
use crate::{TypeId, Weight};
|
use crate::{TypeId, Weight};
|
||||||
|
|
||||||
pub trait ActionTrait: AnyBase + Send + Sync {
|
pub type ActionBox = Box<dyn ActionTrait>;
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Hash)]
|
||||||
|
pub struct ActionKey {
|
||||||
|
action_type_id: TypeId,
|
||||||
|
theme_type_id: Option<TypeId>,
|
||||||
|
referer_type_id: Option<TypeId>,
|
||||||
|
referer_id: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActionKey {
|
||||||
|
pub fn new(
|
||||||
|
action_type_id: TypeId,
|
||||||
|
theme_type_id: Option<TypeId>,
|
||||||
|
referer_type_id: Option<TypeId>,
|
||||||
|
referer_id: Option<String>,
|
||||||
|
) -> Self {
|
||||||
|
ActionKey {
|
||||||
|
action_type_id,
|
||||||
|
theme_type_id,
|
||||||
|
referer_type_id,
|
||||||
|
referer_id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ActionBase {
|
||||||
|
fn key(&self) -> ActionKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait ActionTrait: ActionBase + AnyBase + Send + Sync {
|
||||||
|
fn theme_type_id(&self) -> Option<TypeId> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
fn referer_type_id(&self) -> Option<TypeId> {
|
fn referer_type_id(&self) -> Option<TypeId> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
@ -14,3 +48,14 @@ pub trait ActionTrait: AnyBase + Send + Sync {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A: ActionTrait> ActionBase for A {
|
||||||
|
fn key(&self) -> ActionKey {
|
||||||
|
ActionKey {
|
||||||
|
action_type_id: self.type_id(),
|
||||||
|
theme_type_id: self.theme_type_id(),
|
||||||
|
referer_type_id: self.referer_type_id(),
|
||||||
|
referer_id: self.referer_id(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,19 @@
|
||||||
use crate::core::action::ActionTrait;
|
use crate::core::action::{ActionBox, ActionTrait};
|
||||||
use crate::core::AnyTo;
|
use crate::core::AnyTo;
|
||||||
use crate::trace;
|
use crate::trace;
|
||||||
use crate::AutoDefault;
|
use crate::AutoDefault;
|
||||||
|
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::RwLock;
|
||||||
|
|
||||||
pub type Action = Box<dyn ActionTrait>;
|
|
||||||
|
|
||||||
#[derive(AutoDefault)]
|
#[derive(AutoDefault)]
|
||||||
pub struct ActionsList(Arc<RwLock<Vec<Action>>>);
|
pub struct ActionsList(RwLock<Vec<ActionBox>>);
|
||||||
|
|
||||||
impl ActionsList {
|
impl ActionsList {
|
||||||
pub fn new(action: Action) -> Self {
|
pub fn new() -> Self {
|
||||||
let mut list = ActionsList::default();
|
ActionsList::default()
|
||||||
list.add(action);
|
|
||||||
list
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&mut self, action: Action) {
|
pub fn add(&mut self, action: ActionBox) {
|
||||||
let mut list = self.0.write().unwrap();
|
let mut list = self.0.write().unwrap();
|
||||||
list.push(action);
|
list.push(action);
|
||||||
list.sort_by_key(|a| a.weight());
|
list.sort_by_key(|a| a.weight());
|
||||||
|
|
@ -35,26 +31,12 @@ impl ActionsList {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|a| {
|
.map(|a| {
|
||||||
if let Some(action) = (&**a).downcast_ref::<A>() {
|
if let Some(action) = (**a).downcast_ref::<A>() {
|
||||||
f(action);
|
f(action);
|
||||||
} else {
|
} else {
|
||||||
trace::error!("Failed to downcast action of type {}", (&**a).type_name());
|
trace::error!("Failed to downcast action of type {}", (**a).type_name());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! actions {
|
|
||||||
() => {
|
|
||||||
Vec::<Action>::new()
|
|
||||||
};
|
|
||||||
( $($action:expr),+ $(,)? ) => {{
|
|
||||||
let mut v = Vec::<Action>::new();
|
|
||||||
$(
|
|
||||||
v.push(Box::new($action));
|
|
||||||
)*
|
|
||||||
v
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -50,16 +50,14 @@ impl<C: ComponentTrait> ComponentBase for C {
|
||||||
self.setup_before_prepare(cx);
|
self.setup_before_prepare(cx);
|
||||||
|
|
||||||
// Acciones del tema antes de preparar el componente.
|
// Acciones del tema antes de preparar el componente.
|
||||||
cx.theme().before_prepare_component(self, cx);
|
action::theme::BeforePrepare::dispatch(self, cx);
|
||||||
|
|
||||||
// Acciones de los módulos antes de preparar el componente.
|
// Acciones de los módulos antes de preparar el componente.
|
||||||
action::component::BeforePrepareComponent::dispatch(self, cx, None);
|
action::component::BeforePrepare::dispatch(self, cx);
|
||||||
if let Some(id) = self.id() {
|
action::component::BeforePrepare::dispatch_by_id(self, cx);
|
||||||
action::component::BeforePrepareComponent::dispatch(self, cx, Some(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Renderiza el componente.
|
// Renderiza el componente.
|
||||||
let markup = match cx.theme().render_component(self, cx) {
|
let markup = match action::theme::RenderComponent::dispatch(self, cx) {
|
||||||
Some(html) => html,
|
Some(html) => html,
|
||||||
None => match self.prepare_component(cx) {
|
None => match self.prepare_component(cx) {
|
||||||
PrepareMarkup::None => html! {},
|
PrepareMarkup::None => html! {},
|
||||||
|
|
@ -69,13 +67,11 @@ impl<C: ComponentTrait> ComponentBase for C {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Acciones del tema después de preparar el componente.
|
// Acciones del tema después de preparar el componente.
|
||||||
cx.theme().after_prepare_component(self, cx);
|
action::theme::AfterPrepare::dispatch(self, cx);
|
||||||
|
|
||||||
// Acciones de los módulos después de preparar el componente.
|
// Acciones de los módulos después de preparar el componente.
|
||||||
action::component::AfterPrepareComponent::dispatch(self, cx, None);
|
action::component::AfterPrepare::dispatch(self, cx);
|
||||||
if let Some(id) = self.id() {
|
action::component::AfterPrepare::dispatch_by_id(self, cx);
|
||||||
action::component::AfterPrepareComponent::dispatch(self, cx, Some(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
markup
|
markup
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::core::action::Action;
|
use crate::core::action::ActionBox;
|
||||||
use crate::core::theme::ThemeRef;
|
use crate::core::theme::ThemeRef;
|
||||||
use crate::core::AnyBase;
|
use crate::core::AnyBase;
|
||||||
use crate::locale::L10n;
|
use crate::locale::L10n;
|
||||||
|
|
@ -31,7 +31,7 @@ pub trait PackageTrait: AnyBase + Send + Sync {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actions(&self) -> Vec<Action> {
|
fn actions(&self) -> Vec<ActionBox> {
|
||||||
actions![]
|
actions![]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::base::component::Layout;
|
use crate::base::component::Layout;
|
||||||
use crate::core::component::{ComponentBase, ComponentTrait, Context};
|
use crate::core::component::{ComponentBase, ComponentTrait};
|
||||||
use crate::core::package::PackageTrait;
|
use crate::core::package::PackageTrait;
|
||||||
use crate::html::{html, Favicon, Markup};
|
use crate::html::{html, Favicon, Markup};
|
||||||
use crate::locale::L10n;
|
use crate::locale::L10n;
|
||||||
|
|
@ -26,13 +26,13 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
||||||
fn before_prepare_body(&self, page: &mut Page) {}
|
fn before_prepare_body(&self, page: &mut Page) {}
|
||||||
|
|
||||||
fn prepare_body(&self, page: &mut Page) -> Markup {
|
fn prepare_body(&self, page: &mut Page) -> Markup {
|
||||||
let skip_to = concat_string!("#", page.skip_to().get().unwrap_or("content".to_owned()));
|
let skip_to_id = concat_string!("#", page.skip_to().get().unwrap_or("content".to_owned()));
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||||
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
||||||
div class="skip__to_content" {
|
div class="skip__to_content" {
|
||||||
a href=(skip_to) { (skip) }
|
a href=(skip_to_id) { (skip) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Layout::new().render(page.context()))
|
(Layout::new().render(page.context()))
|
||||||
|
|
@ -80,66 +80,4 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn before_prepare_component(
|
|
||||||
&self,
|
|
||||||
component: &mut dyn ComponentTrait,
|
|
||||||
cx: &mut Context,
|
|
||||||
) {
|
|
||||||
/*
|
|
||||||
Cómo usarlo:
|
|
||||||
|
|
||||||
match component.type_id() {
|
|
||||||
t if t == TypeId::of::<Block>() => {
|
|
||||||
if let Some(b) = component.downcast_mut::<Block>() {
|
|
||||||
b.alter_title("New title");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn after_prepare_component(
|
|
||||||
&self,
|
|
||||||
component: &mut dyn ComponentTrait,
|
|
||||||
cx: &mut Context,
|
|
||||||
) {
|
|
||||||
/*
|
|
||||||
Cómo usarlo:
|
|
||||||
|
|
||||||
match component.type_id() {
|
|
||||||
t if t == TypeId::of::<Block>() => {
|
|
||||||
if let Some(b) = component.downcast_mut::<Block>() {
|
|
||||||
b.alter_title("New title");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn render_component(
|
|
||||||
&self,
|
|
||||||
component: &dyn ComponentTrait,
|
|
||||||
cx: &mut Context,
|
|
||||||
) -> Option<Markup> {
|
|
||||||
None
|
|
||||||
/*
|
|
||||||
Cómo usarlo:
|
|
||||||
|
|
||||||
match component.type_id() {
|
|
||||||
t if t == TypeId::of::<Block>() => {
|
|
||||||
Some(block_default(block))
|
|
||||||
},
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ impl Page {
|
||||||
// Page RENDER.
|
// Page RENDER.
|
||||||
|
|
||||||
pub fn render(&mut self) -> ResultPage<Markup, ErrorPage> {
|
pub fn render(&mut self) -> ResultPage<Markup, ErrorPage> {
|
||||||
// Theme actions before preparing the page body.
|
// Theme operations before preparing the page body.
|
||||||
self.context.theme().before_prepare_body(self);
|
self.context.theme().before_prepare_body(self);
|
||||||
|
|
||||||
// Packages actions before preparing the page body.
|
// Packages actions before preparing the page body.
|
||||||
|
|
@ -177,7 +177,7 @@ impl Page {
|
||||||
// Prepare page body.
|
// Prepare page body.
|
||||||
let body = self.context.theme().prepare_body(self);
|
let body = self.context.theme().prepare_body(self);
|
||||||
|
|
||||||
// Theme actions after preparing the page body.
|
// Theme operations after preparing the page body.
|
||||||
self.context.theme().after_prepare_body(self);
|
self.context.theme().after_prepare_body(self);
|
||||||
|
|
||||||
// Packages actions after preparing the page body.
|
// Packages actions after preparing the page body.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue