💥 Major Handle's improvement
This commit is contained in:
parent
c3c5e46508
commit
5b8c249785
34 changed files with 114 additions and 263 deletions
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_BLOCK);
|
|
||||||
|
|
||||||
actions_for_component!(Block);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
|
|
@ -16,15 +12,13 @@ pub struct Block {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_BLOCK for Block);
|
||||||
|
|
||||||
impl ComponentTrait for Block {
|
impl ComponentTrait for Block {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Block::default().with_classes(ClassesOp::Add, "block")
|
Block::default().with_classes(ClassesOp::Add, "block")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_BLOCK
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -37,10 +31,6 @@ impl ComponentTrait for Block {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_block(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
let id = cx.required_id::<Block>(self.id());
|
let id = cx.required_id::<Block>(self.id());
|
||||||
PrepareMarkup::With(html! {
|
PrepareMarkup::With(html! {
|
||||||
|
|
@ -54,10 +44,6 @@ impl ComponentTrait for Block {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_block(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Block {
|
impl Block {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_BRANDING);
|
|
||||||
|
|
||||||
type SiteLogo = TypedComponent<Image>;
|
type SiteLogo = TypedComponent<Image>;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
@ -28,15 +26,13 @@ impl Default for Branding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_BRANDING for Branding);
|
||||||
|
|
||||||
impl ComponentTrait for Branding {
|
impl ComponentTrait for Branding {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Branding::default()
|
Branding::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_BRANDING
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
Some("pt-branding".to_owned())
|
Some("pt-branding".to_owned())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_FLEX_CONTAINER);
|
|
||||||
|
|
||||||
actions_for_component!(Container);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
|
|
@ -19,15 +15,13 @@ pub struct Container {
|
||||||
gap : flex::Gap,
|
gap : flex::Gap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_FLEX_CONTAINER for Container);
|
||||||
|
|
||||||
impl ComponentTrait for Container {
|
impl ComponentTrait for Container {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Container::default().with_classes(ClassesOp::Add, flex::Direction::Default.to_string())
|
Container::default().with_classes(ClassesOp::Add, flex::Direction::Default.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_FLEX_CONTAINER
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -40,10 +34,6 @@ impl ComponentTrait for Container {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_container(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
cx.set_param::<bool>(PARAM_BASE_INCLUDE_FLEX_ASSETS, true);
|
cx.set_param::<bool>(PARAM_BASE_INCLUDE_FLEX_ASSETS, true);
|
||||||
|
|
||||||
|
|
@ -58,10 +48,6 @@ impl ComponentTrait for Container {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_container(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Container {
|
impl Container {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_FLEX_ITEM);
|
|
||||||
|
|
||||||
actions_for_component!(Item);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Item {
|
pub struct Item {
|
||||||
|
|
@ -20,6 +16,8 @@ pub struct Item {
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_FLEX_ITEM for Item);
|
||||||
|
|
||||||
impl ComponentTrait for Item {
|
impl ComponentTrait for Item {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Item::default()
|
Item::default()
|
||||||
|
|
@ -27,10 +25,6 @@ impl ComponentTrait for Item {
|
||||||
.with_inner_classes(ClassesOp::Add, "pt-flex__item-inner")
|
.with_inner_classes(ClassesOp::Add, "pt-flex__item-inner")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_FLEX_ITEM
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -43,10 +37,6 @@ impl ComponentTrait for Item {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_item(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
let order = match self.weight() {
|
let order = match self.weight() {
|
||||||
0 => None,
|
0 => None,
|
||||||
|
|
@ -60,10 +50,6 @@ impl ComponentTrait for Item {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_item(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Item {
|
impl Item {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_BUTTON);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum ButtonType {
|
pub enum ButtonType {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -24,15 +22,13 @@ pub struct Button {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_BUTTON for Button);
|
||||||
|
|
||||||
impl ComponentTrait for Button {
|
impl ComponentTrait for Button {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Button::default().with_classes(ClassesOp::Add, "btn btn-primary form-button")
|
Button::default().with_classes(ClassesOp::Add, "btn btn-primary form-button")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_BUTTON
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_DATE);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Date {
|
pub struct Date {
|
||||||
|
|
@ -21,15 +19,13 @@ pub struct Date {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_DATE for Date);
|
||||||
|
|
||||||
impl ComponentTrait for Date {
|
impl ComponentTrait for Date {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Date::default().with_classes(ClassesOp::Add, "form-item form-type-date")
|
Date::default().with_classes(ClassesOp::Add, "form-item form-type-date")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_DATE
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_FORM);
|
|
||||||
|
|
||||||
actions_for_component!(Form);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum FormMethod {
|
pub enum FormMethod {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -25,6 +21,8 @@ pub struct Form {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_FORM for Form);
|
||||||
|
|
||||||
impl ComponentTrait for Form {
|
impl ComponentTrait for Form {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Form::default()
|
Form::default()
|
||||||
|
|
@ -32,10 +30,6 @@ impl ComponentTrait for Form {
|
||||||
.with_charset("UTF-8")
|
.with_charset("UTF-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_FORM
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -48,10 +42,6 @@ impl ComponentTrait for Form {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_form(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
let method = match self.method() {
|
let method = match self.method() {
|
||||||
FormMethod::Post => Some("post".to_owned()),
|
FormMethod::Post => Some("post".to_owned()),
|
||||||
|
|
@ -69,10 +59,6 @@ impl ComponentTrait for Form {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_form(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Form {
|
impl Form {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_HIDDEN);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Hidden {
|
pub struct Hidden {
|
||||||
|
|
@ -10,15 +8,13 @@ pub struct Hidden {
|
||||||
value : OptionString,
|
value : OptionString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_HIDDEN for Hidden);
|
||||||
|
|
||||||
impl ComponentTrait for Hidden {
|
impl ComponentTrait for Hidden {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Hidden::default()
|
Hidden::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_HIDDEN
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_INPUT);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum InputType {
|
pub enum InputType {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -36,6 +34,8 @@ pub struct Input {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_INPUT for Input);
|
||||||
|
|
||||||
impl ComponentTrait for Input {
|
impl ComponentTrait for Input {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Input::default()
|
Input::default()
|
||||||
|
|
@ -44,10 +44,6 @@ impl ComponentTrait for Input {
|
||||||
.with_maxlength(Some(128))
|
.with_maxlength(Some(128))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_INPUT
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_HEADING);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum HeadingType {
|
pub enum HeadingType {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -52,15 +50,13 @@ pub struct Heading {
|
||||||
display : HeadingDisplay,
|
display : HeadingDisplay,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_HEADING for Heading);
|
||||||
|
|
||||||
impl ComponentTrait for Heading {
|
impl ComponentTrait for Heading {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Heading::default()
|
Heading::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_HEADING
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_HTML);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Html(Markup);
|
pub struct Html(Markup);
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_HTML for Html);
|
||||||
|
|
||||||
impl ComponentTrait for Html {
|
impl ComponentTrait for Html {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Html::default()
|
Html::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_HTML
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
||||||
PrepareMarkup::With(html! { (self.html()) })
|
PrepareMarkup::With(html! { (self.html()) })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_ICON);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Icon {
|
pub struct Icon {
|
||||||
|
|
@ -12,15 +10,13 @@ pub struct Icon {
|
||||||
icon_name : String,
|
icon_name : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_ICON for Icon);
|
||||||
|
|
||||||
impl ComponentTrait for Icon {
|
impl ComponentTrait for Icon {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Icon::default()
|
Icon::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_ICON
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_IMAGE);
|
|
||||||
|
|
||||||
const IMG_FLUID: &str = "pt-img__fluid";
|
const IMG_FLUID: &str = "pt-img__fluid";
|
||||||
const IMG_FIXED: &str = "pt-img__fixed";
|
const IMG_FIXED: &str = "pt-img__fixed";
|
||||||
|
|
||||||
|
|
@ -26,15 +24,13 @@ pub struct Image {
|
||||||
size : ImageSize,
|
size : ImageSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_IMAGE for Image);
|
||||||
|
|
||||||
impl ComponentTrait for Image {
|
impl ComponentTrait for Image {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Image::default().with_classes(ClassesOp::Add, IMG_FLUID)
|
Image::default().with_classes(ClassesOp::Add, IMG_FLUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_IMAGE
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::Submenu;
|
use super::Submenu;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU_ELEMENT);
|
|
||||||
|
|
||||||
type Content = TypedComponent<Html>;
|
type Content = TypedComponent<Html>;
|
||||||
type SubmenuItems = TypedComponent<Submenu>;
|
type SubmenuItems = TypedComponent<Submenu>;
|
||||||
|
|
||||||
|
|
@ -25,15 +23,13 @@ pub struct Element {
|
||||||
element_type: ElementType,
|
element_type: ElementType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU_ELEMENT for Element);
|
||||||
|
|
||||||
impl ComponentTrait for Element {
|
impl ComponentTrait for Element {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Element::default()
|
Element::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU_ELEMENT
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::Element;
|
use super::Element;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU_GROUP);
|
|
||||||
|
|
||||||
type Elements = TypedComponents<Element>;
|
type Elements = TypedComponents<Element>;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
@ -15,15 +13,13 @@ pub struct Group {
|
||||||
elements : Elements,
|
elements : Elements,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU_GROUP for Group);
|
||||||
|
|
||||||
impl ComponentTrait for Group {
|
impl ComponentTrait for Group {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Group::default()
|
Group::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU_GROUP
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::{Megamenu, Submenu};
|
use super::{Megamenu, Submenu};
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU_ITEM);
|
|
||||||
|
|
||||||
type Label = L10n;
|
type Label = L10n;
|
||||||
type Content = TypedComponent<Html>;
|
type Content = TypedComponent<Html>;
|
||||||
type SubmenuItems = TypedComponent<Submenu>;
|
type SubmenuItems = TypedComponent<Submenu>;
|
||||||
|
|
@ -32,15 +30,13 @@ pub struct Item {
|
||||||
description: OptionTranslated,
|
description: OptionTranslated,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU_ITEM for Item);
|
||||||
|
|
||||||
impl ComponentTrait for Item {
|
impl ComponentTrait for Item {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Item::default()
|
Item::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU_ITEM
|
|
||||||
}
|
|
||||||
|
|
||||||
fn weight(&self) -> Weight {
|
fn weight(&self) -> Weight {
|
||||||
self.weight
|
self.weight
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::Group;
|
use super::Group;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU_MEGAMENU);
|
|
||||||
|
|
||||||
type Groups = TypedComponents<Group>;
|
type Groups = TypedComponents<Group>;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
@ -15,15 +13,13 @@ pub struct Megamenu {
|
||||||
groups : Groups,
|
groups : Groups,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU_MEGAMENU for Megamenu);
|
||||||
|
|
||||||
impl ComponentTrait for Megamenu {
|
impl ComponentTrait for Megamenu {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Megamenu::default()
|
Megamenu::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU_MEGAMENU
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::Item;
|
use super::Item;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU);
|
|
||||||
|
|
||||||
actions_for_component!(Menu);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Menu {
|
pub struct Menu {
|
||||||
|
|
@ -15,15 +11,13 @@ pub struct Menu {
|
||||||
items : TypedComponents<Item>,
|
items : TypedComponents<Item>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU for Menu);
|
||||||
|
|
||||||
impl ComponentTrait for Menu {
|
impl ComponentTrait for Menu {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Menu::default()
|
Menu::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -36,10 +30,6 @@ impl ComponentTrait for Menu {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_menu(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
cx.set_param::<bool>(PARAM_BASE_INCLUDE_MENU_ASSETS, true);
|
cx.set_param::<bool>(PARAM_BASE_INCLUDE_MENU_ASSETS, true);
|
||||||
cx.set_param::<bool>(PARAM_BASE_INCLUDE_ICONS, true);
|
cx.set_param::<bool>(PARAM_BASE_INCLUDE_ICONS, true);
|
||||||
|
|
@ -75,10 +65,6 @@ impl ComponentTrait for Menu {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_menu(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Menu {
|
impl Menu {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use super::Item;
|
use super::Item;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_MENU_SUBMENU);
|
|
||||||
|
|
||||||
type Items = TypedComponents<Item>;
|
type Items = TypedComponents<Item>;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|
@ -16,15 +14,13 @@ pub struct Submenu {
|
||||||
items : Items,
|
items : Items,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_MENU_SUBMENU for Submenu);
|
||||||
|
|
||||||
impl ComponentTrait for Submenu {
|
impl ComponentTrait for Submenu {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Submenu::default()
|
Submenu::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_MENU_SUBMENU
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_PARAGRAPH);
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Paragraph {
|
pub struct Paragraph {
|
||||||
|
|
@ -13,15 +11,13 @@ pub struct Paragraph {
|
||||||
stuff : ArcComponents,
|
stuff : ArcComponents,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_PARAGRAPH for Paragraph);
|
||||||
|
|
||||||
impl ComponentTrait for Paragraph {
|
impl ComponentTrait for Paragraph {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Paragraph::default()
|
Paragraph::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_PARAGRAPH
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_POWEREDBY);
|
|
||||||
|
|
||||||
#[derive(Default, Eq, PartialEq)]
|
#[derive(Default, Eq, PartialEq)]
|
||||||
pub enum PoweredByLogo {
|
pub enum PoweredByLogo {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -21,6 +19,8 @@ pub struct PoweredBy {
|
||||||
logo : PoweredByLogo,
|
logo : PoweredByLogo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_POWEREDBY for PoweredBy);
|
||||||
|
|
||||||
impl ComponentTrait for PoweredBy {
|
impl ComponentTrait for PoweredBy {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
let year = Utc::now().format("%Y").to_string();
|
let year = Utc::now().format("%Y").to_string();
|
||||||
|
|
@ -31,10 +31,6 @@ impl ComponentTrait for PoweredBy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_POWEREDBY
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
Some("pt-poweredby".to_owned())
|
Some("pt-poweredby".to_owned())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_TRANSLATE);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Translate(L10n);
|
pub struct Translate(L10n);
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_TRANSLATE for Translate);
|
||||||
|
|
||||||
impl ComponentTrait for Translate {
|
impl ComponentTrait for Translate {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Translate::default()
|
Translate::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_TRANSLATE
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
PrepareMarkup::With(self.l10n().escaped(cx.langid()))
|
PrepareMarkup::With(self.l10n().escaped(cx.langid()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(COMPONENT_BASE_WRAPPER);
|
|
||||||
|
|
||||||
actions_for_component!(Wrapper);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum WrapperType {
|
pub enum WrapperType {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -27,6 +23,8 @@ pub struct Wrapper {
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_BASE_WRAPPER for Wrapper);
|
||||||
|
|
||||||
impl ComponentTrait for Wrapper {
|
impl ComponentTrait for Wrapper {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Wrapper::default()
|
Wrapper::default()
|
||||||
|
|
@ -34,10 +32,6 @@ impl ComponentTrait for Wrapper {
|
||||||
.with_inner_classes(ClassesOp::Add, "container")
|
.with_inner_classes(ClassesOp::Add, "container")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_BASE_WRAPPER
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self) -> Option<String> {
|
fn id(&self) -> Option<String> {
|
||||||
self.id.get()
|
self.id.get()
|
||||||
}
|
}
|
||||||
|
|
@ -50,10 +44,6 @@ impl ComponentTrait for Wrapper {
|
||||||
(self.renderable.check)(cx)
|
(self.renderable.check)(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_before_prepare_wrapper(self, cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
|
||||||
match self.wrapper_type() {
|
match self.wrapper_type() {
|
||||||
WrapperType::Header => PrepareMarkup::With(html! {
|
WrapperType::Header => PrepareMarkup::With(html! {
|
||||||
|
|
@ -91,10 +81,6 @@ impl ComponentTrait for Wrapper {
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_prepare_component(&mut self, cx: &mut Context) {
|
|
||||||
run_actions_after_prepare_wrapper(self, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Wrapper {
|
impl Wrapper {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(THEME_BASIC);
|
|
||||||
|
|
||||||
pub struct Basic;
|
pub struct Basic;
|
||||||
|
|
||||||
impl ModuleTrait for Basic {
|
impl_handle!(THEME_BASIC for Basic);
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
THEME_BASIC
|
|
||||||
}
|
|
||||||
|
|
||||||
|
impl ModuleTrait for Basic {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> L10n {
|
||||||
L10n::n("Basic")
|
L10n::n("Basic")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(THEME_CHASSIS);
|
|
||||||
|
|
||||||
pub struct Chassis;
|
pub struct Chassis;
|
||||||
|
|
||||||
impl ModuleTrait for Chassis {
|
impl_handle!(THEME_CHASSIS for Chassis);
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
THEME_CHASSIS
|
|
||||||
}
|
|
||||||
|
|
||||||
|
impl ModuleTrait for Chassis {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> L10n {
|
||||||
L10n::n("Chassis")
|
L10n::n("Chassis")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
new_handle!(THEME_INCEPTION);
|
|
||||||
|
|
||||||
pub struct Inception;
|
pub struct Inception;
|
||||||
|
|
||||||
impl ModuleTrait for Inception {
|
impl_handle!(THEME_INCEPTION for Inception);
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
THEME_INCEPTION
|
|
||||||
}
|
|
||||||
|
|
||||||
|
impl ModuleTrait for Inception {
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> L10n {
|
||||||
L10n::n("Inception")
|
L10n::n("Inception")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,18 @@
|
||||||
use crate::core::component::{ComponentTrait, Context};
|
use crate::core::component::{ComponentTrait, Context};
|
||||||
use crate::html::{html, Markup};
|
use crate::html::{html, Markup};
|
||||||
use crate::{new_handle, Handle, Weight};
|
use crate::{impl_handle, Handle, Weight};
|
||||||
|
|
||||||
use std::sync::{Arc, RwLock, RwLockReadGuard};
|
use std::sync::{Arc, RwLock, RwLockReadGuard};
|
||||||
|
|
||||||
new_handle!(COMPONENT_NULL for Crate);
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ComponentNull;
|
struct ComponentNull;
|
||||||
|
|
||||||
|
impl_handle!(COMPONENT_NULL for ComponentNull);
|
||||||
|
|
||||||
impl ComponentTrait for ComponentNull {
|
impl ComponentTrait for ComponentNull {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
ComponentNull::default()
|
ComponentNull::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
COMPONENT_NULL
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::core::component::Context;
|
use crate::core::component::Context;
|
||||||
use crate::html::{html, Markup, PrepareMarkup};
|
use crate::html::{html, Markup, PrepareMarkup};
|
||||||
use crate::{util, Handle, Weight};
|
use crate::{util, HasHandle, Weight};
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
|
|
@ -12,13 +12,11 @@ pub trait ComponentBase: Any {
|
||||||
fn as_mut_any(&mut self) -> &mut dyn Any;
|
fn as_mut_any(&mut self) -> &mut dyn Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ComponentTrait: ComponentBase + Send + Sync {
|
pub trait ComponentTrait: ComponentBase + HasHandle + Send + Sync {
|
||||||
fn new() -> Self
|
fn new() -> Self
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
fn handle(&self) -> Handle;
|
|
||||||
|
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
util::single_type_name::<Self>().to_owned()
|
util::single_type_name::<Self>().to_owned()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::core::action::Action;
|
use crate::core::action::Action;
|
||||||
use crate::core::theme::ThemeRef;
|
use crate::core::theme::ThemeRef;
|
||||||
use crate::locale::L10n;
|
use crate::locale::L10n;
|
||||||
use crate::{actions, service, util, Handle};
|
use crate::{actions, service, util, HasHandle};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::{db::MigrationItem, migrations};
|
use crate::{db::MigrationItem, migrations};
|
||||||
|
|
@ -13,9 +13,7 @@ pub trait ModuleBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Los módulos deben implementar este *trait*.
|
/// Los módulos deben implementar este *trait*.
|
||||||
pub trait ModuleTrait: ModuleBase + Send + Sync {
|
pub trait ModuleTrait: HasHandle + ModuleBase + Send + Sync {
|
||||||
fn handle(&self) -> Handle;
|
|
||||||
|
|
||||||
fn name(&self) -> L10n {
|
fn name(&self) -> L10n {
|
||||||
L10n::n(self.single_name())
|
L10n::n(self.single_name())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use pagetop::prelude::*;
|
//! use pagetop::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! new_handle!(APP_HELLO_WORLD);
|
//! impl_handle!(APP_HELLO_WORLD for HelloWorld);
|
||||||
//!
|
//!
|
||||||
//! struct HelloWorld;
|
//! struct HelloWorld;
|
||||||
//!
|
//!
|
||||||
|
|
@ -119,6 +119,15 @@ pub use once_cell::sync::Lazy as LazyStatic;
|
||||||
pub use static_files::Resource as StaticResource;
|
pub use static_files::Resource as StaticResource;
|
||||||
|
|
||||||
pub type Handle = u64;
|
pub type Handle = u64;
|
||||||
|
|
||||||
|
pub trait HasHandle {
|
||||||
|
fn static_handle() -> Handle
|
||||||
|
where
|
||||||
|
Self: Sized;
|
||||||
|
|
||||||
|
fn handle(&self) -> Handle;
|
||||||
|
}
|
||||||
|
|
||||||
pub type Weight = i8;
|
pub type Weight = i8;
|
||||||
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ pub use crate::{Handle, HashMapResources, LazyStatic, Weight};
|
||||||
|
|
||||||
// Functions and macro helpers.
|
// Functions and macro helpers.
|
||||||
pub use crate::util;
|
pub use crate::util;
|
||||||
pub use crate::{kv, new_handle};
|
pub use crate::{impl_handle, kv};
|
||||||
|
|
||||||
// MACROS.
|
// MACROS.
|
||||||
|
|
||||||
|
|
@ -20,8 +20,6 @@ pub use crate::new_static_locales;
|
||||||
pub use crate::{new_static_files, service_for_static_files};
|
pub use crate::{new_static_files, service_for_static_files};
|
||||||
// crate::core::actions
|
// crate::core::actions
|
||||||
pub use crate::actions;
|
pub use crate::actions;
|
||||||
// crate::base::action::component
|
|
||||||
pub use crate::actions_for_component;
|
|
||||||
|
|
||||||
// API.
|
// API.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
use crate::core::component::{ComponentTrait, Context};
|
use crate::core::component::{ComponentTrait, Context};
|
||||||
use crate::html::{html, PrepareMarkup};
|
use crate::html::{html, PrepareMarkup};
|
||||||
use crate::{new_handle, Handle};
|
use crate::impl_handle;
|
||||||
|
|
||||||
new_handle!(ERROR_403);
|
|
||||||
|
|
||||||
pub struct Error403;
|
pub struct Error403;
|
||||||
|
|
||||||
|
impl_handle!(ERROR_403 for Error403);
|
||||||
|
|
||||||
impl ComponentTrait for Error403 {
|
impl ComponentTrait for Error403 {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
ERROR_403
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
||||||
PrepareMarkup::With(html! {
|
PrepareMarkup::With(html! {
|
||||||
div {
|
div {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
use crate::core::component::{ComponentTrait, Context};
|
use crate::core::component::{ComponentTrait, Context};
|
||||||
use crate::html::{html, PrepareMarkup};
|
use crate::html::{html, PrepareMarkup};
|
||||||
use crate::{new_handle, Handle};
|
use crate::impl_handle;
|
||||||
|
|
||||||
new_handle!(ERROR_404);
|
|
||||||
|
|
||||||
pub struct Error404;
|
pub struct Error404;
|
||||||
|
|
||||||
|
impl_handle!(ERROR_404 for Error404);
|
||||||
|
|
||||||
impl ComponentTrait for Error404 {
|
impl ComponentTrait for Error404 {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self) -> Handle {
|
|
||||||
ERROR_404
|
|
||||||
}
|
|
||||||
|
|
||||||
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
fn prepare_component(&self, _cx: &mut Context) -> PrepareMarkup {
|
||||||
PrepareMarkup::With(html! {
|
PrepareMarkup::With(html! {
|
||||||
div {
|
div {
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,44 @@ pub fn absolute_dir(
|
||||||
// MACRO HELPERS.
|
// MACRO HELPERS.
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! impl_handle {
|
||||||
|
( $HANDLE:ident for $Element:ident ) => {
|
||||||
|
/// Constant handle to represent a unique PageTop building element.
|
||||||
|
pub const $HANDLE: $crate::Handle =
|
||||||
|
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
||||||
|
|
||||||
|
impl $crate::HasHandle for $Element {
|
||||||
|
#[inline]
|
||||||
|
fn static_handle() -> $crate::Handle {
|
||||||
|
$HANDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn handle(&self) -> $crate::Handle {
|
||||||
|
$HANDLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
( $HANDLE:ident for $Element:ident<$Implement:ident> ) => {
|
||||||
|
/// Constant handle to represent a unique PageTop building element.
|
||||||
|
pub const $HANDLE: $crate::Handle =
|
||||||
|
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
||||||
|
|
||||||
|
impl<I: $Implement> $crate::HasHandle for $Element<I> {
|
||||||
|
#[inline]
|
||||||
|
fn static_handle() -> $crate::Handle {
|
||||||
|
$HANDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn handle(&self) -> $crate::Handle {
|
||||||
|
$HANDLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
/// Macro para construir grupos de pares clave-valor.
|
/// Macro para construir grupos de pares clave-valor.
|
||||||
///
|
///
|
||||||
|
|
@ -111,17 +149,3 @@ macro_rules! kv {
|
||||||
a
|
a
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! new_handle {
|
|
||||||
( $HANDLE:ident ) => {
|
|
||||||
/// Public constant handle to represent a unique PageTop building element.
|
|
||||||
pub const $HANDLE: $crate::Handle =
|
|
||||||
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
|
||||||
};
|
|
||||||
( $HANDLE:ident for Crate ) => {
|
|
||||||
/// Local constant handle to represent a unique PageTop building element.
|
|
||||||
pub(crate) const $HANDLE: $crate::Handle =
|
|
||||||
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue