🎨 Ahora son pub_handle!() y pub_locale!()
This commit is contained in:
parent
9c29240c34
commit
680a61247a
36 changed files with 102 additions and 102 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(APP_DRUST);
|
pub_handle!(APP_DRUST);
|
||||||
|
|
||||||
struct Drust;
|
struct Drust;
|
||||||
|
|
||||||
impl ModuleTrait for Drust {
|
impl ModuleTrait for Drust {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
APP_DRUST
|
APP_DRUST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(MODULE_ADMIN);
|
pub_handle!(MODULE_ADMIN);
|
||||||
|
|
||||||
localize!("src/locales");
|
pub_locale!("src/locales");
|
||||||
|
|
||||||
mod summary;
|
mod summary;
|
||||||
|
|
||||||
pub struct Admin;
|
pub struct Admin;
|
||||||
|
|
||||||
impl ModuleTrait for Admin {
|
impl ModuleTrait for Admin {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
MODULE_ADMIN
|
MODULE_ADMIN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(MODULE_NODE);
|
pub_handle!(MODULE_NODE);
|
||||||
|
|
||||||
localize!("src/locales");
|
pub_locale!("src/locales");
|
||||||
|
|
||||||
//mod entity;
|
//mod entity;
|
||||||
mod migration;
|
mod migration;
|
||||||
|
|
@ -10,7 +10,7 @@ mod migration;
|
||||||
pub struct Node;
|
pub struct Node;
|
||||||
|
|
||||||
impl ModuleTrait for Node {
|
impl ModuleTrait for Node {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
MODULE_NODE
|
MODULE_NODE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(MODULE_USER);
|
pub_handle!(MODULE_USER);
|
||||||
|
|
||||||
localize!("src/locales");
|
pub_locale!("src/locales");
|
||||||
|
|
||||||
mod migration;
|
mod migration;
|
||||||
|
|
||||||
pub struct User;
|
pub struct User;
|
||||||
|
|
||||||
impl ModuleTrait for User {
|
impl ModuleTrait for User {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
MODULE_USER
|
MODULE_USER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_ANCHOR);
|
pub_handle!(COMPONENT_ANCHOR);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum AnchorType {
|
pub enum AnchorType {
|
||||||
|
|
@ -43,7 +43,7 @@ impl ComponentTrait for Anchor {
|
||||||
Anchor::default()
|
Anchor::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_ANCHOR
|
COMPONENT_ANCHOR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_BLOCK);
|
pub_handle!(COMPONENT_BLOCK);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_BLOCK, Block);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_BLOCK, Block);
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl ComponentTrait for Block {
|
||||||
Block::default().with_classes(ClassesOp::SetDefault, "block")
|
Block::default().with_classes(ClassesOp::SetDefault, "block")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_BLOCK
|
COMPONENT_BLOCK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_CONTAINER);
|
pub_handle!(COMPONENT_CONTAINER);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_CONTAINER, Container);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_CONTAINER, Container);
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ impl ComponentTrait for Container {
|
||||||
.with_inner_classes(ClassesOp::SetDefault, "container")
|
.with_inner_classes(ClassesOp::SetDefault, "container")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_CONTAINER
|
COMPONENT_CONTAINER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_BUTTON);
|
pub_handle!(COMPONENT_BUTTON);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum ButtonType {
|
pub enum ButtonType {
|
||||||
|
|
@ -31,7 +31,7 @@ impl ComponentTrait for Button {
|
||||||
.with_classes(ClassesOp::AddFirst, "form-button")
|
.with_classes(ClassesOp::AddFirst, "form-button")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_BUTTON
|
COMPONENT_BUTTON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_DATE);
|
pub_handle!(COMPONENT_DATE);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -28,7 +28,7 @@ impl ComponentTrait for Date {
|
||||||
.with_classes(ClassesOp::AddFirst, "form-type-date")
|
.with_classes(ClassesOp::AddFirst, "form-type-date")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_DATE
|
COMPONENT_DATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_FORM);
|
pub_handle!(COMPONENT_FORM);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_FORM, Form);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_FORM, Form);
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ impl ComponentTrait for Form {
|
||||||
.with_charset("UTF-8")
|
.with_charset("UTF-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_FORM
|
COMPONENT_FORM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_HIDDEN);
|
pub_handle!(COMPONENT_HIDDEN);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -15,7 +15,7 @@ impl ComponentTrait for Hidden {
|
||||||
Hidden::default()
|
Hidden::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_HIDDEN
|
COMPONENT_HIDDEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_INPUT);
|
pub_handle!(COMPONENT_INPUT);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum InputType {
|
pub enum InputType {
|
||||||
|
|
@ -45,7 +45,7 @@ impl ComponentTrait for Input {
|
||||||
.with_maxlength(Some(128))
|
.with_maxlength(Some(128))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_INPUT
|
COMPONENT_INPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_COLUMN);
|
pub_handle!(COMPONENT_COLUMN);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_COLUMN, Column);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_COLUMN, Column);
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ impl ComponentTrait for Column {
|
||||||
Column::default().with_classes(ClassesOp::SetDefault, SIZE__DEFAULT)
|
Column::default().with_classes(ClassesOp::SetDefault, SIZE__DEFAULT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_COLUMN
|
COMPONENT_COLUMN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_ROW);
|
pub_handle!(COMPONENT_ROW);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_ROW, Row);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_ROW, Row);
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl ComponentTrait for Row {
|
||||||
Row::default().with_classes(ClassesOp::SetDefault, "row")
|
Row::default().with_classes(ClassesOp::SetDefault, "row")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_ROW
|
COMPONENT_ROW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_HEADING);
|
pub_handle!(COMPONENT_HEADING);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum HeadingType {
|
pub enum HeadingType {
|
||||||
|
|
@ -43,7 +43,7 @@ impl ComponentTrait for Heading {
|
||||||
Heading::default()
|
Heading::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_HEADING
|
COMPONENT_HEADING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_HTML);
|
pub_handle!(COMPONENT_HTML);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -16,7 +16,7 @@ impl ComponentTrait for Html {
|
||||||
Html::default()
|
Html::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_HTML
|
COMPONENT_HTML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_ICON);
|
pub_handle!(COMPONENT_ICON);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -16,7 +16,7 @@ impl ComponentTrait for Icon {
|
||||||
Icon::default().with_classes(ClassesOp::SetDefault, "bi-question-circle-fill")
|
Icon::default().with_classes(ClassesOp::SetDefault, "bi-question-circle-fill")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_ICON
|
COMPONENT_ICON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_IMAGE);
|
pub_handle!(COMPONENT_IMAGE);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -18,7 +18,7 @@ impl ComponentTrait for Image {
|
||||||
Image::default().with_classes(ClassesOp::SetDefault, "img-fluid")
|
Image::default().with_classes(ClassesOp::SetDefault, "img-fluid")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_IMAGE
|
COMPONENT_IMAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_MENUITEM);
|
pub_handle!(COMPONENT_MENUITEM);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum MenuItemType {
|
pub enum MenuItemType {
|
||||||
|
|
@ -29,7 +29,7 @@ impl ComponentTrait for MenuItem {
|
||||||
MenuItem::default()
|
MenuItem::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_MENUITEM
|
COMPONENT_MENUITEM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ impl MenuItem {
|
||||||
|
|
||||||
// Menu.
|
// Menu.
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_MENU);
|
pub_handle!(COMPONENT_MENU);
|
||||||
|
|
||||||
hook_before_render_component!(HOOK_BEFORE_RENDER_MENU, Menu);
|
hook_before_render_component!(HOOK_BEFORE_RENDER_MENU, Menu);
|
||||||
|
|
||||||
|
|
@ -190,7 +190,7 @@ impl ComponentTrait for Menu {
|
||||||
Menu::default().with_classes(ClassesOp::SetDefault, "sm sm-clean")
|
Menu::default().with_classes(ClassesOp::SetDefault, "sm sm-clean")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_MENU
|
COMPONENT_MENU
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(COMPONENT_PARAGRAPH);
|
pub_handle!(COMPONENT_PARAGRAPH);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum ParagraphDisplay {
|
pub enum ParagraphDisplay {
|
||||||
|
|
@ -30,7 +30,7 @@ impl ComponentTrait for Paragraph {
|
||||||
Paragraph::default()
|
Paragraph::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
COMPONENT_PARAGRAPH
|
COMPONENT_PARAGRAPH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(MODULE_DEFAULT_HOMEPAGE);
|
pub_handle!(MODULE_DEFAULT_HOMEPAGE);
|
||||||
|
|
||||||
localize!("src/base/module/homepage/locales");
|
pub_locale!("src/base/module/homepage/locales");
|
||||||
|
|
||||||
pub struct DefaultHomePage;
|
pub struct DefaultHomePage;
|
||||||
|
|
||||||
impl ModuleTrait for DefaultHomePage {
|
impl ModuleTrait for DefaultHomePage {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
MODULE_DEFAULT_HOMEPAGE
|
MODULE_DEFAULT_HOMEPAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(THEME_ALINER);
|
pub_handle!(THEME_ALINER);
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
|
include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
|
||||||
|
|
||||||
pub struct Aliner;
|
pub struct Aliner;
|
||||||
|
|
||||||
impl ThemeTrait for Aliner {
|
impl ThemeTrait for Aliner {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
THEME_ALINER
|
THEME_ALINER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(THEME_BOOTSIER);
|
pub_handle!(THEME_BOOTSIER);
|
||||||
|
|
||||||
|
pub_locale!("src/base/theme/bootsier/locales");
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bootsier.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bootsier.rs"));
|
||||||
|
|
||||||
localize!("src/base/theme/bootsier/locales");
|
|
||||||
|
|
||||||
pub struct Bootsier;
|
pub struct Bootsier;
|
||||||
|
|
||||||
impl ThemeTrait for Bootsier {
|
impl ThemeTrait for Bootsier {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
THEME_BOOTSIER
|
THEME_BOOTSIER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(THEME_BULMIX);
|
pub_handle!(THEME_BULMIX);
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
||||||
|
|
||||||
pub struct Bulmix;
|
pub struct Bulmix;
|
||||||
|
|
||||||
impl ThemeTrait for Bulmix {
|
impl ThemeTrait for Bulmix {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
THEME_BULMIX
|
THEME_BULMIX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ impl ThemeTrait for Bulmix {
|
||||||
component: &mut dyn ComponentTrait,
|
component: &mut dyn ComponentTrait,
|
||||||
_context: &mut PageContext,
|
_context: &mut PageContext,
|
||||||
) {
|
) {
|
||||||
match component.handler() {
|
match component.handle() {
|
||||||
COMPONENT_ANCHOR => {
|
COMPONENT_ANCHOR => {
|
||||||
let a = component_mut::<Anchor>(component);
|
let a = component_mut::<Anchor>(component);
|
||||||
a.alter_classes(
|
a.alter_classes(
|
||||||
|
|
@ -112,7 +112,7 @@ impl ThemeTrait for Bulmix {
|
||||||
component: &dyn ComponentTrait,
|
component: &dyn ComponentTrait,
|
||||||
_context: &mut PageContext,
|
_context: &mut PageContext,
|
||||||
) -> Option<Markup> {
|
) -> Option<Markup> {
|
||||||
match component.handler() {
|
match component.handle() {
|
||||||
COMPONENT_ICON => {
|
COMPONENT_ICON => {
|
||||||
let icon = component_ref::<Icon>(component);
|
let icon = component_ref::<Icon>(component);
|
||||||
Some(html! {
|
Some(html! {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub_const_handler!(THEME_MINIMAL);
|
pub_handle!(THEME_MINIMAL);
|
||||||
|
|
||||||
pub struct Minimal;
|
pub struct Minimal;
|
||||||
|
|
||||||
impl ThemeTrait for Minimal {
|
impl ThemeTrait for Minimal {
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
THEME_MINIMAL
|
THEME_MINIMAL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::html::{html, Markup};
|
use crate::html::{html, Markup};
|
||||||
use crate::response::page::PageContext;
|
use crate::response::page::PageContext;
|
||||||
use crate::util::{single_type_name, Handler};
|
use crate::util::{single_type_name, Handle};
|
||||||
|
|
||||||
pub use std::any::Any as AnyComponent;
|
pub use std::any::Any as AnyComponent;
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync {
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
fn handler(&self) -> Handler;
|
fn handle(&self) -> Handle;
|
||||||
|
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
single_type_name::<Self>().to_owned()
|
single_type_name::<Self>().to_owned()
|
||||||
|
|
@ -75,7 +75,7 @@ pub fn component_mut<C: 'static>(component: &mut dyn ComponentTrait) -> &mut C {
|
||||||
macro_rules! hook_before_render_component {
|
macro_rules! hook_before_render_component {
|
||||||
( $ACTION_HANDLER:ident, $Component:ty ) => {
|
( $ACTION_HANDLER:ident, $Component:ty ) => {
|
||||||
paste::paste! {
|
paste::paste! {
|
||||||
$crate::pub_const_handler!($ACTION_HANDLER);
|
$crate::pub_handle!($ACTION_HANDLER);
|
||||||
|
|
||||||
type Action = fn(&$Component, &mut PageContext);
|
type Action = fn(&$Component, &mut PageContext);
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ macro_rules! hook_before_render_component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
$ACTION_HANDLER
|
$ACTION_HANDLER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
use super::{ActionsHolder, HookAction};
|
use super::{ActionsHolder, HookAction};
|
||||||
use crate::util::Handler;
|
use crate::util::Handle;
|
||||||
use crate::LazyStatic;
|
use crate::LazyStatic;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
// Registered actions.
|
// Registered actions.
|
||||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handler, ActionsHolder>>> =
|
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsHolder>>> =
|
||||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
pub fn add_action(action: HookAction) {
|
pub fn add_action(action: HookAction) {
|
||||||
let mut actions = ACTIONS.write().unwrap();
|
let mut actions = ACTIONS.write().unwrap();
|
||||||
let action_handler = action.handler();
|
let action_handle = action.handle();
|
||||||
if let Some(holder) = actions.get_mut(&action_handler) {
|
if let Some(holder) = actions.get_mut(&action_handle) {
|
||||||
holder.add(action);
|
holder.add(action);
|
||||||
} else {
|
} else {
|
||||||
actions.insert(action_handler, ActionsHolder::new_with(action));
|
actions.insert(action_handle, ActionsHolder::new_with(action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_actions<B, F>(action_handler: Handler, f: F)
|
pub fn run_actions<B, F>(action_handle: Handle, f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(&HookAction) -> B,
|
F: FnMut(&HookAction) -> B,
|
||||||
{
|
{
|
||||||
if let Some(holder) = ACTIONS.read().unwrap().get(&action_handler) {
|
if let Some(holder) = ACTIONS.read().unwrap().get(&action_handle) {
|
||||||
holder.iter_map(f)
|
holder.iter_map(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::util::Handler;
|
use crate::util::Handle;
|
||||||
|
|
||||||
pub use std::any::Any as AnyHookAction;
|
pub use std::any::Any as AnyHookAction;
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ pub trait HookActionTrait: AnyHookAction + Send + Sync {
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
fn handler(&self) -> Handler;
|
fn handle(&self) -> Handle;
|
||||||
|
|
||||||
fn weight(&self) -> isize {
|
fn weight(&self) -> isize {
|
||||||
0
|
0
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ pub fn register_modules(app: ModuleStaticRef) {
|
||||||
|
|
||||||
fn add_to_discarded(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
fn add_to_discarded(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
||||||
for u in module.uninstall_modules().iter() {
|
for u in module.uninstall_modules().iter() {
|
||||||
if !list.iter().any(|m| m.handler() == u.handler()) {
|
if !list.iter().any(|m| m.handle() == u.handle()) {
|
||||||
list.push(*u);
|
list.push(*u);
|
||||||
trace::debug!("Module \"{}\" discarded", u.single_name());
|
trace::debug!("Module \"{}\" discarded", u.single_name());
|
||||||
}
|
}
|
||||||
|
|
@ -42,12 +42,12 @@ fn add_to_discarded(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_to_enabled(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
fn add_to_enabled(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
||||||
if !list.iter().any(|m| m.handler() == module.handler()) {
|
if !list.iter().any(|m| m.handle() == module.handle()) {
|
||||||
if DISCARDED_MODULES
|
if DISCARDED_MODULES
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|m| m.handler() == module.handler())
|
.any(|m| m.handle() == module.handle())
|
||||||
{
|
{
|
||||||
panic!(
|
panic!(
|
||||||
"Trying to enable \"{}\" module which is disabled",
|
"Trying to enable \"{}\" module which is disabled",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::app;
|
use crate::app;
|
||||||
use crate::core::hook::HookAction;
|
use crate::core::hook::HookAction;
|
||||||
use crate::core::theme::ThemeStaticRef;
|
use crate::core::theme::ThemeStaticRef;
|
||||||
use crate::util::{single_type_name, Handler};
|
use crate::util::{single_type_name, Handle};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::db::MigrationItem;
|
use crate::db::MigrationItem;
|
||||||
|
|
@ -14,7 +14,7 @@ pub trait BaseModule {
|
||||||
|
|
||||||
/// Los módulos deben implementar este *trait*.
|
/// Los módulos deben implementar este *trait*.
|
||||||
pub trait ModuleTrait: BaseModule + Send + Sync {
|
pub trait ModuleTrait: BaseModule + Send + Sync {
|
||||||
fn handler(&self) -> Handler;
|
fn handle(&self) -> Handle;
|
||||||
|
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
self.single_name().to_owned()
|
self.single_name().to_owned()
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ pub fn register_themes(themes: Vec<ThemeStaticRef>) {
|
||||||
for theme in themes {
|
for theme in themes {
|
||||||
if !registered_themes
|
if !registered_themes
|
||||||
.iter()
|
.iter()
|
||||||
.any(|t| t.handler() == theme.handler())
|
.any(|t| t.handle() == theme.handle())
|
||||||
{
|
{
|
||||||
trace::debug!("Registering theme \"{}\"", theme.single_name());
|
trace::debug!("Registering theme \"{}\"", theme.single_name());
|
||||||
registered_themes.push(theme);
|
registered_themes.push(theme);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::concat_string;
|
||||||
use crate::core::component::ComponentTrait;
|
use crate::core::component::ComponentTrait;
|
||||||
use crate::html::{html, Favicon, Markup};
|
use crate::html::{html, Favicon, Markup};
|
||||||
use crate::response::page::{Page, PageContext, PageOp};
|
use crate::response::page::{Page, PageContext, PageOp};
|
||||||
use crate::util::{single_type_name, Handler};
|
use crate::util::{single_type_name, Handle};
|
||||||
|
|
||||||
pub type ThemeStaticRef = &'static dyn ThemeTrait;
|
pub type ThemeStaticRef = &'static dyn ThemeTrait;
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ pub trait BaseTheme {
|
||||||
|
|
||||||
/// Los temas deben implementar este "trait".
|
/// Los temas deben implementar este "trait".
|
||||||
pub trait ThemeTrait: BaseTheme + Send + Sync {
|
pub trait ThemeTrait: BaseTheme + Send + Sync {
|
||||||
fn handler(&self) -> Handler;
|
fn handle(&self) -> Handle;
|
||||||
|
|
||||||
fn name(&self) -> String {
|
fn name(&self) -> String {
|
||||||
self.single_name().to_owned()
|
self.single_name().to_owned()
|
||||||
|
|
@ -91,7 +91,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
||||||
/*
|
/*
|
||||||
Cómo usarlo:
|
Cómo usarlo:
|
||||||
|
|
||||||
match component.handler() {
|
match component.handle() {
|
||||||
BLOCK_COMPONENT => {
|
BLOCK_COMPONENT => {
|
||||||
let block = component_mut::<Block>(component);
|
let block = component_mut::<Block>(component);
|
||||||
block.alter_title("New title");
|
block.alter_title("New title");
|
||||||
|
|
@ -111,7 +111,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
||||||
/*
|
/*
|
||||||
Cómo usarlo:
|
Cómo usarlo:
|
||||||
|
|
||||||
match component.handler() {
|
match component.handle() {
|
||||||
BLOCK_COMPONENT => {
|
BLOCK_COMPONENT => {
|
||||||
let block = component_ref::<Block>(component);
|
let block = component_ref::<Block>(component);
|
||||||
match block.template() {
|
match block.template() {
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,16 @@
|
||||||
//! # Cómo aplicar la localización en tu código
|
//! # Cómo aplicar la localización en tu código
|
||||||
//!
|
//!
|
||||||
//! Una vez hayas creado tu directorio de recursos FTL, sólo tienes que usar la poderosa macro
|
//! Una vez hayas creado tu directorio de recursos FTL, sólo tienes que usar la poderosa macro
|
||||||
//! [`localize!`](crate::localize) para integrar fácilmente tus recursos de localización.
|
//! [`pub_locale!`](crate::pub_locale) para integrar fácilmente tus recursos de localización.
|
||||||
//!
|
//!
|
||||||
//! Esta macro crea dos funciones para el ámbito donde se ejecuta. Por un lado la función `l()` para
|
//! Esta macro crea dos funciones para el ámbito donde se ejecuta. Por un lado la función `l()` para
|
||||||
//! traducciones directas de etiquetas. Y por otro la función `t()` para traducciones que requieren
|
//! traducciones directas de etiquetas. Y por otro la función `t()` para traducciones que requieren
|
||||||
//! argumentos:
|
//! argumentos:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use pagetop::{args, localize};
|
//! use pagetop::{args, pub_locale};
|
||||||
//!
|
//!
|
||||||
//! localize!("en-US");
|
//! pub_locale!("en-US");
|
||||||
//!
|
//!
|
||||||
//! fn demo() {
|
//! fn demo() {
|
||||||
//! println!("* {}", l("hello-world"));
|
//! println!("* {}", l("hello-world"));
|
||||||
|
|
@ -100,7 +100,7 @@ pub use fluent_templates::{static_loader as static_locale, Loader as Locale};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
/// Permite integrar fácilmente localización en temas, módulos y componentes.
|
/// Permite integrar fácilmente localización en temas, módulos y componentes.
|
||||||
macro_rules! localize {
|
macro_rules! pub_locale {
|
||||||
( $dir_locales:literal $(, $core_locales:literal)? ) => {
|
( $dir_locales:literal $(, $core_locales:literal)? ) => {
|
||||||
use $crate::locale::*;
|
use $crate::locale::*;
|
||||||
use $crate::app::locale::LANGID;
|
use $crate::app::locale::LANGID;
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,13 @@
|
||||||
pub use crate::{concat_string, LazyStatic};
|
pub use crate::{concat_string, LazyStatic};
|
||||||
|
|
||||||
// Macros.
|
// Macros.
|
||||||
pub use crate::{args, configure_service_for_static_files, predefined_settings, pub_const_handler};
|
pub use crate::{
|
||||||
|
args, configure_service_for_static_files, predefined_settings, pub_handle, pub_locale,
|
||||||
|
};
|
||||||
|
|
||||||
// Helpers.
|
// Helpers.
|
||||||
pub use crate::util;
|
pub use crate::util;
|
||||||
pub use crate::util::{Handler, HashMapResources};
|
pub use crate::util::{Handle, HashMapResources};
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
|
||||||
|
|
@ -14,8 +16,6 @@ pub use crate::config;
|
||||||
|
|
||||||
pub use crate::trace;
|
pub use crate::trace;
|
||||||
|
|
||||||
pub use crate::localize;
|
|
||||||
|
|
||||||
pub use crate::html::*;
|
pub use crate::html::*;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use super::Page;
|
use super::Page;
|
||||||
use crate::core::hook::{AnyHookAction, HookActionTrait};
|
use crate::core::hook::{AnyHookAction, HookActionTrait};
|
||||||
use crate::pub_const_handler;
|
use crate::pub_handle;
|
||||||
use crate::util::Handler;
|
use crate::util::Handle;
|
||||||
|
|
||||||
pub_const_handler!(HOOK_BEFORE_RENDER_PAGE);
|
pub_handle!(HOOK_BEFORE_RENDER_PAGE);
|
||||||
|
|
||||||
type Hook = fn(&mut Page);
|
type Hook = fn(&mut Page);
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ impl HookActionTrait for BeforeRenderPageHook {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handler(&self) -> Handler {
|
fn handle(&self) -> Handle {
|
||||||
HOOK_BEFORE_RENDER_PAGE
|
HOOK_BEFORE_RENDER_PAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,15 +87,15 @@ pub fn bundle_resources(
|
||||||
bundle.build()
|
bundle.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Handler = u64;
|
pub type Handle = u64;
|
||||||
|
|
||||||
// https://stackoverflow.com/a/71464396
|
// https://stackoverflow.com/a/71464396
|
||||||
pub const fn handler(
|
pub const fn handle(
|
||||||
module_path: &'static str,
|
module_path: &'static str,
|
||||||
file: &'static str,
|
file: &'static str,
|
||||||
line: u32,
|
line: u32,
|
||||||
column: u32,
|
column: u32,
|
||||||
) -> Handler {
|
) -> Handle {
|
||||||
let mut hash = 0xcbf29ce484222325;
|
let mut hash = 0xcbf29ce484222325;
|
||||||
let prime = 0x00000100000001B3;
|
let prime = 0x00000100000001B3;
|
||||||
|
|
||||||
|
|
@ -124,10 +124,10 @@ pub const fn handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! pub_const_handler {
|
macro_rules! pub_handle {
|
||||||
( $HANDLER:ident ) => {
|
( $HANDLE:ident ) => {
|
||||||
pub const $HANDLER: $crate::util::Handler =
|
pub const $HANDLE: $crate::util::Handle =
|
||||||
$crate::util::handler(module_path!(), file!(), line!(), column!());
|
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue