🚧 Revisa macros externas al core
This commit is contained in:
parent
ab795d17ff
commit
0a7f756709
4 changed files with 29 additions and 28 deletions
|
|
@ -2,7 +2,7 @@ use pagetop::prelude::*;
|
||||||
|
|
||||||
use_handle!(MODULE_MENU);
|
use_handle!(MODULE_MENU);
|
||||||
|
|
||||||
use_locale!(LOCALE_MENU["src/module/menu/locales"]);
|
use_locale!(LOCALE_MENU in "src/module/menu/locales");
|
||||||
|
|
||||||
pub struct Menu;
|
pub struct Menu;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ mod path;
|
||||||
mod source;
|
mod source;
|
||||||
mod value;
|
mod value;
|
||||||
|
|
||||||
|
use crate::default_settings;
|
||||||
use crate::LazyStatic;
|
use crate::LazyStatic;
|
||||||
|
|
||||||
use crate::config::data::ConfigData;
|
use crate::config::data::ConfigData;
|
||||||
|
|
@ -158,31 +159,6 @@ pub static CONFIG: LazyStatic<ConfigData> = LazyStatic::new(|| {
|
||||||
settings
|
settings
|
||||||
});
|
});
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
/// Define un conjunto de ajustes de configuración usando tipos seguros y valores predefinidos.
|
|
||||||
///
|
|
||||||
/// Detiene la aplicación con un panic! si no pueden asignarse los ajustes de configuración.
|
|
||||||
///
|
|
||||||
/// Ver [`Cómo añadir ajustes de configuración`](config/index.html#cómo-añadir-ajustes-de-configuración).
|
|
||||||
macro_rules! default_settings {
|
|
||||||
( $($key:literal => $value:literal),* $(,)? ) => {
|
|
||||||
#[doc = concat!(
|
|
||||||
"Assigned or predefined values for configuration settings associated with the ",
|
|
||||||
"[`Settings`] structure."
|
|
||||||
)]
|
|
||||||
pub static SETTINGS: $crate::LazyStatic<Settings> = $crate::LazyStatic::new(|| {
|
|
||||||
let mut settings = $crate::config::CONFIG.clone();
|
|
||||||
$(
|
|
||||||
settings.set_default($key, $value).unwrap();
|
|
||||||
)*
|
|
||||||
match settings.try_into() {
|
|
||||||
Ok(s) => s,
|
|
||||||
Err(e) => panic!("Error parsing settings: {}", e),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
/// Configuration settings for the [`[app]`](App), [`[database]`](Database), [`[dev]`](Dev),
|
/// Configuration settings for the [`[app]`](App), [`[database]`](Database), [`[dev]`](Dev),
|
||||||
/// [`[log]`](Log), and [`[server]`](Server) sections (see [`SETTINGS`]).
|
/// [`[log]`](Log), and [`[server]`](Server) sections (see [`SETTINGS`]).
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//! use pagetop::prelude::*;
|
//! use pagetop::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! use_locale!(LOCALE_SAMPLE["path/to/locale"]);
|
//! use_locale!(LOCALE_SAMPLE in "path/to/locale");
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Usa el componente [L10n](crate::core::component::l10n::L10n) para incluir textos y contenidos
|
//! Usa el componente [L10n](crate::core::component::l10n::L10n) para incluir textos y contenidos
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,31 @@ macro_rules! kv {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
/// Define un conjunto de ajustes de configuración usando tipos seguros y valores predefinidos.
|
||||||
|
///
|
||||||
|
/// Detiene la aplicación con un panic! si no pueden asignarse los ajustes de configuración.
|
||||||
|
///
|
||||||
|
/// Ver [`Cómo añadir ajustes de configuración`](config/index.html#cómo-añadir-ajustes-de-configuración).
|
||||||
|
macro_rules! default_settings {
|
||||||
|
( $($key:literal => $value:literal),* $(,)? ) => {
|
||||||
|
#[doc = concat!(
|
||||||
|
"Assigned or predefined values for configuration settings associated with the ",
|
||||||
|
"[`Settings`] structure."
|
||||||
|
)]
|
||||||
|
pub static SETTINGS: $crate::LazyStatic<Settings> = $crate::LazyStatic::new(|| {
|
||||||
|
let mut settings = $crate::config::CONFIG.clone();
|
||||||
|
$(
|
||||||
|
settings.set_default($key, $value).unwrap();
|
||||||
|
)*
|
||||||
|
match settings.try_into() {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(e) => panic!("Error parsing settings: {}", e),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! use_handle {
|
macro_rules! use_handle {
|
||||||
( $HANDLE:ident ) => {
|
( $HANDLE:ident ) => {
|
||||||
|
|
@ -111,7 +136,7 @@ macro_rules! use_locale {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
( $LOCALES:ident[$dir_locales:literal] $(, $core_locales:literal)? ) => {
|
( $LOCALES:ident in $dir_locales:literal $(, $core_locales:literal)? ) => {
|
||||||
use $crate::locale::*;
|
use $crate::locale::*;
|
||||||
|
|
||||||
fluent_templates::static_loader! {
|
fluent_templates::static_loader! {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue