Actualiza el código para las nuevas denominaciones

This commit is contained in:
Manuel Cillero 2022-05-02 12:30:30 +02:00
parent 16996eeee0
commit a8cb7f0d29
38 changed files with 123 additions and 139 deletions

View file

@ -1,9 +1,9 @@
use pagetop::prelude::*; use pagetop::prelude::*;
fn bootstrap() { fn bootstrap() {
register_module(&pagetop_admin::AdminModule); register_module(&pagetop_admin::Admin);
register_module(&pagetop_user::UserModule); register_module(&pagetop_user::User);
register_module(&pagetop_node::NodeModule); register_module(&pagetop_node::Node);
} }
#[actix_web::main] #[actix_web::main]

View file

@ -4,15 +4,11 @@ localize!("src/locales");
mod summary; mod summary;
pub struct AdminModule; pub struct Admin;
impl ModuleTrait for AdminModule { impl ModuleTrait for Admin {
fn name(&self) -> &'static str { fn name(&self) -> String {
"Admin" l("module_name")
}
fn fullname(&self) -> String {
l("module_fullname")
} }
fn description(&self) -> Option<String> { fn description(&self) -> Option<String> {

View file

@ -1,2 +1,2 @@
module_fullname = Admin module module_name = Admin module
module_description = Administration module. module_description = Administration module.

View file

@ -1,2 +1,2 @@
module_fullname = Admin module module_name = Admin module
module_description = Módulo de administración. module_description = Módulo de administración.

View file

@ -3,7 +3,7 @@ use super::l;
pub async fn summary() -> app::Result<Markup> { pub async fn summary() -> app::Result<Markup> {
let top_menu = Menu::new() let top_menu = Menu::new()
.add(MenuItem::label(l("module_fullname").as_str())) .add(MenuItem::label(l("module_name").as_str()))
.add(MenuItem::link("Opción 2", "https://www.google.es")) .add(MenuItem::link("Opción 2", "https://www.google.es"))
.add(MenuItem::link_blank("Opción 3", "https://www.google.es")) .add(MenuItem::link_blank("Opción 3", "https://www.google.es"))
.add(MenuItem::submenu("Submenú 1", Menu::new() .add(MenuItem::submenu("Submenú 1", Menu::new()

View file

@ -5,15 +5,11 @@ localize!("src/locales");
//mod entity; //mod entity;
mod migration; mod migration;
pub struct NodeModule; pub struct Node;
impl ModuleTrait for NodeModule { impl ModuleTrait for Node {
fn name(&self) -> &'static str { fn name(&self) -> String {
"Node" l("module_name")
}
fn fullname(&self) -> String {
l("module_fullname")
} }
fn description(&self) -> Option<String> { fn description(&self) -> Option<String> {

View file

@ -1,2 +1,2 @@
module_fullname = Node module_name = Node
module_description = Allows content to be submitted to the site and displayed on pages. module_description = Allows content to be submitted to the site and displayed on pages.

View file

@ -1,2 +1,2 @@
module_fullname = Nodo module_name = Nodo
module_description = Permite enviar contenidos al sitio y mostrarlos en páginas. module_description = Permite enviar contenidos al sitio y mostrarlos en páginas.

View file

@ -4,15 +4,11 @@ localize!("src/locales");
mod migration; mod migration;
pub struct UserModule; pub struct User;
impl ModuleTrait for UserModule { impl ModuleTrait for User {
fn name(&self) -> &'static str { fn name(&self) -> String {
"User" l("module_name")
}
fn fullname(&self) -> String {
l("module_fullname")
} }
fn description(&self) -> Option<String> { fn description(&self) -> Option<String> {

View file

@ -1,4 +1,4 @@
module_fullname = User module_name = User
module_description = Manages the user registration and login system. module_description = Manages the user registration and login system.
username = User name username = User name

View file

@ -1,4 +1,4 @@
module_fullname = Usuario module_name = Usuario
module_description = Gestiona el registro de usuarios y el sistema de accesos. module_description = Gestiona el registro de usuarios y el sistema de accesos.
username = Nombre de usuario username = Nombre de usuario

View file

@ -28,10 +28,10 @@ impl Application {
Lazy::force(&app::db::DBCONN); Lazy::force(&app::db::DBCONN);
// Registra los temas predeterminados. // Registra los temas predeterminados.
theme::register_theme(&base::theme::aliner::AlinerTheme); theme::register_theme(&base::theme::aliner::Aliner);
theme::register_theme(&base::theme::minimal::MinimalTheme); theme::register_theme(&base::theme::minimal::Minimal);
theme::register_theme(&base::theme::bootsier::BootsierTheme); theme::register_theme(&base::theme::bootsier::Bootsier);
theme::register_theme(&base::theme::bulmix::BulmixTheme); theme::register_theme(&base::theme::bulmix::Bulmix);
// Ejecuta la función de inicio de la aplicación. // Ejecuta la función de inicio de la aplicación.
trace::info!("Calling application bootstrap"); trace::info!("Calling application bootstrap");
@ -39,7 +39,7 @@ impl Application {
// Registra el módulo de presentación de PageTop. // Registra el módulo de presentación de PageTop.
// Normalmente se sobrecargará en la función de inicio. // Normalmente se sobrecargará en la función de inicio.
module::register_module(&base::module::demopage::DemopageModule); module::register_module(&base::module::demopage::Demopage);
// Actualizaciones pendientes de la base de datos (opcional). // Actualizaciones pendientes de la base de datos (opcional).
#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))]

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_BLOCK: &str = "pagetop::base::component::block::Block";
pub struct Block { pub struct Block {
renderable: fn() -> bool, renderable: fn() -> bool,
weight : i8, weight : i8,
@ -32,7 +34,7 @@ impl ComponentTrait for Block {
} }
fn default_render(&self, assets: &mut PageAssets) -> Markup { fn default_render(&self, assets: &mut PageAssets) -> Markup {
let id = assets.serial_id(self.name(), self.id()); let id = assets.serial_id(self.single_name(), self.id());
html! { html! {
div id=(id) class=[self.classes()] { div id=(id) class=[self.classes()] {
@match self.title() { @match self.title() {

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_CHUNCK: &str = "pagetop::base::component::chunck::Chunck";
pub struct Chunck { pub struct Chunck {
renderable: fn() -> bool, renderable: fn() -> bool,
weight : i8, weight : i8,

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_CONTAINER: &str = "pagetop::base::component::container::Container";
pub enum ContainerType { Header, Footer, Main, Section, Wrapper } pub enum ContainerType { Header, Footer, Main, Section, Wrapper }
pub struct Container { pub struct Container {

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_BUTTON: &str = "pagetop::base::component::form::button::Button";
pub enum ButtonType {Button, Reset, Submit} pub enum ButtonType {Button, Reset, Submit}
pub struct Button { pub struct Button {

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_DATE: &str = "pagetop::base::component::form::date::Date";
pub struct Date { pub struct Date {
renderable : fn() -> bool, renderable : fn() -> bool,
weight : i8, weight : i8,

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_FORM: &str = "pagetop::base::component::form::form::Form";
pub enum FormMethod {Get, Post} pub enum FormMethod {Get, Post}
pub struct Form { pub struct Form {

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_HIDDEN: &str = "pagetop::base::component::form::hidden::Hidden";
pub struct Hidden { pub struct Hidden {
weight: i8, weight: i8,
name : OptIden, name : OptIden,

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_INPUT: &str = "pagetop::base::component::form::input::Input";
pub enum InputType {Email, Password, Search, Telephone, Textfield, Url} pub enum InputType {Email, Password, Search, Telephone, Textfield, Url}
pub struct Input { pub struct Input {

View file

@ -1,11 +1,21 @@
mod form; mod form;
pub use form::{Form, FormMethod}; pub use form::{
TYPENAME_FORM, Form, FormMethod
};
mod input; mod input;
pub use input::{Input, InputType}; pub use input::{
TYPENAME_INPUT, Input, InputType
};
mod hidden; mod hidden;
pub use hidden::Hidden; pub use hidden::{
TYPENAME_HIDDEN, Hidden
};
mod date; mod date;
pub use date::Date; pub use date::{
TYPENAME_DATE, Date
};
mod button; mod button;
pub use button::{Button, ButtonType}; pub use button::{
TYPENAME_BUTTON, Button, ButtonType
};

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_COLUMN: &str = "pagetop::base::component::grid::column::Column";
pub struct Column { pub struct Column {
renderable: fn() -> bool, renderable: fn() -> bool,
weight : i8, weight : i8,
@ -21,10 +23,6 @@ impl ComponentTrait for Column {
} }
} }
fn name(&self) -> &'static str {
"GridColumn"
}
fn is_renderable(&self) -> bool { fn is_renderable(&self) -> bool {
(self.renderable)() (self.renderable)()
} }

View file

@ -1,4 +1,8 @@
mod row; mod row;
pub use row::Row; pub use row::{
TYPENAME_ROW, Row
};
mod column; mod column;
pub use column::Column; pub use column::{
TYPENAME_COLUMN, Column
};

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_ROW: &str = "pagetop::base::component::grid::row::Row";
pub struct Row { pub struct Row {
renderable: fn() -> bool, renderable: fn() -> bool,
weight : i8, weight : i8,
@ -21,10 +23,6 @@ impl ComponentTrait for Row {
} }
} }
fn name(&self) -> &'static str {
"GridRow"
}
fn is_renderable(&self) -> bool { fn is_renderable(&self) -> bool {
(self.renderable)() (self.renderable)()
} }

View file

@ -1,5 +1,7 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_IMAGE: &str = "pagetop::base::component::image::Image";
pub struct Image { pub struct Image {
renderable: fn() -> bool, renderable: fn() -> bool,
weight : i8, weight : i8,

View file

@ -1,5 +1,8 @@
use crate::prelude::*; use crate::prelude::*;
pub const TYPENAME_MENU: &str = "pagetop::base::component::menu::Menu";
pub const TYPENAME_MENUITEM: &str = "pagetop::base::component::menu::MenuItem";
pub enum MenuItemType { pub enum MenuItemType {
Label(String), Label(String),
Link(String, String), Link(String, String),
@ -10,9 +13,7 @@ pub enum MenuItemType {
Void, Void,
} }
// -----------------------------------------------------------------------------
// MenuItem. // MenuItem.
// -----------------------------------------------------------------------------
pub struct MenuItem { pub struct MenuItem {
renderable: fn() -> bool, renderable: fn() -> bool,
@ -166,9 +167,7 @@ impl MenuItem {
} }
} }
// -----------------------------------------------------------------------------
// Menu. // Menu.
// -----------------------------------------------------------------------------
pub struct Menu { pub struct Menu {
renderable: fn() -> bool, renderable: fn() -> bool,
@ -212,7 +211,7 @@ impl ComponentTrait for Menu {
)) ))
.add_jquery(); .add_jquery();
let id = assets.serial_id(self.name(), self.id()); let id = assets.serial_id(self.single_name(), self.id());
html! { html! {
ul id=(id) class=[self.classes()] { ul id=(id) class=[self.classes()] {
(self.items().render(assets)) (self.items().render(assets))

View file

@ -1,16 +1,28 @@
mod container; mod container;
pub use container::{Container, ContainerType}; pub use container::{
TYPENAME_CONTAINER, Container, ContainerType
};
pub mod grid; pub mod grid;
mod chunck; mod chunck;
pub use chunck::Chunck; pub use chunck::{
TYPENAME_CHUNCK, Chunck
};
mod block; mod block;
pub use block::Block; pub use block::{
TYPENAME_BLOCK, Block
};
mod image; mod image;
pub use image::Image; pub use image::{
TYPENAME_IMAGE, Image
};
mod menu; mod menu;
pub use menu::{Menu, MenuItem, MenuItemType}; pub use menu::{
TYPENAME_MENU, TYPENAME_MENUITEM, Menu, MenuItem, MenuItemType
};
pub mod form; pub mod form;
pub use form::{Form, FormMethod}; pub use form::{
TYPENAME_FORM, Form, FormMethod
};

View file

@ -1,3 +1,3 @@
pub mod component; pub mod component;
pub mod module; pub mod module;
pub mod theme; pub mod theme;

View file

@ -1,4 +1,4 @@
module_fullname = Default homepage module_name = Default homepage
module_description = Displays a demo homepage when none is configured. module_description = Displays a demo homepage when none is configured.
page_title = Hello world! page_title = Hello world!

View file

@ -1,4 +1,4 @@
module_fullname = Página de inicio predeterminada module_name = Página de inicio predeterminada
module_description = Muestra una página de demostración predeterminada cuando no hay ninguna configurada. module_description = Muestra una página de demostración predeterminada cuando no hay ninguna configurada.
page_title = ¡Hola mundo! page_title = ¡Hola mundo!

View file

@ -2,15 +2,11 @@ use crate::prelude::*;
localize!("src/base/module/demopage/locales"); localize!("src/base/module/demopage/locales");
pub struct DemopageModule; pub struct Demopage;
impl ModuleTrait for DemopageModule { impl ModuleTrait for Demopage {
fn name(&self) -> &'static str { fn name(&self) -> String {
"Demopage" l("module_name")
}
fn fullname(&self) -> String {
l("module_fullname")
} }
fn description(&self) -> Option<String> { fn description(&self) -> Option<String> {

View file

@ -2,17 +2,9 @@ use crate::prelude::*;
include!(concat!(env!("OUT_DIR"), "/aliner.rs")); include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
pub struct AlinerTheme; pub struct Aliner;
impl ThemeTrait for AlinerTheme {
fn name(&self) -> &'static str {
"Aliner"
}
fn fullname(&self) -> String {
"Aliner".to_owned()
}
impl ThemeTrait for Aliner {
fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) {
theme_static_files!(cfg, "/aliner"); theme_static_files!(cfg, "/aliner");
} }

View file

@ -4,17 +4,9 @@ include!(concat!(env!("OUT_DIR"), "/bootsier.rs"));
localize!("src/base/theme/bootsier/locales"); localize!("src/base/theme/bootsier/locales");
pub struct BootsierTheme; pub struct Bootsier;
impl ThemeTrait for BootsierTheme {
fn name(&self) -> &'static str {
"Bootsier"
}
fn fullname(&self) -> String {
"Bootsier".to_owned()
}
impl ThemeTrait for Bootsier {
fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) {
theme_static_files!(cfg, "/bootsier"); theme_static_files!(cfg, "/bootsier");
} }

View file

@ -2,17 +2,9 @@ use crate::prelude::*;
include!(concat!(env!("OUT_DIR"), "/bulmix.rs")); include!(concat!(env!("OUT_DIR"), "/bulmix.rs"));
pub struct BulmixTheme; pub struct Bulmix;
impl ThemeTrait for BulmixTheme {
fn name(&self) -> &'static str {
"Bulmix"
}
fn fullname(&self) -> String {
"Bulmix".to_owned()
}
impl ThemeTrait for Bulmix {
fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) {
theme_static_files!(cfg, "/bulmix"); theme_static_files!(cfg, "/bulmix");
} }
@ -37,12 +29,12 @@ impl ThemeTrait for BulmixTheme {
component: &mut dyn ComponentTrait, component: &mut dyn ComponentTrait,
_assets: &mut PageAssets _assets: &mut PageAssets
) { ) {
match component.name() { match component.type_name() {
"GridRow" => { grid::TYPENAME_ROW => {
let row = component_mut::<grid::Row>(component); let row = component_mut::<grid::Row>(component);
row.alter_classes("columns", ClassesOp::SetDefault); row.alter_classes("columns", ClassesOp::SetDefault);
}, },
"GridColumn" => { grid::TYPENAME_COLUMN => {
let col = component_mut::<grid::Column>(component); let col = component_mut::<grid::Column>(component);
col.alter_classes("column", ClassesOp::SetDefault); col.alter_classes("column", ClassesOp::SetDefault);
}, },

View file

@ -1,13 +1,6 @@
use crate::prelude::*; use crate::prelude::*;
pub struct MinimalTheme; pub struct Minimal;
impl ThemeTrait for MinimalTheme { impl ThemeTrait for Minimal {
fn name(&self) -> &'static str {
"Minimal"
}
fn fullname(&self) -> String {
"Minimal".to_owned()
}
} }

View file

@ -1,4 +1,4 @@
// Exports. // External.
pub use concat_string::concat_string; pub use concat_string::concat_string;
pub use doc_comment::doc_comment; pub use doc_comment::doc_comment;
@ -8,24 +8,24 @@ pub use once_cell::sync::Lazy;
pub(crate) use futures::executor::block_on as run_now; pub(crate) use futures::executor::block_on as run_now;
// ----------------------------------------------------------------------------- // Public APIs.
// APIs públicas.
// -----------------------------------------------------------------------------
pub mod config; // Gestión de la configuración. pub mod config; // Gestión de la configuración.
pub mod trace; // Registro de trazas y eventos de la aplicación. pub mod trace; // Registro de trazas y eventos de la aplicación.
pub mod locale; // Localización. pub mod locale; // Localización.
pub mod html; // HTML en código.
#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))]
pub mod db; // Acceso a la base de datos. pub mod db; // Acceso a base de datos.
pub mod html; // Publicación de HTML desde el código. pub mod theme; // Temas predefinidos y API para crear temas.
pub mod module; // API para crear módulos con nuevas funcionalidades. pub mod module; // API para añadir módulos con nuevas funcionalidades.
pub mod theme; // API para crear temas y temas predeterminados.
pub mod response; // Tipos de respuestas web. pub mod response; // Tipos de respuestas web.
pub mod app; // Aplicación y servidor web.
pub mod app; // Aplicación y servidor web.
pub mod base; // Componentes, Módulos y Temas base. pub mod base; // Componentes, Módulos y Temas base.
pub mod util; // Macros y funciones útiles. pub mod util; // Macros y funciones útiles.
pub mod prelude; // Re-exporta recursos comunes. // Re-exports.
pub mod prelude;

View file

@ -11,11 +11,11 @@ pub use crate::{
pub use crate::config::SETTINGS; pub use crate::config::SETTINGS;
pub use crate::trace; pub use crate::trace;
pub use crate::localize; pub use crate::localize;
pub use crate::html::*;
#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))] #[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))]
pub use crate::{db, db::*, boxed_migration}; pub use crate::{db, db::*, boxed_migration};
pub use crate::html::*;
pub use crate::theme::*; pub use crate::theme::*;
pub use crate::module::*; pub use crate::module::*;
pub use crate::response::page::*; pub use crate::response::page::*;

View file

@ -6,13 +6,11 @@ use crate::theme::*;
static DEFAULT_THEME: Lazy<&dyn ThemeTrait> = Lazy::new(|| { static DEFAULT_THEME: Lazy<&dyn ThemeTrait> = Lazy::new(|| {
match theme_by_name(&SETTINGS.app.theme) { match theme_by_name(&SETTINGS.app.theme) {
Some(theme) => theme, Some(theme) => theme,
None => &base::theme::bootsier::BootsierTheme, None => &base::theme::bootsier::Bootsier,
} }
}); });
// -----------------------------------------------------------------------------
// Favicon. // Favicon.
// -----------------------------------------------------------------------------
pub struct Favicon(Vec<String>); pub struct Favicon(Vec<String>);
@ -99,9 +97,7 @@ impl Favicon {
} }
} }
// -----------------------------------------------------------------------------
// StyleSheet. // StyleSheet.
// -----------------------------------------------------------------------------
pub struct StyleSheet { pub struct StyleSheet {
source: &'static str, source: &'static str,
@ -131,9 +127,7 @@ impl StyleSheet {
} }
} }
// -----------------------------------------------------------------------------
// JavaScript. // JavaScript.
// -----------------------------------------------------------------------------
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum JSMode { Async, Defer, Normal } pub enum JSMode { Async, Defer, Normal }
@ -177,9 +171,7 @@ impl JavaScript {
} }
} }
// -----------------------------------------------------------------------------
// Page assets. // Page assets.
// -----------------------------------------------------------------------------
pub struct PageAssets { pub struct PageAssets {
theme : &'static dyn ThemeTrait, theme : &'static dyn ThemeTrait,