💥 Better names for main macros

This commit is contained in:
Manuel Cillero 2023-07-15 11:34:28 +02:00
parent eee481cfcb
commit 6df57a0c12
44 changed files with 146 additions and 140 deletions

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(APP_DRUST);
create_handle!(APP_DRUST);
struct Drust;

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(APP_HELLO_NAME);
create_handle!(APP_HELLO_NAME);
struct HelloName;

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(APP_HELLO_WORLD);
create_handle!(APP_HELLO_WORLD);
struct HelloWorld;

View file

@ -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]

View file

@ -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<Markup, FatalError> {
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",

View file

@ -1,8 +1,8 @@
use pagetop::prelude::*;
use_handle!(THEME_ALINER);
create_handle!(THEME_ALINER);
use_static!(aliner);
static_files!(aliner);
pub struct Aliner;

View file

@ -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))
}
}
}

View file

@ -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.

View file

@ -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;

View file

@ -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<ModuleStaticRef> {
@ -34,7 +34,7 @@ impl ModuleTrait for HomeDemo {
async fn demo(request: service::HttpRequest) -> ResultPage<Markup, FatalError> {
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!(
"<span class=\"app-name\">{}</span>",
@ -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!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
@ -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!(
"<span class=\"app-name\">{}</span>",
@ -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!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"https://crates.io/crates/pagetop", "PageTop",
Paragraph::with(
L10n::e("pagetop_promo_text1", &LOCALES_HOMEDEMO).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
"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,
))),
),
)

View file

@ -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<Action> {

View file

@ -1,7 +1,7 @@
use pagetop::prelude::*;
use pagetop_jquery::JQuery;
use_handle!(COMPONENT_MEGAMENUITEM);
create_handle!(COMPONENT_MEGAMENUITEM);
type Label = OneComponent<L10n>;
type Content = OneComponent<L10n>;
@ -144,7 +144,7 @@ impl MegaMenuItem {
// MegaMenu.
use_handle!(COMPONENT_MEGAMENU);
create_handle!(COMPONENT_MEGAMENU);
actions_for_component!(MegaMenu);

View file

@ -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;

View file

@ -2,7 +2,7 @@ use pagetop::prelude::*;
use crate::component::Icon;
use_handle!(COMPONENT_ANCHOR);
create_handle!(COMPONENT_ANCHOR);
#[derive(Default)]
pub enum AnchorType {

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_BLOCK);
create_handle!(COMPONENT_BLOCK);
actions_for_component!(Block);

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_CONTAINER);
create_handle!(COMPONENT_CONTAINER);
actions_for_component!(Container);

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_BUTTON);
create_handle!(COMPONENT_BUTTON);
#[derive(Default)]
pub enum ButtonType {

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_DATE);
create_handle!(COMPONENT_DATE);
#[rustfmt::skip]
#[derive(Default)]

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_FORM);
create_handle!(COMPONENT_FORM);
actions_for_component!(Form);

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_HIDDEN);
create_handle!(COMPONENT_HIDDEN);
#[rustfmt::skip]
#[derive(Default)]

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_INPUT);
create_handle!(COMPONENT_INPUT);
#[derive(Default)]
pub enum InputType {

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_COLUMN);
create_handle!(COMPONENT_COLUMN);
actions_for_component!(Column);

View file

@ -2,7 +2,7 @@ use pagetop::prelude::*;
use crate::component::grid;
use_handle!(COMPONENT_ROW);
create_handle!(COMPONENT_ROW);
actions_for_component!(Row);

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_HEADING);
create_handle!(COMPONENT_HEADING);
#[derive(Default)]
pub enum HeadingType {

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_ICON);
create_handle!(COMPONENT_ICON);
#[rustfmt::skip]
#[derive(Default)]

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_IMAGE);
create_handle!(COMPONENT_IMAGE);
#[rustfmt::skip]
#[derive(Default)]

View file

@ -1,6 +1,6 @@
use pagetop::prelude::*;
use_handle!(COMPONENT_PARAGRAPH);
create_handle!(COMPONENT_PARAGRAPH);
#[derive(Default)]
pub enum ParagraphDisplay {

View file

@ -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;

View file

@ -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)
}
}

View file

@ -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) {

View file

@ -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<ModuleStaticRef> {
@ -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,
)))
}

View file

@ -28,7 +28,7 @@ macro_rules! actions_for_component {
// ACTION BEFORE PREPARE COMPONENT
// *************************************************************************************
$crate::use_handle!([<ACTION_BEFORE_PREPARE_ $Component:upper>] for Action);
$crate::create_handle!([<ACTION_BEFORE_PREPARE_ $Component:upper>] for Action);
pub struct [<BeforePrepare $Component>] {
action: Option<[<Action $Component>]>,
@ -87,7 +87,7 @@ macro_rules! actions_for_component {
// ACTION AFTER PREPARE COMPONENT
// *************************************************************************************
$crate::use_handle!([<ACTION_AFTER_PREPARE_ $Component:upper>] for Action);
$crate::create_handle!([<ACTION_AFTER_PREPARE_ $Component:upper>] for Action);
pub struct [<AfterPrepare $Component>] {
action: Option<[<Action $Component>]>,

View file

@ -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);

View file

@ -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 {

View file

@ -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;

View file

@ -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)),
]
}

View file

@ -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.

View file

@ -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

View file

@ -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};
// *************************************************************************************************

View file

@ -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;

View file

@ -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;

View file

@ -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<ActionPage>,

View file

@ -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<ActionPage>,

View file

@ -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<Settings> = $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 [<static_bundle_ $bundle>] {
mod [<static_files_ $bundle>] {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
}
}
};
( $bundle:ident => $STATIC:ident ) => {
$crate::paste! {
mod [<static_bundle_ $bundle>] {
mod [<static_files_ $bundle>] {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
}
static $STATIC: LazyStatic<HashMapResources> = LazyStatic::new([
<static_bundle_ $bundle>]::$bundle
<static_files_ $bundle>]::$bundle
);
}
};
@ -181,7 +181,7 @@ macro_rules! serve_static_files {
if static_files.is_empty() {
$cfg.service($crate::service::ResourceFiles::new(
$path,
[<static_bundle_ $bundle>]::$bundle(),
[<static_files_ $bundle>]::$bundle(),
));
} else {
$cfg.service(