diff --git a/config/default.toml b/config/default.toml index 33280fbd..5b6982fe 100644 --- a/config/default.toml +++ b/config/default.toml @@ -1,12 +1,12 @@ [app] name = "Drust" description = """\ - A modern Content Management System for sharing the world.\ + A modern web Content Management System to share your world.\ """ -language = "es-ES" #theme = "Aliner" #theme = "Minimal" theme = "Bootsier" +language = "es-ES" [database] db_type = "mysql" @@ -16,3 +16,6 @@ db_pass = "DrU__#3T" [log] tracing = "Info,sqlx::query=Warn" + +[dev] +#static_files = "pagetop/static" diff --git a/drust/Cargo.toml b/drust/Cargo.toml index 88ebabde..7a5412d5 100644 --- a/drust/Cargo.toml +++ b/drust/Cargo.toml @@ -7,7 +7,7 @@ authors = [ "Manuel Cillero " ] description = """\ - A modern Content Management System for sharing the world.\ + A modern web Content Management System to share your world.\ """ homepage = "https://suitepro.cillero.es/projects/drust" repository = "https://gitlab.com/manuelcillero/drust" diff --git a/pagetop-admin/Cargo.toml b/pagetop-admin/Cargo.toml index 1bff0edd..3dfc6e60 100644 --- a/pagetop-admin/Cargo.toml +++ b/pagetop-admin/Cargo.toml @@ -7,10 +7,10 @@ authors = [ "Manuel Cillero " ] description = """\ - Allows content to be submitted to the site and displayed on pages.\ + ...\ """ -homepage = "https://suitepro.cillero.es/projects/drust" -repository = "https://gitlab.com/manuelcillero/drust" +homepage = "https://suitepro.cillero.es/projects/pagetop" +repository = "https://gitlab.com/manuelcillero/pagetop" [dependencies] pagetop = { path = "../pagetop" } diff --git a/pagetop-node/Cargo.toml b/pagetop-node/Cargo.toml index 36b43d39..29857822 100644 --- a/pagetop-node/Cargo.toml +++ b/pagetop-node/Cargo.toml @@ -9,8 +9,8 @@ authors = [ description = """\ Allows content to be submitted to the site and displayed on pages.\ """ -homepage = "https://suitepro.cillero.es/projects/drust" -repository = "https://gitlab.com/manuelcillero/drust" +homepage = "https://suitepro.cillero.es/projects/pagetop" +repository = "https://gitlab.com/manuelcillero/pagetop" [dependencies] pagetop = { path = "../pagetop" } diff --git a/pagetop-user/Cargo.toml b/pagetop-user/Cargo.toml index 37352fe7..59c24cb3 100644 --- a/pagetop-user/Cargo.toml +++ b/pagetop-user/Cargo.toml @@ -9,14 +9,10 @@ authors = [ description = """\ Allows content to be submitted to the site and displayed on pages.\ """ -homepage = "https://suitepro.cillero.es/projects/drust" -repository = "https://gitlab.com/manuelcillero/drust" +homepage = "https://suitepro.cillero.es/projects/pagetop" +repository = "https://gitlab.com/manuelcillero/pagetop" [dependencies] pagetop = { path = "../pagetop" } +sea-orm = { version = "0.6.0" } serde = { version = "1.0", features = ["derive"] } - -[dependencies.sea-orm] -version = "0.6.0" -features = ["debug-print", "macros"] -default-features = false diff --git a/pagetop-user/src/locales/es-ES/homepage.ftl b/pagetop-user/src/locales/es-ES/homepage.ftl index ae9a70e0..f5f6e1bb 100644 --- a/pagetop-user/src/locales/es-ES/homepage.ftl +++ b/pagetop-user/src/locales/es-ES/homepage.ftl @@ -1,5 +1,5 @@ module_fullname = Usuario -module_description = Gestion 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 password = Contraseña diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index db491819..4d92b378 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -7,10 +7,8 @@ authors = [ "Manuel Cillero " ] description = """\ - PageTop es un proyecto personal para aprender Rust. Incluye algunos de los \ - crates más estables y populares para desarrollar soluciones web modulares, \ - extensibles y configurables. También es un sistema para la gestión de \ - contenidos web.\ + PageTop is an opinionated framework for using the most stable and popular \ + Rust packages to build modular, extensible and configurable web solutions.\ """ homepage = "https://suitepro.cillero.es/projects/pagetop" repository = "https://gitlab.com/manuelcillero/pagetop" @@ -44,6 +42,7 @@ unic-langid = "0.9.0" actix-web = "3.3.3" actix-web-static-files = "3.0.5" +actix-files = "0.4.1" maud = { version = "0.23.0", features = ["actix-web"] } sycamore = { version = "0.7.1", features = ["ssr"] } @@ -62,9 +61,6 @@ features = ["debug-print", "migration"] default-features = false optional = true -[dev-dependencies] -tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } - [features] default = [] mysql = ["sea-orm", "sea-schema", "sea-orm/sqlx-mysql"] @@ -74,5 +70,8 @@ sqlite = ["sea-orm", "sea-schema", "sea-orm/sqlx-sqlite"] [build-dependencies] actix-web-static-files = "3.0.5" +[dev-dependencies] +tokio = { version = "1.17.0", features = ["macros", "rt-multi-thread"] } + [lib] name = "pagetop" diff --git a/pagetop/STARTER.bin.Cargo.toml b/pagetop/STARTER.bin.Cargo.toml index d05a17bf..2ee2fd9d 100644 --- a/pagetop/STARTER.bin.Cargo.toml +++ b/pagetop/STARTER.bin.Cargo.toml @@ -8,24 +8,20 @@ edition = "2021" [dependencies.pagetop] path = "../pagetop" -# Opcional. Por defecto se puede usar PageTop sin base de datos. +# PageTop por defecto no requiere base de datos. Hay que habilitarla: features = ["mysql"] # features = ["postgres"] # features = ["sqlite"] -# PageTop puede dar soporte a todas las bases de datos. +# PageTop puede dar soporte a todas las bases de datos: # features = ["mysql", "postgres", "sqlite"] -# Sólo cuando no se usen las características predeterminadas. +# En estos casos hay que deshabilitar las características predeterminadas: default-features = false [dependencies] -# Requerido. actix-web = "3.3.3" -# Opcional. Sólo si se usa la macro html!. +# Opcional. Sólo si se usa la macro html!: maud = { version = "0.23.0" } -# Opcional. Si se requiere serialización de estructuras de datos. +# Opcional. Sólo si se usa base de datos: +sea-orm = { version = "0.6.0" } +# Opcional. Para la serialización de estructuras de datos: serde = { version = "1.0", features = ["derive"] } - -[dependencies.sea-orm] -version = "0.6.0" -features = ["debug-print", "macros"] -default-features = false diff --git a/pagetop/STARTER.lib.Cargo.toml b/pagetop/STARTER.lib.Cargo.toml index 97389750..74e74a8a 100644 --- a/pagetop/STARTER.lib.Cargo.toml +++ b/pagetop/STARTER.lib.Cargo.toml @@ -6,24 +6,11 @@ edition = "2021" # Ver más claves y sus definiciones en # https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies.pagetop] -path = "../pagetop" -# Opcional. Por defecto se puede usar PageTop sin base de datos. -features = ["mysql"] -# features = ["postgres"] -# features = ["sqlite"] -# PageTop puede dar soporte a todas las bases de datos. -# features = ["mysql", "postgres", "sqlite"] -# Sólo cuando no se usen las características predeterminadas. -default-features = false - [dependencies] -# Opcional. Sólo si se usa la macro html!. +pagetop = { path = "../pagetop" } +# Opcional. Sólo si se usa la macro html!: maud = { version = "0.23.0" } -# Opcional. Si se requiere serialización de estructuras de datos. +# Opcional. Sólo si se usa base de datos: +sea-orm = { version = "0.6.0" } +# Opcional. Para la serialización de estructuras de datos: serde = { version = "1.0", features = ["derive"] } - -[dependencies.sea-orm] -version = "0.6.0" -features = ["debug-print", "macros"] -default-features = false diff --git a/pagetop/build.rs b/pagetop/build.rs index 9b252213..bd7e60a0 100644 --- a/pagetop/build.rs +++ b/pagetop/build.rs @@ -9,7 +9,6 @@ fn main() { Path::new(env::var("OUT_DIR").unwrap().as_str()) .join("theme.rs") ) - .with_generated_fn("assets") .build() .unwrap(); @@ -18,7 +17,6 @@ fn main() { Path::new(env::var("OUT_DIR").unwrap().as_str()) .join("aliner.rs") ) - .with_generated_fn("assets") .build() .unwrap(); @@ -27,7 +25,6 @@ fn main() { Path::new(env::var("OUT_DIR").unwrap().as_str()) .join("bootsier.rs") ) - .with_generated_fn("assets") .build() .unwrap(); } diff --git a/pagetop/config/settings.default.toml b/pagetop/config/settings.default.toml index b9c329cf..8ac7ab2d 100644 --- a/pagetop/config/settings.default.toml +++ b/pagetop/config/settings.default.toml @@ -43,3 +43,11 @@ max_pool_size = 5 # Configuración del servidor web. bind_address = "localhost" bind_port = 8088 + +[dev] +# Los archivos estáticos requeridos por temas y componentes incluidos en PageTop +# se integran de manera predeterminada en el binario ejecutable. Sin embargo, es +# útil servir estos archivos desde su propio directorio durante el desarrollo ya +# que no requiere compilar cada vez que se modifican. En este caso, normalmente, +# basta con indicar el directorio "pagetop/static". +static_files = "" diff --git a/pagetop/src/base/theme/aliner/mod.rs b/pagetop/src/base/theme/aliner/mod.rs index 676eb25d..07b1470f 100644 --- a/pagetop/src/base/theme/aliner/mod.rs +++ b/pagetop/src/base/theme/aliner/mod.rs @@ -14,10 +14,7 @@ impl ThemeTrait for AlinerTheme { } fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { - cfg.service(actix_web_static_files::ResourceFiles::new( - "/aliner", - assets() - )); + theme_static_files!(cfg, "/aliner"); } fn before_render_page(&self, page: &mut Page) { diff --git a/pagetop/src/base/theme/bootsier/mod.rs b/pagetop/src/base/theme/bootsier/mod.rs index 132dce32..dbd31727 100644 --- a/pagetop/src/base/theme/bootsier/mod.rs +++ b/pagetop/src/base/theme/bootsier/mod.rs @@ -16,10 +16,7 @@ impl ThemeTrait for BootsierTheme { } fn configure_theme(&self, cfg: &mut app::web::ServiceConfig) { - cfg.service(actix_web_static_files::ResourceFiles::new( - "/bootsier", - assets() - )); + theme_static_files!(cfg, "/bootsier"); } fn before_render_page(&self, page: &mut Page) { @@ -61,7 +58,7 @@ impl ThemeTrait for BootsierTheme { div class="jumbotron" { div class="media" { img - src="/bootsier/images/caution.png" + src="/static/bootsier/images/caution.png" class="mr-4" style="width: 20%; max-width: 188px" alt="Caution!"; diff --git a/pagetop/src/config.rs b/pagetop/src/config.rs index 27dbb275..0a5e322d 100644 --- a/pagetop/src/config.rs +++ b/pagetop/src/config.rs @@ -104,12 +104,18 @@ pub struct Webserver { pub bind_port : u16, } +#[derive(Debug, Deserialize)] +pub struct Dev { + pub static_files : String, +} + #[derive(Debug, Deserialize)] pub struct Settings { pub app : App, pub log : Log, pub database : Database, pub webserver : Webserver, + pub dev : Dev, } config_map!(r#" @@ -144,5 +150,8 @@ Ajustes globales y valores predeterminados para las secciones *\[app\]*, // [webserver] "webserver.bind_address" => "localhost", - "webserver.bind_port" => 8088 + "webserver.bind_port" => 8088, + + // [dev] + "dev.static_files" => "" ); diff --git a/pagetop/src/global.rs b/pagetop/src/global.rs index 34280cf4..1b4c169f 100644 --- a/pagetop/src/global.rs +++ b/pagetop/src/global.rs @@ -1,4 +1,4 @@ -use crate::{Lazy, app, base, run_now, trace}; +use crate::{Lazy, app, base, run_now, theme_static_files, trace}; use crate::config::SETTINGS; use crate::db::migration::*; use crate::module::*; @@ -84,10 +84,7 @@ pub fn theme_by_name(name: &str) -> Option<&'static dyn ThemeTrait> { } pub fn themes(cfg: &mut app::web::ServiceConfig) { - cfg.service(actix_web_static_files::ResourceFiles::new( - "/theme", - assets() - )); + theme_static_files!(cfg, "/theme"); for t in THEMES.read().unwrap().iter() { t.configure_theme(cfg); diff --git a/pagetop/src/prelude.rs b/pagetop/src/prelude.rs index e9b3617c..7c2e9ef3 100644 --- a/pagetop/src/prelude.rs +++ b/pagetop/src/prelude.rs @@ -1,6 +1,11 @@ //! Re-exporta recursos comunes. -pub use crate::args; +// Macros. +pub use crate::{ + args, + theme_static_files, +}; + pub use crate::config::SETTINGS; pub use crate::trace; pub use crate::localize; diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index 3fff0a23..c5254618 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -18,6 +18,24 @@ macro_rules! args { }}; } +#[macro_export] +macro_rules! theme_static_files { + ( $cfg:ident, $dir:expr ) => {{ + let static_files = &$crate::config::SETTINGS.dev.static_files; + if static_files.is_empty() { + $cfg.service(actix_web_static_files::ResourceFiles::new( + $dir, + generate() + )); + } else { + $cfg.service(actix_files::Files::new( + $dir, + &[static_files, $dir].join("") + ).show_files_listing()); + } + }}; +} + pub fn valid_id(id: &str) -> Option { let id = id.trim().replace(" ", "_").to_lowercase(); match id.is_empty() { diff --git a/pagetop/static/aliner/css/styles.css b/pagetop/static/aliner/css/styles.css index ffeee7db..1cc2f5dc 100644 --- a/pagetop/static/aliner/css/styles.css +++ b/pagetop/static/aliner/css/styles.css @@ -1,5 +1,16 @@ html { background-color: white; + padding: 1px 3px; +} +body { + padding: 1px 3px; +} +div { + padding: 1px 3px; + margin: 5px; +} +h1, h2, h3, h4,h5, h6, p { + background-color: snow; } * * { outline: 5px solid rgba(255,0,0,.1); @@ -21,7 +32,9 @@ html { background: #faa; border-radius: 3px; font: normal normal 400 10px/1.2 monospace; + vertical-align: middle; padding: 1px 3px; + margin: 0 3px; } *::before { content: "(";