diff --git a/drust/config/default.toml b/drust/config/default.toml index 6d6317f3..32684d4a 100644 --- a/drust/config/default.toml +++ b/drust/config/default.toml @@ -19,4 +19,4 @@ db_pass = "DrU__#3T" tracing = "Info,pagetop=Debug,sqlx::query=Warn" [dev] -#static_files = "pagetop/static" +#static_files = "../pagetop/static" diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index 7e04ea35..e40b232f 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "pagetop" -version = "0.0.24" +version = "0.0.25" edition = "2021" authors = [ "Manuel Cillero " ] description = """\ - PageTop is an opinionated framework for using the most stable and popular \ - Rust packages to build modular, extensible and configurable web solutions.\ + PageTop is an opinionated web development framework that uses the most stable and popular Rust \ + packages to build modular, extensible and configurable Server-side rendered solutions.\ """ homepage = "https://suitepro.cillero.es/projects/pagetop" repository = "https://gitlab.com/manuelcillero/pagetop" @@ -28,7 +28,7 @@ doc-comment = "0.3.3" figlet-rs = "0.1.3" futures = "0.3.21" once_cell = "1.13.0" -paste = "1.0.7" +paste = "1.0.8" substring = "1.4.5" term_size = "0.3.2" url = "2.2.2" diff --git a/pagetop/src/base/component/paragraph.rs b/pagetop/src/base/component/paragraph.rs index ab1eccf7..52cb5c5d 100644 --- a/pagetop/src/base/component/paragraph.rs +++ b/pagetop/src/base/component/paragraph.rs @@ -20,7 +20,7 @@ pub struct Paragraph { renderable: Renderable, id : IdentifierValue, classes : Classes, - html : HtmlMarkup, + components: ComponentsBundle, display : ParagraphDisplay, template : String, } @@ -42,9 +42,14 @@ impl ComponentTrait for Paragraph { (self.renderable.check)(context) } - fn default_render(&self, _: &mut PageContext) -> Markup { + fn default_render(&self, context: &mut PageContext) -> Markup { html! { - p id=[self.id().get()] class=[self.classes().get()] { (*self.html()) } + p + id=[self.id().get()] + class=[self.classes().get()] + { + (self.components().render(context)) + } } } @@ -59,7 +64,7 @@ impl ComponentTrait for Paragraph { impl Paragraph { pub fn with(html: Markup) -> Self { - Paragraph::new().with_html(html) + Paragraph::new().with_component(Html::with(html)) } // Paragraph BUILDER. @@ -84,8 +89,8 @@ impl Paragraph { self } - pub fn with_html(mut self, html: Markup) -> Self { - self.alter_html(html); + pub fn with_component(mut self, component: impl ComponentTrait) -> Self { + self.alter_component(component); self } @@ -121,8 +126,8 @@ impl Paragraph { self } - pub fn alter_html(&mut self, html: Markup) -> &mut Self { - self.html.markup = html; + pub fn alter_component(&mut self, component: impl ComponentTrait) -> &mut Self { + self.components.add(component); self } @@ -158,8 +163,8 @@ impl Paragraph { &self.classes } - pub fn html(&self) -> &Markup { - &self.html.markup + pub fn components(&self) -> &ComponentsBundle { + &self.components } pub fn display(&self) -> &ParagraphDisplay { diff --git a/pagetop/src/base/module/homepage.rs b/pagetop/src/base/module/homepage.rs index eb8e41dd..92a3628b 100644 --- a/pagetop/src/base/module/homepage.rs +++ b/pagetop/src/base/module/homepage.rs @@ -30,6 +30,7 @@ async fn demo() -> ResultPage { .with_context(PageOp::AddStyleSheet(StyleSheet::located( "/theme/module/homepage/styles.css", ))) + .with_body_classes(ClassesOp::AddFirst, "default-homepage") .add_to("region-content", hello_world()) .add_to("region-content", welcome()) .add_to("region-content", about_pagetop()) @@ -54,34 +55,32 @@ fn hello_world() -> Container { .with_component( Paragraph::with(html! { (e("hello_intro", &args![ - "app" => format!("{}", &SETTINGS.app.name) + "app" => format!("{}", &SETTINGS.app.name) ])) }) .with_display(ParagraphDisplay::Small), ) .with_component(Paragraph::with(html! { - (e("hello_pagetop", &args![ - "pagetop" => "PageTop" + (e("hello_powered", &args![ + "pagetop" => "PageTop" ])) })) .with_component( Anchor::button( - "#", - html! { - ("Offered services") - }, + "https://gitlab.com/manuelcillero/pagetop", + html! { (l("hello_code")) }, ) - .with_left_icon(Icon::with("card-checklist")) - .with_classes(ClassesOp::Add, "services-link"), + .with_target(AnchorTarget::Blank) + .with_left_icon(Icon::with("git")) + .with_classes(ClassesOp::Add, "code-link"), ) .with_component( - Anchor::button( - "#", - html! { - ("Get quote") - }, + Anchor::link( + "#welcome", + html! { (l("hello_welcome")) }, ) - .with_left_icon(Icon::with("envelope-open-heart-fill")), + .with_left_icon(Icon::with("arrow-down-circle-fill")) + .with_classes(ClassesOp::Add, "welcome-link"), ), ) .with_column( @@ -97,11 +96,13 @@ fn welcome() -> Container { .with_id("welcome") .with_classes(ClassesOp::Add, "welcome-col-text") .with_component(Heading::h2(html! { - (t("welcome_to", &args!["app" => SETTINGS.app.name.as_str()])) + (l("welcome_page")) })) .with_component( Heading::h3(html! { - (l("welcome_subtitle")) + (e("welcome_subtitle", &args![ + "app" => format!("{}", &SETTINGS.app.name) + ])) }) .with_display(HeadingDisplay::Subtitle), ) diff --git a/pagetop/src/base/module/homepage/locales/en-US/homepage.ftl b/pagetop/src/base/module/homepage/locales/en-US/homepage.ftl index 87e0ddf0..e4e8dead 100644 --- a/pagetop/src/base/module/homepage/locales/en-US/homepage.ftl +++ b/pagetop/src/base/module/homepage/locales/en-US/homepage.ftl @@ -4,10 +4,12 @@ module_description = Displays a demo homepage when none is configured. page_title = Hello world! hello_intro = This page is used to test the proper operation of { $app } after installation. -hello_pagetop = This web solution is powered by { $pagetop }. +hello_powered = This web solution is powered by { $pagetop }. +hello_code = Code +hello_welcome = Welcome -welcome_to = Welcome to { $app } -welcome_subtitle = Are you user of this website? +welcome_page = Welcome Page +welcome_subtitle = Are you user of { $app }? welcome_text1 = If you don't know what this page is about, this probably means that the site is either experiencing problems or is undergoing routine maintenance. welcome_text2 = If the problem persists, please contact your system administrator. diff --git a/pagetop/src/base/module/homepage/locales/es-ES/homepage.ftl b/pagetop/src/base/module/homepage/locales/es-ES/homepage.ftl index 67afd423..614a879e 100644 --- a/pagetop/src/base/module/homepage/locales/es-ES/homepage.ftl +++ b/pagetop/src/base/module/homepage/locales/es-ES/homepage.ftl @@ -3,11 +3,13 @@ module_description = Muestra una página de demostración predeterminada cuando page_title = ¡Hola mundo! -hello_intro = Esta página se utiliza para probar el correcto funcionamiento de { $app } después de la instalación. -hello_pagetop = Esta solución web funciona con { $pagetop }. +hello_intro = Esta página se utiliza para comprobar el correcto funcionamiento de { $app } después de la instalación. +hello_powered = Una solución web creada con { $pagetop }. +hello_code = Código +hello_welcome = Bienvenida -welcome_to = Bienvenido a { $app } -welcome_subtitle = ¿Eres usuario de este sitio web? +welcome_page = Página de bienvenida +welcome_subtitle = ¿Utilizas los servicios de { $app }? welcome_text1 = Si no sabes de qué trata esta página, probablemente significa que el sitio está experimentando problemas o está pasando por un mantenimiento de rutina. welcome_text2 = Si el problema persiste, póngase en contacto con el administrador del sistema. diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index e1aa44bc..68d20d3e 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -7,7 +7,7 @@ pub type HashMapResources = std::collections::HashMap<&'static str, StaticResour /// This function uses the [static_files](https://docs.rs/static-files/latest/static_files/) library /// to embed at compile time a bundle of static files in your binary. /// -/// Just create the folder with static resources in your project (for example `static`): +/// Just create folder with static resources in your project (for example `static`): /// /// ```bash /// cd project_dir @@ -54,12 +54,13 @@ pub type HashMapResources = std::collections::HashMap<&'static str, StaticResour /// } /// ``` /// -/// This will create a file called `guides.rs` where all output and intermediate artifacts are -/// placed, see [OUT_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html). +/// This will create a file called `guides.rs` in the standard directory +/// [OUT_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html) where all +/// intermediate and output artifacts are placed during compilation. /// -/// You don't need to access this file, just include it in your source code and a module called -/// `resources_guides` will be added to your project. Use the function `bundle_guides` to embed the -/// generated HashMap resources collection: +/// You don't need to access this file, just include it in your project source code and a module called +/// `resources_guides` will be added. Then simply reference the `bundle_guides` function to embed +/// the generated HashMap resources collection: /// /// ```rust#ignore /// use pagetop::prelude::*; diff --git a/pagetop/static/theme/module/homepage/styles.css b/pagetop/static/theme/module/homepage/styles.css index 08b28b02..6444fe44 100644 --- a/pagetop/static/theme/module/homepage/styles.css +++ b/pagetop/static/theme/module/homepage/styles.css @@ -1,13 +1,24 @@ +body.default-homepage span.app-name { + font-weight: bold; + color: inherit; +} + #hello-world { padding: 2em 5%; } #hello-world a { margin: .25em; } -#hello-world a.services-link { - padding-left: 1.5em; - padding-right: 1.5em; +#hello-world a.code-link { + padding-left: 2em; + padding-right: 2em; border-radius: 1.5em; + font-size: 112.5%; +} +#hello-world a.welcome-link { + text-decoration: none; + display: inline-block; + vertical-align: middle; } #welcome {