From 4472f2ef52c7d4e7f0320acc14a649d7bcb18e0f Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Fri, 27 Oct 2023 11:14:37 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Integrate=20aliner=20theme=20with?= =?UTF-8?q?=20name=20Chassis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 1 - README.md | 3 -- drust/Cargo.toml | 1 - drust/config/local.toml | 7 +-- drust/src/main.rs | 1 - pagetop-aliner/Cargo.toml | 22 --------- pagetop-aliner/README.md | 27 ----------- pagetop-aliner/build.rs | 7 --- pagetop-aliner/src/lib.rs | 30 ------------ pagetop/src/base/theme.rs | 6 +++ pagetop/src/base/theme/basic.rs | 36 +++++++++++++++ pagetop/src/base/theme/chassis.rs | 36 +++++++++++++++ pagetop/src/base/theme/inception.rs | 10 +--- pagetop/src/core/module/all.rs | 9 +++- pagetop/static/base/css/basic.css | 3 ++ .../static/base/css/chassis.css | 0 pagetop/static/base/css/components.css | 46 ------------------- .../base/css/{styles.css => inception.css} | 0 18 files changed, 94 insertions(+), 151 deletions(-) delete mode 100644 pagetop-aliner/Cargo.toml delete mode 100644 pagetop-aliner/README.md delete mode 100644 pagetop-aliner/build.rs delete mode 100644 pagetop-aliner/src/lib.rs create mode 100644 pagetop/src/base/theme/basic.rs create mode 100644 pagetop/src/base/theme/chassis.rs create mode 100644 pagetop/static/base/css/basic.css rename pagetop-aliner/static/css/styles.css => pagetop/static/base/css/chassis.css (100%) delete mode 100644 pagetop/static/base/css/components.css rename pagetop/static/base/css/{styles.css => inception.css} (100%) diff --git a/Cargo.toml b/Cargo.toml index cab17095..e64205fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ members = [ "pagetop-user", "pagetop-node", # Themes. - "pagetop-aliner", "pagetop-bootsier", "pagetop-bulmix", ] diff --git a/README.md b/README.md index a963c0d3..1e509f73 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,6 @@ El repositorio se organiza en un *workspace* con los siguientes subproyectos: ## Temas -* **[pagetop-aliner](https://github.com/manuelcillero/pagetop/tree/main/pagetop-aliner)**, tema que - delimita con cajas los elementos HTML para mostrar esquemáticamente la composición de las páginas. - * **[pagetop-bootsier](https://github.com/manuelcillero/pagetop/tree/main/pagetop-bootsier)**, tema que utiliza el *framework* [Bootstrap](https://getbootstrap.com/) para la composición de páginas y visualización de componentes. diff --git a/drust/Cargo.toml b/drust/Cargo.toml index c0de9ab6..3260e429 100644 --- a/drust/Cargo.toml +++ b/drust/Cargo.toml @@ -16,7 +16,6 @@ license = "Apache-2.0 OR MIT" [dependencies] pagetop = { version = "0.0", path = "../pagetop", features = ["mysql"], default-features = false } # Themes. -pagetop-aliner = { version = "0.0", path = "../pagetop-aliner" } pagetop-bootsier = { version = "0.0", path = "../pagetop-bootsier" } pagetop-bulmix = { version = "0.0", path = "../pagetop-bulmix" } # Modules. diff --git a/drust/config/local.toml b/drust/config/local.toml index 410a913d..343add5c 100644 --- a/drust/config/local.toml +++ b/drust/config/local.toml @@ -1,7 +1,8 @@ [app] -#theme = "Default" -#theme = "Aliner" -theme = "Bootsier" +#theme = "Basic" +#theme = "Chassis" +theme = "Inception" +#theme = "Bootsier" #theme = "Bulmix" language = "es-ES" diff --git a/drust/src/main.rs b/drust/src/main.rs index 306b3c02..04a959ad 100644 --- a/drust/src/main.rs +++ b/drust/src/main.rs @@ -12,7 +12,6 @@ impl ModuleTrait for Drust { fn dependencies(&self) -> Vec { vec![ // Themes. - &pagetop_aliner::Aliner, &pagetop_bootsier::Bootsier, &pagetop_bulmix::Bulmix, // Modules. diff --git a/pagetop-aliner/Cargo.toml b/pagetop-aliner/Cargo.toml deleted file mode 100644 index 44935540..00000000 --- a/pagetop-aliner/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "pagetop-aliner" -version = "0.0.9" -edition = "2021" - -authors = [ - "Manuel Cillero " -] -description = """\ - Theme for PageTop with a basic set of styles that encloses HTML elements with boxes to show an \ - outline of the page layout and components display.\ -""" -homepage = "https://pagetop.cillero.es" -repository = "https://github.com/manuelcillero/pagetop" -license = "Apache-2.0 OR MIT" - -[dependencies] -pagetop = { version = "0.0", path = "../pagetop" } -static-files = "0.2.3" - -[build-dependencies] -pagetop-build = { version = "0.0", path = "../pagetop-build" } diff --git a/pagetop-aliner/README.md b/pagetop-aliner/README.md deleted file mode 100644 index 6697707e..00000000 --- a/pagetop-aliner/README.md +++ /dev/null @@ -1,27 +0,0 @@ -Tema para **PageTop** que delimita con cajas los elementos HTML para mostrar esquemáticamente la -composición de las páginas. - -[PageTop](https://github.com/manuelcillero/pagetop/tree/main/pagetop), es un entorno de desarrollo -basado en algunos de los *crates* más estables y populares del ecosistema Rust para proporcionar -APIs, patrones de desarrollo y buenas prácticas para la creación de soluciones web SSR (*Server-Side -Rendering*). - - -# 🚧 Advertencia - -**PageTop** sólo libera actualmente versiones de desarrollo. La API no es estable y los cambios son -constantes. No puede considerarse preparado hasta que se libere la versión **0.1.0**. - - -# 📜 Licencia - -Este proyecto tiene licencia, de hecho tiene dos, puedes aplicar cualquiera de las siguientes a tu -elección: - -* Licencia Apache versión 2.0 - ([LICENSE-APACHE](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-APACHE) o - [http://www.apache.org/licenses/LICENSE-2.0]). - -* Licencia MIT - ([LICENSE-MIT](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-MIT) o - [http://opensource.org/licenses/MIT]). diff --git a/pagetop-aliner/build.rs b/pagetop-aliner/build.rs deleted file mode 100644 index 2f0500aa..00000000 --- a/pagetop-aliner/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -use pagetop_build::StaticFilesBundle; - -fn main() -> std::io::Result<()> { - StaticFilesBundle::from_dir("./static") - .with_name("aliner") - .build() -} diff --git a/pagetop-aliner/src/lib.rs b/pagetop-aliner/src/lib.rs deleted file mode 100644 index 350a14dd..00000000 --- a/pagetop-aliner/src/lib.rs +++ /dev/null @@ -1,30 +0,0 @@ -use pagetop::prelude::*; - -new_handle!(THEME_ALINER); - -new_static_files!(aliner); - -pub struct Aliner; - -impl ModuleTrait for Aliner { - fn handle(&self) -> Handle { - THEME_ALINER - } - - fn theme(&self) -> Option { - Some(&Aliner) - } - - fn configure_service(&self, scfg: &mut service::web::ServiceConfig) { - service_for_static_files!(scfg, "/aliner", aliner); - } -} - -impl ThemeTrait for Aliner { - fn before_prepare_body(&self, page: &mut Page) { - page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico"))) - .alter_context(ContextOp::AddStyleSheet( - StyleSheet::at("/aliner/css/styles.css").with_weight(-99), - )); - } -} diff --git a/pagetop/src/base/theme.rs b/pagetop/src/base/theme.rs index 83216d03..b78722b0 100644 --- a/pagetop/src/base/theme.rs +++ b/pagetop/src/base/theme.rs @@ -1,2 +1,8 @@ +mod basic; +pub use basic::{Basic, THEME_BASIC}; + +mod chassis; +pub use chassis::{Chassis, THEME_CHASSIS}; + mod inception; pub use inception::{Inception, THEME_INCEPTION}; diff --git a/pagetop/src/base/theme/basic.rs b/pagetop/src/base/theme/basic.rs new file mode 100644 index 00000000..f28a6ebf --- /dev/null +++ b/pagetop/src/base/theme/basic.rs @@ -0,0 +1,36 @@ +use crate::prelude::*; + +new_handle!(THEME_BASIC); + +pub struct Basic; + +impl ModuleTrait for Basic { + fn handle(&self) -> Handle { + THEME_BASIC + } + + fn name(&self) -> L10n { + L10n::n("Basic") + } + + fn theme(&self) -> Option { + Some(&Basic) + } +} + +impl ThemeTrait for Basic { + fn after_prepare_body(&self, page: &mut Page) { + page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico"))) + .alter_context(ContextOp::AddStyleSheet( + StyleSheet::at("/base/css/normalize.min.css") + .with_version("8.0.1") + .with_weight(-90), + )) + .alter_context(ContextOp::AddBaseAssets) + .alter_context(ContextOp::AddStyleSheet( + StyleSheet::at("/base/css/basic.css") + .with_version("0.0.1") + .with_weight(-90), + )); + } +} diff --git a/pagetop/src/base/theme/chassis.rs b/pagetop/src/base/theme/chassis.rs new file mode 100644 index 00000000..03180b5e --- /dev/null +++ b/pagetop/src/base/theme/chassis.rs @@ -0,0 +1,36 @@ +use crate::prelude::*; + +new_handle!(THEME_CHASSIS); + +pub struct Chassis; + +impl ModuleTrait for Chassis { + fn handle(&self) -> Handle { + THEME_CHASSIS + } + + fn name(&self) -> L10n { + L10n::n("Chassis") + } + + fn theme(&self) -> Option { + Some(&Chassis) + } +} + +impl ThemeTrait for Chassis { + fn after_prepare_body(&self, page: &mut Page) { + page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico"))) + .alter_context(ContextOp::AddStyleSheet( + StyleSheet::at("/base/css/normalize.min.css") + .with_version("8.0.1") + .with_weight(-90), + )) + .alter_context(ContextOp::AddBaseAssets) + .alter_context(ContextOp::AddStyleSheet( + StyleSheet::at("/base/css/chassis.css") + .with_version("0.0.1") + .with_weight(-90), + )); + } +} diff --git a/pagetop/src/base/theme/inception.rs b/pagetop/src/base/theme/inception.rs index 3557a077..f706fe31 100644 --- a/pagetop/src/base/theme/inception.rs +++ b/pagetop/src/base/theme/inception.rs @@ -2,8 +2,6 @@ use crate::prelude::*; new_handle!(THEME_INCEPTION); -new_static_files!(base); - pub struct Inception; impl ModuleTrait for Inception { @@ -12,16 +10,12 @@ impl ModuleTrait for Inception { } fn name(&self) -> L10n { - L10n::n("Default") + L10n::n("Inception") } fn theme(&self) -> Option { Some(&Inception) } - - fn configure_service(&self, scfg: &mut service::web::ServiceConfig) { - service_for_static_files!(scfg, "/base", base); - } } impl ThemeTrait for Inception { @@ -34,7 +28,7 @@ impl ThemeTrait for Inception { )) .alter_context(ContextOp::AddBaseAssets) .alter_context(ContextOp::AddStyleSheet( - StyleSheet::at("/base/css/styles.css") + StyleSheet::at("/base/css/inception.css") .with_version("0.0.1") .with_weight(-90), )); diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index fd160c30..76826f13 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -1,13 +1,15 @@ use crate::core::action::add_action; use crate::core::module::ModuleRef; use crate::core::theme::all::THEMES; -use crate::{service, trace, LazyStatic}; +use crate::{new_static_files, service, service_for_static_files, trace, LazyStatic}; #[cfg(feature = "database")] use crate::db::*; use std::sync::RwLock; +new_static_files!(base); + // MODULES ***************************************************************************************** static ENABLED_MODULES: LazyStatic>> = @@ -27,7 +29,9 @@ pub fn register_modules(app: ModuleRef) { // List of modules to enable. let mut list: Vec = Vec::new(); - // Enable default theme. + // Enable default themes. + add_to_enabled(&mut list, &crate::base::theme::Basic); + add_to_enabled(&mut list, &crate::base::theme::Chassis); add_to_enabled(&mut list, &crate::base::theme::Inception); // Enable application modules. @@ -153,6 +157,7 @@ pub fn run_migrations() { // CONFIGURE SERVICES ****************************************************************************** pub fn configure_services(scfg: &mut service::web::ServiceConfig) { + service_for_static_files!(scfg, "/base", base); for m in ENABLED_MODULES.read().unwrap().iter() { m.configure_service(scfg); } diff --git a/pagetop/static/base/css/basic.css b/pagetop/static/base/css/basic.css new file mode 100644 index 00000000..06a9d968 --- /dev/null +++ b/pagetop/static/base/css/basic.css @@ -0,0 +1,3 @@ +.pt-body__skip { + display: none; +} diff --git a/pagetop-aliner/static/css/styles.css b/pagetop/static/base/css/chassis.css similarity index 100% rename from pagetop-aliner/static/css/styles.css rename to pagetop/static/base/css/chassis.css diff --git a/pagetop/static/base/css/components.css b/pagetop/static/base/css/components.css deleted file mode 100644 index 57f93007..00000000 --- a/pagetop/static/base/css/components.css +++ /dev/null @@ -1,46 +0,0 @@ -/* Image component */ - -.pt-img__fluid { - max-width: 100%; - height: auto; -} - -/* Branding component */ - -.pt-branding__wrapper { - display: flex; - align-items: flex-end; - column-gap: var(--pt-gap-0-75); -} -.pt-branding__name { - letter-spacing: 0.02em; - font-size: var(--pt-font-size-xl); -} -.pt-branding__slogan { - font-size: var(--pt-font-size-l); -} - -/* SM - Applies <= 568px */ -@media (max-width: 35.5em) { - .pt-branding__logo { - display: none; - } -} -/* LG - Applies <= 992px */ -@media (max-width: 62em) { - .pt-branding__slogan { - font-size: var(--pt-font-size-l); - } -} - -/* PoweredBy component */ - -#pt-powered-by { - text-align: center; -} -#pt-powered-by .pt-pagetop__logo img, -#pt-powered-by .pt-pagetop__logo svg { - margin-left: .275em; - height: 1.275em; - vertical-align: middle; -} diff --git a/pagetop/static/base/css/styles.css b/pagetop/static/base/css/inception.css similarity index 100% rename from pagetop/static/base/css/styles.css rename to pagetop/static/base/css/inception.css