🎨 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::*;
|
||||
|
||||
pub_const_handler!(APP_DRUST);
|
||||
pub_handle!(APP_DRUST);
|
||||
|
||||
struct Drust;
|
||||
|
||||
impl ModuleTrait for Drust {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
APP_DRUST
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub_const_handler!(MODULE_ADMIN);
|
||||
pub_handle!(MODULE_ADMIN);
|
||||
|
||||
localize!("src/locales");
|
||||
pub_locale!("src/locales");
|
||||
|
||||
mod summary;
|
||||
|
||||
pub struct Admin;
|
||||
|
||||
impl ModuleTrait for Admin {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
MODULE_ADMIN
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub_const_handler!(MODULE_NODE);
|
||||
pub_handle!(MODULE_NODE);
|
||||
|
||||
localize!("src/locales");
|
||||
pub_locale!("src/locales");
|
||||
|
||||
//mod entity;
|
||||
mod migration;
|
||||
|
|
@ -10,7 +10,7 @@ mod migration;
|
|||
pub struct Node;
|
||||
|
||||
impl ModuleTrait for Node {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
MODULE_NODE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub_const_handler!(MODULE_USER);
|
||||
pub_handle!(MODULE_USER);
|
||||
|
||||
localize!("src/locales");
|
||||
pub_locale!("src/locales");
|
||||
|
||||
mod migration;
|
||||
|
||||
pub struct User;
|
||||
|
||||
impl ModuleTrait for User {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
MODULE_USER
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_ANCHOR);
|
||||
pub_handle!(COMPONENT_ANCHOR);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum AnchorType {
|
||||
|
|
@ -43,7 +43,7 @@ impl ComponentTrait for Anchor {
|
|||
Anchor::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_ANCHOR
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_BLOCK);
|
||||
pub_handle!(COMPONENT_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")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_BLOCK
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_CONTAINER);
|
||||
pub_handle!(COMPONENT_CONTAINER);
|
||||
|
||||
hook_before_render_component!(HOOK_BEFORE_RENDER_CONTAINER, Container);
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ impl ComponentTrait for Container {
|
|||
.with_inner_classes(ClassesOp::SetDefault, "container")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_CONTAINER
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_BUTTON);
|
||||
pub_handle!(COMPONENT_BUTTON);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum ButtonType {
|
||||
|
|
@ -31,7 +31,7 @@ impl ComponentTrait for Button {
|
|||
.with_classes(ClassesOp::AddFirst, "form-button")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_BUTTON
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_DATE);
|
||||
pub_handle!(COMPONENT_DATE);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -28,7 +28,7 @@ impl ComponentTrait for Date {
|
|||
.with_classes(ClassesOp::AddFirst, "form-type-date")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_DATE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_FORM);
|
||||
pub_handle!(COMPONENT_FORM);
|
||||
|
||||
hook_before_render_component!(HOOK_BEFORE_RENDER_FORM, Form);
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ impl ComponentTrait for Form {
|
|||
.with_charset("UTF-8")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_FORM
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_HIDDEN);
|
||||
pub_handle!(COMPONENT_HIDDEN);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -15,7 +15,7 @@ impl ComponentTrait for Hidden {
|
|||
Hidden::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_HIDDEN
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_INPUT);
|
||||
pub_handle!(COMPONENT_INPUT);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum InputType {
|
||||
|
|
@ -45,7 +45,7 @@ impl ComponentTrait for Input {
|
|||
.with_maxlength(Some(128))
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_INPUT
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_COLUMN);
|
||||
pub_handle!(COMPONENT_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)
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_COLUMN
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_ROW);
|
||||
pub_handle!(COMPONENT_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")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_ROW
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_HEADING);
|
||||
pub_handle!(COMPONENT_HEADING);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum HeadingType {
|
||||
|
|
@ -43,7 +43,7 @@ impl ComponentTrait for Heading {
|
|||
Heading::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_HEADING
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_HTML);
|
||||
pub_handle!(COMPONENT_HTML);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -16,7 +16,7 @@ impl ComponentTrait for Html {
|
|||
Html::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_HTML
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_ICON);
|
||||
pub_handle!(COMPONENT_ICON);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -16,7 +16,7 @@ impl ComponentTrait for Icon {
|
|||
Icon::default().with_classes(ClassesOp::SetDefault, "bi-question-circle-fill")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_ICON
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_IMAGE);
|
||||
pub_handle!(COMPONENT_IMAGE);
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(Default)]
|
||||
|
|
@ -18,7 +18,7 @@ impl ComponentTrait for Image {
|
|||
Image::default().with_classes(ClassesOp::SetDefault, "img-fluid")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_IMAGE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_MENUITEM);
|
||||
pub_handle!(COMPONENT_MENUITEM);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum MenuItemType {
|
||||
|
|
@ -29,7 +29,7 @@ impl ComponentTrait for MenuItem {
|
|||
MenuItem::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_MENUITEM
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ impl MenuItem {
|
|||
|
||||
// Menu.
|
||||
|
||||
pub_const_handler!(COMPONENT_MENU);
|
||||
pub_handle!(COMPONENT_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")
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_MENU
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(COMPONENT_PARAGRAPH);
|
||||
pub_handle!(COMPONENT_PARAGRAPH);
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum ParagraphDisplay {
|
||||
|
|
@ -30,7 +30,7 @@ impl ComponentTrait for Paragraph {
|
|||
Paragraph::default()
|
||||
}
|
||||
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
COMPONENT_PARAGRAPH
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
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;
|
||||
|
||||
impl ModuleTrait for DefaultHomePage {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
MODULE_DEFAULT_HOMEPAGE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(THEME_ALINER);
|
||||
pub_handle!(THEME_ALINER);
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
|
||||
|
||||
pub struct Aliner;
|
||||
|
||||
impl ThemeTrait for Aliner {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
THEME_ALINER
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
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"));
|
||||
|
||||
localize!("src/base/theme/bootsier/locales");
|
||||
|
||||
pub struct Bootsier;
|
||||
|
||||
impl ThemeTrait for Bootsier {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
THEME_BOOTSIER
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(THEME_BULMIX);
|
||||
pub_handle!(THEME_BULMIX);
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
|
||||
|
||||
pub struct Bulmix;
|
||||
|
||||
impl ThemeTrait for Bulmix {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
THEME_BULMIX
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ impl ThemeTrait for Bulmix {
|
|||
component: &mut dyn ComponentTrait,
|
||||
_context: &mut PageContext,
|
||||
) {
|
||||
match component.handler() {
|
||||
match component.handle() {
|
||||
COMPONENT_ANCHOR => {
|
||||
let a = component_mut::<Anchor>(component);
|
||||
a.alter_classes(
|
||||
|
|
@ -112,7 +112,7 @@ impl ThemeTrait for Bulmix {
|
|||
component: &dyn ComponentTrait,
|
||||
_context: &mut PageContext,
|
||||
) -> Option<Markup> {
|
||||
match component.handler() {
|
||||
match component.handle() {
|
||||
COMPONENT_ICON => {
|
||||
let icon = component_ref::<Icon>(component);
|
||||
Some(html! {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub_const_handler!(THEME_MINIMAL);
|
||||
pub_handle!(THEME_MINIMAL);
|
||||
|
||||
pub struct Minimal;
|
||||
|
||||
impl ThemeTrait for Minimal {
|
||||
fn handler(&self) -> Handler {
|
||||
fn handle(&self) -> Handle {
|
||||
THEME_MINIMAL
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::html::{html, Markup};
|
||||
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;
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ pub trait ComponentTrait: AnyComponent + BaseComponent + Send + Sync {
|
|||
where
|
||||
Self: Sized;
|
||||
|
||||
fn handler(&self) -> Handler;
|
||||
fn handle(&self) -> Handle;
|
||||
|
||||
fn name(&self) -> String {
|
||||
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 {
|
||||
( $ACTION_HANDLER:ident, $Component:ty ) => {
|
||||
paste::paste! {
|
||||
$crate::pub_const_handler!($ACTION_HANDLER);
|
||||
$crate::pub_handle!($ACTION_HANDLER);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
use super::{ActionsHolder, HookAction};
|
||||
use crate::util::Handler;
|
||||
use crate::util::Handle;
|
||||
use crate::LazyStatic;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::RwLock;
|
||||
|
||||
// Registered actions.
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handler, ActionsHolder>>> =
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handle, ActionsHolder>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
pub fn add_action(action: HookAction) {
|
||||
let mut actions = ACTIONS.write().unwrap();
|
||||
let action_handler = action.handler();
|
||||
if let Some(holder) = actions.get_mut(&action_handler) {
|
||||
let action_handle = action.handle();
|
||||
if let Some(holder) = actions.get_mut(&action_handle) {
|
||||
holder.add(action);
|
||||
} 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
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::util::Handler;
|
||||
use crate::util::Handle;
|
||||
|
||||
pub use std::any::Any as AnyHookAction;
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ pub trait HookActionTrait: AnyHookAction + Send + Sync {
|
|||
where
|
||||
Self: Sized;
|
||||
|
||||
fn handler(&self) -> Handler;
|
||||
fn handle(&self) -> Handle;
|
||||
|
||||
fn weight(&self) -> isize {
|
||||
0
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub fn register_modules(app: ModuleStaticRef) {
|
|||
|
||||
fn add_to_discarded(list: &mut Vec<ModuleStaticRef>, module: ModuleStaticRef) {
|
||||
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);
|
||||
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) {
|
||||
if !list.iter().any(|m| m.handler() == module.handler()) {
|
||||
if !list.iter().any(|m| m.handle() == module.handle()) {
|
||||
if DISCARDED_MODULES
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.any(|m| m.handler() == module.handler())
|
||||
.any(|m| m.handle() == module.handle())
|
||||
{
|
||||
panic!(
|
||||
"Trying to enable \"{}\" module which is disabled",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::app;
|
||||
use crate::core::hook::HookAction;
|
||||
use crate::core::theme::ThemeStaticRef;
|
||||
use crate::util::{single_type_name, Handler};
|
||||
use crate::util::{single_type_name, Handle};
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use crate::db::MigrationItem;
|
||||
|
|
@ -14,7 +14,7 @@ pub trait BaseModule {
|
|||
|
||||
/// Los módulos deben implementar este *trait*.
|
||||
pub trait ModuleTrait: BaseModule + Send + Sync {
|
||||
fn handler(&self) -> Handler;
|
||||
fn handle(&self) -> Handle;
|
||||
|
||||
fn name(&self) -> String {
|
||||
self.single_name().to_owned()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub fn register_themes(themes: Vec<ThemeStaticRef>) {
|
|||
for theme in themes {
|
||||
if !registered_themes
|
||||
.iter()
|
||||
.any(|t| t.handler() == theme.handler())
|
||||
.any(|t| t.handle() == theme.handle())
|
||||
{
|
||||
trace::debug!("Registering theme \"{}\"", theme.single_name());
|
||||
registered_themes.push(theme);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::concat_string;
|
|||
use crate::core::component::ComponentTrait;
|
||||
use crate::html::{html, Favicon, Markup};
|
||||
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;
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ pub trait BaseTheme {
|
|||
|
||||
/// Los temas deben implementar este "trait".
|
||||
pub trait ThemeTrait: BaseTheme + Send + Sync {
|
||||
fn handler(&self) -> Handler;
|
||||
fn handle(&self) -> Handle;
|
||||
|
||||
fn name(&self) -> String {
|
||||
self.single_name().to_owned()
|
||||
|
|
@ -91,7 +91,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
|||
/*
|
||||
Cómo usarlo:
|
||||
|
||||
match component.handler() {
|
||||
match component.handle() {
|
||||
BLOCK_COMPONENT => {
|
||||
let block = component_mut::<Block>(component);
|
||||
block.alter_title("New title");
|
||||
|
|
@ -111,7 +111,7 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
|||
/*
|
||||
Cómo usarlo:
|
||||
|
||||
match component.handler() {
|
||||
match component.handle() {
|
||||
BLOCK_COMPONENT => {
|
||||
let block = component_ref::<Block>(component);
|
||||
match block.template() {
|
||||
|
|
|
|||
|
|
@ -69,16 +69,16 @@
|
|||
//! # 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
|
||||
//! [`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
|
||||
//! traducciones directas de etiquetas. Y por otro la función `t()` para traducciones que requieren
|
||||
//! argumentos:
|
||||
//!
|
||||
//! ```
|
||||
//! use pagetop::{args, localize};
|
||||
//! use pagetop::{args, pub_locale};
|
||||
//!
|
||||
//! localize!("en-US");
|
||||
//! pub_locale!("en-US");
|
||||
//!
|
||||
//! fn demo() {
|
||||
//! println!("* {}", l("hello-world"));
|
||||
|
|
@ -100,7 +100,7 @@ pub use fluent_templates::{static_loader as static_locale, Loader as Locale};
|
|||
|
||||
#[macro_export]
|
||||
/// 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)? ) => {
|
||||
use $crate::locale::*;
|
||||
use $crate::app::locale::LANGID;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
pub use crate::{concat_string, LazyStatic};
|
||||
|
||||
// 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.
|
||||
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::localize;
|
||||
|
||||
pub use crate::html::*;
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use super::Page;
|
||||
use crate::core::hook::{AnyHookAction, HookActionTrait};
|
||||
use crate::pub_const_handler;
|
||||
use crate::util::Handler;
|
||||
use crate::pub_handle;
|
||||
use crate::util::Handle;
|
||||
|
||||
pub_const_handler!(HOOK_BEFORE_RENDER_PAGE);
|
||||
pub_handle!(HOOK_BEFORE_RENDER_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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,15 +87,15 @@ pub fn bundle_resources(
|
|||
bundle.build()
|
||||
}
|
||||
|
||||
pub type Handler = u64;
|
||||
pub type Handle = u64;
|
||||
|
||||
// https://stackoverflow.com/a/71464396
|
||||
pub const fn handler(
|
||||
pub const fn handle(
|
||||
module_path: &'static str,
|
||||
file: &'static str,
|
||||
line: u32,
|
||||
column: u32,
|
||||
) -> Handler {
|
||||
) -> Handle {
|
||||
let mut hash = 0xcbf29ce484222325;
|
||||
let prime = 0x00000100000001B3;
|
||||
|
||||
|
|
@ -124,10 +124,10 @@ pub const fn handler(
|
|||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! pub_const_handler {
|
||||
( $HANDLER:ident ) => {
|
||||
pub const $HANDLER: $crate::util::Handler =
|
||||
$crate::util::handler(module_path!(), file!(), line!(), column!());
|
||||
macro_rules! pub_handle {
|
||||
( $HANDLE:ident ) => {
|
||||
pub const $HANDLE: $crate::util::Handle =
|
||||
$crate::util::handle(module_path!(), file!(), line!(), column!());
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue