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::*;
fn bootstrap() {
register_module(&pagetop_admin::AdminModule);
register_module(&pagetop_user::UserModule);
register_module(&pagetop_node::NodeModule);
register_module(&pagetop_admin::Admin);
register_module(&pagetop_user::User);
register_module(&pagetop_node::Node);
}
#[actix_web::main]

View file

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

View file

@ -1,2 +1,2 @@
module_fullname = Admin module
module_name = Admin 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.

View file

@ -3,7 +3,7 @@ use super::l;
pub async fn summary() -> app::Result<Markup> {
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_blank("Opción 3", "https://www.google.es"))
.add(MenuItem::submenu("Submenú 1", Menu::new()

View file

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

View file

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

View file

@ -4,15 +4,11 @@ localize!("src/locales");
mod migration;
pub struct UserModule;
pub struct User;
impl ModuleTrait for UserModule {
fn name(&self) -> &'static str {
"User"
}
fn fullname(&self) -> String {
l("module_fullname")
impl ModuleTrait for User {
fn name(&self) -> String {
l("module_name")
}
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.
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.
username = Nombre de usuario

View file

@ -28,10 +28,10 @@ impl Application {
Lazy::force(&app::db::DBCONN);
// Registra los temas predeterminados.
theme::register_theme(&base::theme::aliner::AlinerTheme);
theme::register_theme(&base::theme::minimal::MinimalTheme);
theme::register_theme(&base::theme::bootsier::BootsierTheme);
theme::register_theme(&base::theme::bulmix::BulmixTheme);
theme::register_theme(&base::theme::aliner::Aliner);
theme::register_theme(&base::theme::minimal::Minimal);
theme::register_theme(&base::theme::bootsier::Bootsier);
theme::register_theme(&base::theme::bulmix::Bulmix);
// Ejecuta la función de inicio de la aplicación.
trace::info!("Calling application bootstrap");
@ -39,7 +39,7 @@ impl Application {
// Registra el módulo de presentación de PageTop.
// 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).
#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))]

View file

@ -1,5 +1,7 @@
use crate::prelude::*;
pub const TYPENAME_BLOCK: &str = "pagetop::base::component::block::Block";
pub struct Block {
renderable: fn() -> bool,
weight : i8,
@ -32,7 +34,7 @@ impl ComponentTrait for Block {
}
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! {
div id=(id) class=[self.classes()] {
@match self.title() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,8 @@
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 {
Label(String),
Link(String, String),
@ -10,9 +13,7 @@ pub enum MenuItemType {
Void,
}
// -----------------------------------------------------------------------------
// MenuItem.
// -----------------------------------------------------------------------------
pub struct MenuItem {
renderable: fn() -> bool,
@ -166,9 +167,7 @@ impl MenuItem {
}
}
// -----------------------------------------------------------------------------
// Menu.
// -----------------------------------------------------------------------------
pub struct Menu {
renderable: fn() -> bool,
@ -212,7 +211,7 @@ impl ComponentTrait for Menu {
))
.add_jquery();
let id = assets.serial_id(self.name(), self.id());
let id = assets.serial_id(self.single_name(), self.id());
html! {
ul id=(id) class=[self.classes()] {
(self.items().render(assets))

View file

@ -1,16 +1,28 @@
mod container;
pub use container::{Container, ContainerType};
pub use container::{
TYPENAME_CONTAINER, Container, ContainerType
};
pub mod grid;
mod chunck;
pub use chunck::Chunck;
pub use chunck::{
TYPENAME_CHUNCK, Chunck
};
mod block;
pub use block::Block;
pub use block::{
TYPENAME_BLOCK, Block
};
mod image;
pub use image::Image;
pub use image::{
TYPENAME_IMAGE, Image
};
mod menu;
pub use menu::{Menu, MenuItem, MenuItemType};
pub use menu::{
TYPENAME_MENU, TYPENAME_MENUITEM, Menu, MenuItem, MenuItemType
};
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 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.
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.
page_title = ¡Hola mundo!

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
// Exports.
// External.
pub use concat_string::concat_string;
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;
// -----------------------------------------------------------------------------
// APIs públicas.
// -----------------------------------------------------------------------------
// Public APIs.
pub mod config; // Gestión de la configuración.
pub mod trace; // Registro de trazas y eventos de la aplicación.
pub mod locale; // Localización.
pub mod html; // HTML en código.
#[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 module; // API para crear módulos con nuevas funcionalidades.
pub mod theme; // API para crear temas y temas predeterminados.
pub mod theme; // Temas predefinidos y API para crear temas.
pub mod module; // API para añadir módulos con nuevas funcionalidades.
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 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::trace;
pub use crate::localize;
pub use crate::html::*;
#[cfg(any(feature = "mysql", feature = "postgres", feature = "sqlite"))]
pub use crate::{db, db::*, boxed_migration};
pub use crate::html::*;
pub use crate::theme::*;
pub use crate::module::*;
pub use crate::response::page::*;

View file

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