diff --git a/drust/src/main.rs b/drust/src/main.rs index 63dcaccd..25c5ed88 100644 --- a/drust/src/main.rs +++ b/drust/src/main.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(APP_DRUST); +create_handle!(APP_DRUST); struct Drust; diff --git a/examples/basics/hello-name/src/main.rs b/examples/basics/hello-name/src/main.rs index c02f4865..cc0c8cd8 100644 --- a/examples/basics/hello-name/src/main.rs +++ b/examples/basics/hello-name/src/main.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(APP_HELLO_NAME); +create_handle!(APP_HELLO_NAME); struct HelloName; diff --git a/examples/basics/hello-world/src/main.rs b/examples/basics/hello-world/src/main.rs index 0d1a8e15..14a1f5a7 100644 --- a/examples/basics/hello-world/src/main.rs +++ b/examples/basics/hello-world/src/main.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(APP_HELLO_WORLD); +create_handle!(APP_HELLO_WORLD); struct HelloWorld; diff --git a/pagetop-admin/src/lib.rs b/pagetop-admin/src/lib.rs index c6004a9c..52d6233d 100644 --- a/pagetop-admin/src/lib.rs +++ b/pagetop-admin/src/lib.rs @@ -1,8 +1,8 @@ use pagetop::prelude::*; -use_handle!(MODULE_ADMIN); +create_handle!(MODULE_ADMIN); -use_locale!(LOCALE_ADMIN); +static_locales!(LOCALES_ADMIN); mod summary; @@ -14,11 +14,11 @@ impl ModuleTrait for Admin { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_ADMIN) + L10n::t("module_name", &LOCALES_ADMIN) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_ADMIN) + L10n::t("module_description", &LOCALES_ADMIN) } #[rustfmt::skip] diff --git a/pagetop-admin/src/summary.rs b/pagetop-admin/src/summary.rs index 8d90bcb6..4d097049 100644 --- a/pagetop-admin/src/summary.rs +++ b/pagetop-admin/src/summary.rs @@ -1,4 +1,4 @@ -use crate::LOCALE_ADMIN; +use crate::LOCALES_ADMIN; use pagetop::prelude::*; use pagetop_megamenu::component::{MegaMenu, MegaMenuItem}; @@ -6,7 +6,7 @@ use pagetop_minimal::component::*; pub async fn summary(request: service::HttpRequest) -> ResultPage { let top_menu = MegaMenu::new() - .with_item(MegaMenuItem::label(L10n::t("module_name", &LOCALE_ADMIN))) + .with_item(MegaMenuItem::label(L10n::t("module_name", &LOCALES_ADMIN))) .with_item(MegaMenuItem::link( L10n::n("Opción 2"), "https://www.google.es", diff --git a/pagetop-aliner/src/lib.rs b/pagetop-aliner/src/lib.rs index f532eef1..92079cfd 100644 --- a/pagetop-aliner/src/lib.rs +++ b/pagetop-aliner/src/lib.rs @@ -1,8 +1,8 @@ use pagetop::prelude::*; -use_handle!(THEME_ALINER); +create_handle!(THEME_ALINER); -use_static!(aliner); +static_files!(aliner); pub struct Aliner; diff --git a/pagetop-bootsier/src/lib.rs b/pagetop-bootsier/src/lib.rs index 338cc6cf..31dfd56e 100644 --- a/pagetop-bootsier/src/lib.rs +++ b/pagetop-bootsier/src/lib.rs @@ -1,11 +1,11 @@ use pagetop::prelude::*; use pagetop_jquery::JQuery; -use_handle!(THEME_BOOTSIER); +create_handle!(THEME_BOOTSIER); -use_locale!(LOCALE_BOOTSIER); +static_locales!(LOCALES_BOOTSIER); -use_static!(bootsier); +static_files!(bootsier); pub struct Bootsier; @@ -31,15 +31,15 @@ impl ThemeTrait for Bootsier { #[rustfmt::skip] fn regions(&self) -> Vec<(&'static str, L10n)> { vec![ - ("header", L10n::t("header", &LOCALE_BOOTSIER)), - ("nav_branding", L10n::t("nav_branding", &LOCALE_BOOTSIER)), - ("nav_main", L10n::t("nav_main", &LOCALE_BOOTSIER)), - ("nav_additional", L10n::t("nav_additional", &LOCALE_BOOTSIER)), - ("breadcrumb", L10n::t("breadcrumb", &LOCALE_BOOTSIER)), - ("content", L10n::t("breadcrumb", &LOCALE_BOOTSIER)), - ("sidebar_first", L10n::t("sidebar_first", &LOCALE_BOOTSIER)), - ("sidebar_second", L10n::t("sidebar_second", &LOCALE_BOOTSIER)), - ("footer", L10n::t("footer", &LOCALE_BOOTSIER)), + ("header", L10n::t("header", &LOCALES_BOOTSIER)), + ("nav_branding", L10n::t("nav_branding", &LOCALES_BOOTSIER)), + ("nav_main", L10n::t("nav_main", &LOCALES_BOOTSIER)), + ("nav_additional", L10n::t("nav_additional", &LOCALES_BOOTSIER)), + ("breadcrumb", L10n::t("breadcrumb", &LOCALES_BOOTSIER)), + ("content", L10n::t("breadcrumb", &LOCALES_BOOTSIER)), + ("sidebar_first", L10n::t("sidebar_first", &LOCALES_BOOTSIER)), + ("sidebar_second", L10n::t("sidebar_second", &LOCALES_BOOTSIER)), + ("footer", L10n::t("footer", &LOCALES_BOOTSIER)), ] } @@ -131,18 +131,18 @@ impl ThemeTrait for Bootsier { div class="media-body" { h1 class="display-4" { ("RESOURCE NOT FOUND") } p class="lead" { - (L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(cx)) + (L10n::t("e404-description", &LOCALES_BOOTSIER).prepare(cx)) } hr class="my-4"; p { - (L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(cx)) + (L10n::t("e404-description", &LOCALES_BOOTSIER).prepare(cx)) } a class="btn btn-primary btn-lg" href="/" role="button" { - (L10n::t("back-homepage", &LOCALE_BOOTSIER).prepare(cx)) + (L10n::t("back-homepage", &LOCALES_BOOTSIER).prepare(cx)) } } } diff --git a/pagetop-build/src/lib.rs b/pagetop-build/src/lib.rs index 5e877d82..8c53d241 100644 --- a/pagetop-build/src/lib.rs +++ b/pagetop-build/src/lib.rs @@ -59,7 +59,7 @@ //! ```rust#ignore //! use pagetop::prelude::*; //! -//! use_static!(guides); +//! static_files!(guides); //! ``` //! //! Also you can get the bundle as a static reference to the generated HashMap resources collection: @@ -67,7 +67,7 @@ //! ```rust#ignore //! use pagetop::prelude::*; //! -//! use_static!(guides => BUNDLE_GUIDES); +//! static_files!(guides => BUNDLE_GUIDES); //! ``` //! //! You can build more than one resources file to compile with your project. diff --git a/pagetop-bulmix/src/lib.rs b/pagetop-bulmix/src/lib.rs index 9059ed56..9905b05d 100644 --- a/pagetop-bulmix/src/lib.rs +++ b/pagetop-bulmix/src/lib.rs @@ -2,9 +2,9 @@ use pagetop::prelude::*; use pagetop_jquery::JQuery; use pagetop_minimal::component::*; -use_handle!(THEME_BULMIX); +create_handle!(THEME_BULMIX); -use_static!(bulmix); +static_files!(bulmix); pub struct Bulmix; diff --git a/pagetop-homedemo/src/lib.rs b/pagetop-homedemo/src/lib.rs index f3cb304d..308d6873 100644 --- a/pagetop-homedemo/src/lib.rs +++ b/pagetop-homedemo/src/lib.rs @@ -1,11 +1,11 @@ use pagetop::prelude::*; use pagetop_minimal::component::*; -use_handle!(MODULE_HOMEDEMO); +create_handle!(MODULE_HOMEDEMO); -use_locale!(LOCALE_HOMEDEMO); +static_locales!(LOCALES_HOMEDEMO); -use_static!(homedemo); +static_files!(homedemo); pub struct HomeDemo; @@ -15,11 +15,11 @@ impl ModuleTrait for HomeDemo { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_HOMEDEMO) + L10n::t("module_name", &LOCALES_HOMEDEMO) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_HOMEDEMO) + L10n::t("module_description", &LOCALES_HOMEDEMO) } fn dependencies(&self) -> Vec { @@ -34,7 +34,7 @@ impl ModuleTrait for HomeDemo { async fn demo(request: service::HttpRequest) -> ResultPage { Page::new(request) - .with_title(L10n::t("page_title", &LOCALE_HOMEDEMO)) + .with_title(L10n::t("page_title", &LOCALES_HOMEDEMO)) .with_context(ContextOp::AddStyleSheet(StyleSheet::at( "/homedemo/css/styles.css", ))) @@ -55,11 +55,11 @@ fn hello_world() -> Container { .with_classes(ClassesOp::Add, "hello-col-text") .with_size(grid::ColumnSize::Is5of12) .with_component( - Heading::h1(L10n::t("page_title", &LOCALE_HOMEDEMO)) + Heading::h1(L10n::t("page_title", &LOCALES_HOMEDEMO)) .with_display(HeadingDisplay::Medium), ) .with_component( - Paragraph::with(L10n::e("hello_intro", &LOCALE_HOMEDEMO).with_arg( + Paragraph::with(L10n::e("hello_intro", &LOCALES_HOMEDEMO).with_arg( "app", format!( "{}", @@ -69,7 +69,7 @@ fn hello_world() -> Container { .with_display(ParagraphDisplay::Small), ) .with_component(Paragraph::with( - L10n::e("hello_powered", &LOCALE_HOMEDEMO).with_arg( + L10n::e("hello_powered", &LOCALES_HOMEDEMO).with_arg( "pagetop", format!( "{}", @@ -80,14 +80,14 @@ fn hello_world() -> Container { .with_component( Anchor::button( "https://github.com/manuelcillero/pagetop", - L10n::t("hello_code", &LOCALE_HOMEDEMO), + L10n::t("hello_code", &LOCALES_HOMEDEMO), ) .with_target(AnchorTarget::Blank) .with_left_icon(Icon::with("git")) .with_classes(ClassesOp::Add, "code-link"), ) .with_component( - Anchor::link("#welcome", L10n::t("hello_welcome", &LOCALE_HOMEDEMO)) + Anchor::link("#welcome", L10n::t("hello_welcome", &LOCALES_HOMEDEMO)) .with_left_icon(Icon::with("arrow-down-circle-fill")) .with_classes(ClassesOp::Add, "welcome-link"), ), @@ -104,9 +104,9 @@ fn welcome() -> Container { Container::section() .with_id("welcome") .with_classes(ClassesOp::Add, "welcome-col-text") - .with_component(Heading::h2(L10n::t("welcome_page", &LOCALE_HOMEDEMO))) + .with_component(Heading::h2(L10n::t("welcome_page", &LOCALES_HOMEDEMO))) .with_component( - Heading::h3(L10n::e("welcome_subtitle", &LOCALE_HOMEDEMO).with_arg( + Heading::h3(L10n::e("welcome_subtitle", &LOCALES_HOMEDEMO).with_arg( "app", format!( "{}", @@ -116,10 +116,10 @@ fn welcome() -> Container { .with_display(HeadingDisplay::Subtitle), ) .with_component( - Paragraph::with(L10n::t("welcome_text1", &LOCALE_HOMEDEMO)) + Paragraph::with(L10n::t("welcome_text1", &LOCALES_HOMEDEMO)) .with_display(ParagraphDisplay::Small), ) - .with_component(Paragraph::with(L10n::t("welcome_text2", &LOCALE_HOMEDEMO))) + .with_component(Paragraph::with(L10n::t("welcome_text2", &LOCALES_HOMEDEMO))) } fn about_pagetop() -> Container { @@ -134,14 +134,14 @@ fn about_pagetop() -> Container { .with_column( grid::Column::new() .with_classes(ClassesOp::Add, "pagetop-col-text") - .with_component(Heading::h2(L10n::t("pagetop_title", &LOCALE_HOMEDEMO))) + .with_component(Heading::h2(L10n::t("pagetop_title", &LOCALES_HOMEDEMO))) .with_component( - Paragraph::with(L10n::t("pagetop_text1", &LOCALE_HOMEDEMO)) + Paragraph::with(L10n::t("pagetop_text1", &LOCALES_HOMEDEMO)) .with_display(ParagraphDisplay::Small), ) - .with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALE_HOMEDEMO))) + .with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALES_HOMEDEMO))) .with_component(Paragraph::with( - L10n::e("pagetop_text3", &LOCALE_HOMEDEMO) + L10n::e("pagetop_text3", &LOCALES_HOMEDEMO) .with_arg("href", "https://docs.rs/pagetop/latest/pagetop".to_string()), )), ), @@ -156,16 +156,18 @@ fn promo_pagetop() -> Container { .with_classes(ClassesOp::Add, "promo-col-text") .with_component(Heading::h2(L10n::t( "pagetop_promo_title", - &LOCALE_HOMEDEMO, + &LOCALES_HOMEDEMO, ))) .with_component( - Paragraph::with(L10n::e("pagetop_promo_text1", &LOCALE_HOMEDEMO).with_arg( - "pagetop", - format!( - "{}", - "https://crates.io/crates/pagetop", "PageTop", + Paragraph::with( + L10n::e("pagetop_promo_text1", &LOCALES_HOMEDEMO).with_arg( + "pagetop", + format!( + "{}", + "https://crates.io/crates/pagetop", "PageTop", + ), ), - )) + ) .with_display(ParagraphDisplay::Small), ), ) @@ -192,15 +194,15 @@ fn reporting_issues() -> Container { .with_size(grid::ColumnSize::Is6of12) .with_component(Heading::h2(L10n::t( "report_problems_title", - &LOCALE_HOMEDEMO, + &LOCALES_HOMEDEMO, ))) .with_component( - Paragraph::with(L10n::t("report_problems_text1", &LOCALE_HOMEDEMO)) + Paragraph::with(L10n::t("report_problems_text1", &LOCALES_HOMEDEMO)) .with_display(ParagraphDisplay::Small), ) .with_component(Paragraph::with(L10n::t( "report_problems_text2", - &LOCALE_HOMEDEMO, + &LOCALES_HOMEDEMO, ))), ), ) diff --git a/pagetop-jquery/src/lib.rs b/pagetop-jquery/src/lib.rs index dfbffacb..585a85a9 100644 --- a/pagetop-jquery/src/lib.rs +++ b/pagetop-jquery/src/lib.rs @@ -1,10 +1,10 @@ use pagetop::prelude::*; -use_handle!(MODULE_JQUERY); +create_handle!(MODULE_JQUERY); -use_locale!(LOCALE_JQUERY); +static_locales!(LOCALES_JQUERY); -use_static!(jquery); +static_files!(jquery); const PARAM_JQUERY: &str = "jquery.js"; @@ -16,11 +16,11 @@ impl ModuleTrait for JQuery { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_JQUERY) + L10n::t("module_name", &LOCALES_JQUERY) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_JQUERY) + L10n::t("module_description", &LOCALES_JQUERY) } fn actions(&self) -> Vec { diff --git a/pagetop-megamenu/src/component.rs b/pagetop-megamenu/src/component.rs index 25d3dbd3..9112593a 100644 --- a/pagetop-megamenu/src/component.rs +++ b/pagetop-megamenu/src/component.rs @@ -1,7 +1,7 @@ use pagetop::prelude::*; use pagetop_jquery::JQuery; -use_handle!(COMPONENT_MEGAMENUITEM); +create_handle!(COMPONENT_MEGAMENUITEM); type Label = OneComponent; type Content = OneComponent; @@ -144,7 +144,7 @@ impl MegaMenuItem { // MegaMenu. -use_handle!(COMPONENT_MEGAMENU); +create_handle!(COMPONENT_MEGAMENU); actions_for_component!(MegaMenu); diff --git a/pagetop-megamenu/src/lib.rs b/pagetop-megamenu/src/lib.rs index bf77e59c..b1bd6593 100644 --- a/pagetop-megamenu/src/lib.rs +++ b/pagetop-megamenu/src/lib.rs @@ -2,9 +2,9 @@ use pagetop::prelude::*; pub mod component; -use_handle!(MODULE_MEGAMENU); +create_handle!(MODULE_MEGAMENU); -use_static!(megamenu); +static_files!(megamenu); pub struct MegaMenu; diff --git a/pagetop-minimal/src/component/anchor.rs b/pagetop-minimal/src/component/anchor.rs index 07254ec5..0d041e21 100644 --- a/pagetop-minimal/src/component/anchor.rs +++ b/pagetop-minimal/src/component/anchor.rs @@ -2,7 +2,7 @@ use pagetop::prelude::*; use crate::component::Icon; -use_handle!(COMPONENT_ANCHOR); +create_handle!(COMPONENT_ANCHOR); #[derive(Default)] pub enum AnchorType { diff --git a/pagetop-minimal/src/component/block.rs b/pagetop-minimal/src/component/block.rs index 4770a03b..956f64bf 100644 --- a/pagetop-minimal/src/component/block.rs +++ b/pagetop-minimal/src/component/block.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_BLOCK); +create_handle!(COMPONENT_BLOCK); actions_for_component!(Block); diff --git a/pagetop-minimal/src/component/container.rs b/pagetop-minimal/src/component/container.rs index 2a24de4c..cdd98932 100644 --- a/pagetop-minimal/src/component/container.rs +++ b/pagetop-minimal/src/component/container.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_CONTAINER); +create_handle!(COMPONENT_CONTAINER); actions_for_component!(Container); diff --git a/pagetop-minimal/src/component/form_element/button.rs b/pagetop-minimal/src/component/form_element/button.rs index 358391d3..d2977c84 100644 --- a/pagetop-minimal/src/component/form_element/button.rs +++ b/pagetop-minimal/src/component/form_element/button.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_BUTTON); +create_handle!(COMPONENT_BUTTON); #[derive(Default)] pub enum ButtonType { diff --git a/pagetop-minimal/src/component/form_element/date.rs b/pagetop-minimal/src/component/form_element/date.rs index faba0fcc..2b097088 100644 --- a/pagetop-minimal/src/component/form_element/date.rs +++ b/pagetop-minimal/src/component/form_element/date.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_DATE); +create_handle!(COMPONENT_DATE); #[rustfmt::skip] #[derive(Default)] diff --git a/pagetop-minimal/src/component/form_element/form.rs b/pagetop-minimal/src/component/form_element/form.rs index 1d20370e..a4299fa1 100644 --- a/pagetop-minimal/src/component/form_element/form.rs +++ b/pagetop-minimal/src/component/form_element/form.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_FORM); +create_handle!(COMPONENT_FORM); actions_for_component!(Form); diff --git a/pagetop-minimal/src/component/form_element/hidden.rs b/pagetop-minimal/src/component/form_element/hidden.rs index e1b88cf8..c982e77e 100644 --- a/pagetop-minimal/src/component/form_element/hidden.rs +++ b/pagetop-minimal/src/component/form_element/hidden.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_HIDDEN); +create_handle!(COMPONENT_HIDDEN); #[rustfmt::skip] #[derive(Default)] diff --git a/pagetop-minimal/src/component/form_element/input.rs b/pagetop-minimal/src/component/form_element/input.rs index c2f49a4c..057048f4 100644 --- a/pagetop-minimal/src/component/form_element/input.rs +++ b/pagetop-minimal/src/component/form_element/input.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_INPUT); +create_handle!(COMPONENT_INPUT); #[derive(Default)] pub enum InputType { diff --git a/pagetop-minimal/src/component/grid/column.rs b/pagetop-minimal/src/component/grid/column.rs index 56b96043..b872ccfa 100644 --- a/pagetop-minimal/src/component/grid/column.rs +++ b/pagetop-minimal/src/component/grid/column.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_COLUMN); +create_handle!(COMPONENT_COLUMN); actions_for_component!(Column); diff --git a/pagetop-minimal/src/component/grid/row.rs b/pagetop-minimal/src/component/grid/row.rs index 80112733..ce9def7a 100644 --- a/pagetop-minimal/src/component/grid/row.rs +++ b/pagetop-minimal/src/component/grid/row.rs @@ -2,7 +2,7 @@ use pagetop::prelude::*; use crate::component::grid; -use_handle!(COMPONENT_ROW); +create_handle!(COMPONENT_ROW); actions_for_component!(Row); diff --git a/pagetop-minimal/src/component/heading.rs b/pagetop-minimal/src/component/heading.rs index ca8280f2..4aeab75b 100644 --- a/pagetop-minimal/src/component/heading.rs +++ b/pagetop-minimal/src/component/heading.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_HEADING); +create_handle!(COMPONENT_HEADING); #[derive(Default)] pub enum HeadingType { diff --git a/pagetop-minimal/src/component/icon.rs b/pagetop-minimal/src/component/icon.rs index ca2115c3..f6b162c0 100644 --- a/pagetop-minimal/src/component/icon.rs +++ b/pagetop-minimal/src/component/icon.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_ICON); +create_handle!(COMPONENT_ICON); #[rustfmt::skip] #[derive(Default)] diff --git a/pagetop-minimal/src/component/image.rs b/pagetop-minimal/src/component/image.rs index 0496bfb1..bd1287c5 100644 --- a/pagetop-minimal/src/component/image.rs +++ b/pagetop-minimal/src/component/image.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_IMAGE); +create_handle!(COMPONENT_IMAGE); #[rustfmt::skip] #[derive(Default)] diff --git a/pagetop-minimal/src/component/paragraph.rs b/pagetop-minimal/src/component/paragraph.rs index 25211a08..78f98687 100644 --- a/pagetop-minimal/src/component/paragraph.rs +++ b/pagetop-minimal/src/component/paragraph.rs @@ -1,6 +1,6 @@ use pagetop::prelude::*; -use_handle!(COMPONENT_PARAGRAPH); +create_handle!(COMPONENT_PARAGRAPH); #[derive(Default)] pub enum ParagraphDisplay { diff --git a/pagetop-minimal/src/lib.rs b/pagetop-minimal/src/lib.rs index 19604281..b0d14ac3 100644 --- a/pagetop-minimal/src/lib.rs +++ b/pagetop-minimal/src/lib.rs @@ -3,9 +3,9 @@ use pagetop::prelude::*; pub mod component; pub mod module; -use_handle!(MODULE_MINIMAL); +create_handle!(MODULE_MINIMAL); -use_static!(minimal); +static_files!(minimal); pub struct Minimal; diff --git a/pagetop-minimal/src/module/menu.rs b/pagetop-minimal/src/module/menu.rs index 27107fee..49ed13d7 100644 --- a/pagetop-minimal/src/module/menu.rs +++ b/pagetop-minimal/src/module/menu.rs @@ -1,8 +1,8 @@ use pagetop::prelude::*; -use_handle!(MODULE_MENU); +create_handle!(MODULE_MENU); -use_locale!(LOCALE_MENU in "src/module/menu/locales"); +static_locales!(LOCALES_MENU in "src/module/menu/locales"); pub struct Menu; @@ -12,10 +12,10 @@ impl ModuleTrait for Menu { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_MENU) + L10n::t("module_name", &LOCALES_MENU) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_MENU) + L10n::t("module_description", &LOCALES_MENU) } } diff --git a/pagetop-node/src/lib.rs b/pagetop-node/src/lib.rs index d9490c48..ffe40c72 100644 --- a/pagetop-node/src/lib.rs +++ b/pagetop-node/src/lib.rs @@ -1,8 +1,8 @@ use pagetop::prelude::*; -use_handle!(MODULE_NODE); +create_handle!(MODULE_NODE); -use_locale!(LOCALE_NODE); +static_locales!(LOCALES_NODE); //mod entity; mod migration; @@ -15,11 +15,11 @@ impl ModuleTrait for Node { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_NODE) + L10n::t("module_name", &LOCALES_NODE) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_NODE) + L10n::t("module_description", &LOCALES_NODE) } fn configure_service(&self, cfg: &mut service::web::ServiceConfig) { diff --git a/pagetop-user/src/lib.rs b/pagetop-user/src/lib.rs index 9dfb312c..3b45b3a5 100644 --- a/pagetop-user/src/lib.rs +++ b/pagetop-user/src/lib.rs @@ -1,9 +1,9 @@ use pagetop::prelude::*; use pagetop_minimal::component::*; -use_handle!(MODULE_USER); +create_handle!(MODULE_USER); -use_locale!(LOCALE_USER); +static_locales!(LOCALES_USER); mod migration; @@ -15,11 +15,11 @@ impl ModuleTrait for User { } fn name(&self) -> L10n { - L10n::t("module_name", &LOCALE_USER) + L10n::t("module_name", &LOCALES_USER) } fn description(&self) -> L10n { - L10n::t("module_description", &LOCALE_USER) + L10n::t("module_description", &LOCALES_USER) } fn dependencies(&self) -> Vec { @@ -58,9 +58,9 @@ fn form_login() -> Form { .with_element( form_element::Input::textfield() .with_name("name") - .with_label(L10n::t("username", &LOCALE_USER)) + .with_label(L10n::t("username", &LOCALES_USER)) .with_help_text( - L10n::t("username_help", &LOCALE_USER) + L10n::t("username_help", &LOCALES_USER) .with_arg("app", config::SETTINGS.app.name.to_owned()), ) .with_autofocus(true), @@ -68,8 +68,11 @@ fn form_login() -> Form { .with_element( form_element::Input::password() .with_name("pass") - .with_label(L10n::t("password", &LOCALE_USER)) - .with_help_text(L10n::t("password_help", &LOCALE_USER)), + .with_label(L10n::t("password", &LOCALES_USER)) + .with_help_text(L10n::t("password_help", &LOCALES_USER)), ) - .with_element(form_element::Button::submit(L10n::t("login", &LOCALE_USER))) + .with_element(form_element::Button::submit(L10n::t( + "login", + &LOCALES_USER, + ))) } diff --git a/pagetop/src/core/component.rs b/pagetop/src/core/component.rs index 8247485b..9e0ce62e 100644 --- a/pagetop/src/core/component.rs +++ b/pagetop/src/core/component.rs @@ -28,7 +28,7 @@ macro_rules! actions_for_component { // ACTION BEFORE PREPARE COMPONENT // ************************************************************************************* - $crate::use_handle!([] for Action); + $crate::create_handle!([] for Action); pub struct [] { action: Option<[]>, @@ -87,7 +87,7 @@ macro_rules! actions_for_component { // ACTION AFTER PREPARE COMPONENT // ************************************************************************************* - $crate::use_handle!([] for Action); + $crate::create_handle!([] for Action); pub struct [] { action: Option<[]>, diff --git a/pagetop/src/core/component/html.rs b/pagetop/src/core/component/html.rs index b0af5bc8..8cf0d5a3 100644 --- a/pagetop/src/core/component/html.rs +++ b/pagetop/src/core/component/html.rs @@ -1,8 +1,8 @@ use crate::core::component::{ComponentTrait, Context}; use crate::html::{html, Markup, PrepareMarkup}; -use crate::{fn_builder, use_handle, Handle}; +use crate::{create_handle, fn_builder, Handle}; -use_handle!(COMPONENT_HTML); +create_handle!(COMPONENT_HTML); #[derive(Default)] pub struct Html(Markup); diff --git a/pagetop/src/core/component/l10n.rs b/pagetop/src/core/component/l10n.rs index 1ef93642..5829c943 100644 --- a/pagetop/src/core/component/l10n.rs +++ b/pagetop/src/core/component/l10n.rs @@ -1,11 +1,11 @@ use crate::core::component::{ComponentTrait, Context}; use crate::html::{html, PreEscaped, PrepareMarkup}; use crate::locale::{Loader, Locales}; -use crate::{fn_builder, use_handle, Handle}; +use crate::{create_handle, fn_builder, Handle}; use std::collections::HashMap; -use_handle!(COMPONENT_L10N); +create_handle!(COMPONENT_L10N); #[derive(Default)] pub enum L10nOp { diff --git a/pagetop/src/core/theme/basic.rs b/pagetop/src/core/theme/basic.rs index 0a2091b6..7c196eae 100644 --- a/pagetop/src/core/theme/basic.rs +++ b/pagetop/src/core/theme/basic.rs @@ -4,11 +4,11 @@ use crate::core::theme::{ThemeStaticRef, ThemeTrait}; use crate::html::{Favicon, StyleSheet}; use crate::response::page::Page; use crate::service; -use crate::{serve_static_files, use_handle, use_static, Handle}; +use crate::{create_handle, serve_static_files, static_files, Handle}; -use_handle!(THEME_BASIC); +create_handle!(THEME_BASIC); -use_static!(theme); +static_files!(theme); pub struct Basic; diff --git a/pagetop/src/core/theme/definition.rs b/pagetop/src/core/theme/definition.rs index cb347ef6..1e54e16a 100644 --- a/pagetop/src/core/theme/definition.rs +++ b/pagetop/src/core/theme/definition.rs @@ -3,7 +3,7 @@ use crate::core::component::{ComponentTrait, Context}; use crate::core::module::ModuleTrait; use crate::html::{html, Favicon, Markup}; use crate::response::page::Page; -use crate::{config, LOCALE_PAGETOP}; +use crate::{config, LOCALES_PAGETOP}; pub type ThemeStaticRef = &'static dyn ThemeTrait; @@ -12,11 +12,11 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync { #[rustfmt::skip] fn regions(&self) -> Vec<(&'static str, L10n)> { vec![ - ("header", L10n::t("header", &LOCALE_PAGETOP)), - ("pagetop", L10n::t("pagetop", &LOCALE_PAGETOP)), - ("content", L10n::t("content", &LOCALE_PAGETOP)), - ("sidebar", L10n::t("sidebar", &LOCALE_PAGETOP)), - ("footer", L10n::t("footer", &LOCALE_PAGETOP)), + ("header", L10n::t("header", &LOCALES_PAGETOP)), + ("pagetop", L10n::t("pagetop", &LOCALES_PAGETOP)), + ("content", L10n::t("content", &LOCALES_PAGETOP)), + ("sidebar", L10n::t("sidebar", &LOCALES_PAGETOP)), + ("footer", L10n::t("footer", &LOCALES_PAGETOP)), ] } diff --git a/pagetop/src/lib.rs b/pagetop/src/lib.rs index 2fd99261..a82ef463 100644 --- a/pagetop/src/lib.rs +++ b/pagetop/src/lib.rs @@ -42,7 +42,7 @@ //! ```rust //! use pagetop::prelude::*; //! -//! use_handle!(APP_HELLO_WORLD); +//! create_handle!(APP_HELLO_WORLD); //! //! struct HelloWorld; //! @@ -116,7 +116,7 @@ pub type HashMapResources = std::collections::HashMap<&'static str, StaticResour pub type Handle = u64; -use_locale!(LOCALE_PAGETOP); +static_locales!(LOCALES_PAGETOP); // ************************************************************************************************* // APIs PÚBLICAS. diff --git a/pagetop/src/locale.rs b/pagetop/src/locale.rs index 6e8ee8a8..1490e11e 100644 --- a/pagetop/src/locale.rs +++ b/pagetop/src/locale.rs @@ -70,13 +70,13 @@ //! # Cómo aplicar la localización en tu código //! //! Una vez hayas creado tu directorio de recursos FTL usa la macro -//! [`use_locale!`](crate::use_locale) para integrarlos en tu módulo o aplicación. Si tus recursos -//! se encuentran en el directorio `"src/locale"` bastará con declarar: +//! [`static_locales!`](crate::static_locales) para integrarlos en tu módulo o aplicación. Si tus +//! recursos se encuentran en el directorio `"src/locale"` bastará con declarar: //! //! ``` //! use pagetop::prelude::*; //! -//! use_locale!(LOCALE_SAMPLE); +//! static_locales!(LOCALES_SAMPLE); //! ``` //! //! Y si están en otro directorio, entonces puedes usar: @@ -84,7 +84,7 @@ //! ``` //! use pagetop::prelude::*; //! -//! use_locale!(LOCALE_SAMPLE in "path/to/locale"); +//! static_locales!(LOCALES_SAMPLE in "path/to/locale"); //! ``` //! //! Usa el componente [L10n](crate::core::component::l10n::L10n) para incluir textos y contenidos diff --git a/pagetop/src/prelude.rs b/pagetop/src/prelude.rs index b6bd2924..a3fd2241 100644 --- a/pagetop/src/prelude.rs +++ b/pagetop/src/prelude.rs @@ -8,7 +8,8 @@ pub use crate::{ // Funciones y macros útiles. pub use crate::util; pub use crate::{action, actions_for_component}; -pub use crate::{default_settings, kv, serve_static_files, use_handle, use_locale, use_static}; +pub use crate::{create_handle, default_settings, kv}; +pub use crate::{serve_static_files, static_files, static_locales}; // ************************************************************************************************* diff --git a/pagetop/src/response/fatal_error/error403.rs b/pagetop/src/response/fatal_error/error403.rs index a3eb8c75..376234c2 100644 --- a/pagetop/src/response/fatal_error/error403.rs +++ b/pagetop/src/response/fatal_error/error403.rs @@ -1,8 +1,8 @@ use crate::core::component::{ComponentTrait, Context}; use crate::html::{html, PrepareMarkup}; -use crate::{use_handle, Handle}; +use crate::{create_handle, Handle}; -use_handle!(ERROR_403); +create_handle!(ERROR_403); pub struct Error403; diff --git a/pagetop/src/response/fatal_error/error404.rs b/pagetop/src/response/fatal_error/error404.rs index 40acf80d..c9c9051d 100644 --- a/pagetop/src/response/fatal_error/error404.rs +++ b/pagetop/src/response/fatal_error/error404.rs @@ -1,8 +1,8 @@ use crate::core::component::{ComponentTrait, Context}; use crate::html::{html, PrepareMarkup}; -use crate::{use_handle, Handle}; +use crate::{create_handle, Handle}; -use_handle!(ERROR_404); +create_handle!(ERROR_404); pub struct Error404; diff --git a/pagetop/src/response/page/action/after_prepare_body.rs b/pagetop/src/response/page/action/after_prepare_body.rs index f745e4fa..941d6f52 100644 --- a/pagetop/src/response/page/action/after_prepare_body.rs +++ b/pagetop/src/response/page/action/after_prepare_body.rs @@ -1,9 +1,9 @@ use crate::core::action::{action_ref, run_actions, ActionTrait}; use crate::response::page::action::ActionPage; use crate::response::page::Page; -use crate::{use_handle, Handle}; +use crate::{create_handle, Handle}; -use_handle!(ACTION_AFTER_PREPARE_BODY for Action); +create_handle!(ACTION_AFTER_PREPARE_BODY for Action); pub struct ActionAfterPrepareBody { action: Option, diff --git a/pagetop/src/response/page/action/before_prepare_body.rs b/pagetop/src/response/page/action/before_prepare_body.rs index ef1d938d..8971e51a 100644 --- a/pagetop/src/response/page/action/before_prepare_body.rs +++ b/pagetop/src/response/page/action/before_prepare_body.rs @@ -1,9 +1,9 @@ use crate::core::action::{action_ref, run_actions, ActionTrait}; use crate::response::page::action::ActionPage; use crate::response::page::Page; -use crate::{use_handle, Handle}; +use crate::{create_handle, Handle}; -use_handle!(ACTION_BEFORE_PREPARE_BODY for Action); +create_handle!(ACTION_BEFORE_PREPARE_BODY for Action); pub struct ActionBeforePrepareBody { action: Option, diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index 06f70f16..e2c47536 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -89,8 +89,8 @@ macro_rules! kv { macro_rules! default_settings { ( $($key:literal => $value:literal),* $(,)? ) => { #[doc = concat!( - "Assigned or predefined values for configuration settings associated with the ", - "[`Settings`] structure." + "Assigned or predefined values for configuration settings associated to the ", + "[`Settings`] type." )] pub static SETTINGS: $crate::LazyStatic = $crate::LazyStatic::new(|| { let mut settings = $crate::config::CONFIG.clone(); @@ -106,7 +106,7 @@ macro_rules! default_settings { } #[macro_export] -macro_rules! use_handle { +macro_rules! create_handle { ( $HANDLE:ident ) => { /// Public constant handle to represent a unique PageTop building element. pub const $HANDLE: $crate::Handle = @@ -121,7 +121,7 @@ macro_rules! use_handle { #[macro_export] /// Define un conjunto de elementos de localización y funciones locales de traducción. -macro_rules! use_locale { +macro_rules! static_locales { ( $LOCALES:ident $(, $core_locales:literal)? ) => { use $crate::locale::*; @@ -153,21 +153,21 @@ macro_rules! use_locale { } #[macro_export] -macro_rules! use_static { +macro_rules! static_files { ( $bundle:ident ) => { $crate::paste! { - mod [] { + mod [] { include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); } } }; ( $bundle:ident => $STATIC:ident ) => { $crate::paste! { - mod [] { + mod [] { include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs")); } static $STATIC: LazyStatic = LazyStatic::new([ - ]::$bundle + ]::$bundle ); } }; @@ -181,7 +181,7 @@ macro_rules! serve_static_files { if static_files.is_empty() { $cfg.service($crate::service::ResourceFiles::new( $path, - []::$bundle(), + []::$bundle(), )); } else { $cfg.service(