From 0af85c4d776dd711d146bf825fa9426934d0e76f Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Fri, 9 Jun 2023 10:33:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Define=20la=20estructura=20para=20t?= =?UTF-8?q?ests=20y=20ejemplos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 12 ++++++----- examples/Cargo.toml | 4 ++++ examples/hello-world/Cargo.toml | 9 +++++++++ examples/hello-world/src/main.rs | 20 +++++++++++++++++++ pagetop-admin/src/summary.rs | 4 ++-- pagetop-homedemo/src/lib.rs | 10 +++++----- pagetop-user/src/lib.rs | 2 +- pagetop/src/config.rs | 8 ++++---- pagetop/src/response/fatal_error.rs | 4 ++-- pagetop/src/response/page/definition.rs | 6 +----- tests/Cargo.toml | 18 +++++++++++++++++ tests/src/main.rs | 1 + pagetop/tests/main.rs => tests/src/server.rs | 0 .../src/server}/health_check.rs | 0 14 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 examples/Cargo.toml create mode 100644 examples/hello-world/Cargo.toml create mode 100644 examples/hello-world/src/main.rs create mode 100644 tests/Cargo.toml create mode 100644 tests/src/main.rs rename pagetop/tests/main.rs => tests/src/server.rs (100%) rename {pagetop/tests => tests/src/server}/health_check.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index ea843974..2029180c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,19 +7,21 @@ members = [ "pagetop-build", "pagetop-jquery", "pagetop-homedemo", - "pagetop-megamenu", # Components. "pagetop-minimal", - # Themes. - "pagetop-aliner", - "pagetop-bootsier", - "pagetop-bulmix", + "pagetop-megamenu", # Modules. "pagetop-admin", "pagetop-user", "pagetop-node", + # Themes. + "pagetop-aliner", + "pagetop-bootsier", + "pagetop-bulmix", ] exclude = [ "drust", + "examples", + "tests", ] diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 00000000..22a37520 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] +members = [ + "hello-world", +] diff --git a/examples/hello-world/Cargo.toml b/examples/hello-world/Cargo.toml new file mode 100644 index 00000000..d35e5156 --- /dev/null +++ b/examples/hello-world/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "example_hello_world" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +actix-web = "4" +pagetop = { version = "0.0", path = "../../pagetop" } diff --git a/examples/hello-world/src/main.rs b/examples/hello-world/src/main.rs new file mode 100644 index 00000000..502153f8 --- /dev/null +++ b/examples/hello-world/src/main.rs @@ -0,0 +1,20 @@ +use pagetop::prelude::*; + +struct HelloWorld; + +impl ModuleTrait for HelloWorld { + fn configure_service(&self, cfg: &mut server::web::ServiceConfig) { + cfg.route("/", server::web::get().to(hello_world)); + } +} + +async fn hello_world(request: server::HttpRequest) -> ResultPage { + Page::new(request) + .with_in("content", L10n::html(html! {h1 { "Hello World!"}})) + .render() +} + +#[actix_web::main] +async fn main() -> std::io::Result<()> { + Application::prepare(&HelloWorld).unwrap().run()?.await +} diff --git a/pagetop-admin/src/summary.rs b/pagetop-admin/src/summary.rs index d12b692d..595b0edf 100644 --- a/pagetop-admin/src/summary.rs +++ b/pagetop-admin/src/summary.rs @@ -57,8 +57,8 @@ pub async fn summary(request: server::HttpRequest) -> ResultPage ResultPage { "/homedemo/css/styles.css", ))) .with_body_classes(ClassesOp::AddFirst, "default-homepage") - .with_this_in("content", hello_world()) - .with_this_in("content", welcome()) - .with_this_in("content", about_pagetop()) - .with_this_in("content", promo_pagetop()) - .with_this_in("content", reporting_issues()) + .with_in("content", hello_world()) + .with_in("content", welcome()) + .with_in("content", about_pagetop()) + .with_in("content", promo_pagetop()) + .with_in("content", reporting_issues()) .render() } diff --git a/pagetop-user/src/lib.rs b/pagetop-user/src/lib.rs index 31d75650..eac858e9 100644 --- a/pagetop-user/src/lib.rs +++ b/pagetop-user/src/lib.rs @@ -43,7 +43,7 @@ impl ModuleTrait for User { async fn login(request: server::HttpRequest) -> ResultPage { Page::new(request) .with_title(L10n::text("Identificación del usuario")) - .with_this_in( + .with_in( "content", Container::new() .with_id("welcome") diff --git a/pagetop/src/config.rs b/pagetop/src/config.rs index 9f692f7b..e0c47130 100644 --- a/pagetop/src/config.rs +++ b/pagetop/src/config.rs @@ -202,10 +202,10 @@ pub struct Settings { /// Ver [`Settings`]. pub struct App { /// El nombre de la aplicación. - /// Por defecto: *"PageTop Application"*. + /// Por defecto: *"PageTop App"*. pub name: String, /// Una descripción breve de la aplicación. - /// Por defecto: *"Developed with the amazing PageTop framework."*. + /// Por defecto: *"Modular web solutions made simple with PageTop."*. pub description: String, /// Tema predeterminado. /// Por defecto: *"Basic"*. @@ -308,8 +308,8 @@ pub struct Server { define_config!(SETTINGS as Settings, // [app] - "app.name" => "PageTop Application", - "app.description" => "Developed with the amazing PageTop framework.", + "app.name" => "PageTop App", + "app.description" => "Modular web solutions made simple with PageTop.", "app.theme" => "Basic", "app.language" => "en-US", "app.direction" => "ltr", diff --git a/pagetop/src/response/fatal_error.rs b/pagetop/src/response/fatal_error.rs index 4b82bd27..dce7be90 100644 --- a/pagetop/src/response/fatal_error.rs +++ b/pagetop/src/response/fatal_error.rs @@ -33,7 +33,7 @@ impl fmt::Display for FatalError { let error_page = Page::new(request.clone()); if let Ok(page) = error_page .with_title(L10n::text("Error FORBIDDEN")) - .with_this_in("content", error403::Error403) + .with_in("content", error403::Error403) .with_template("error") .render() { @@ -47,7 +47,7 @@ impl fmt::Display for FatalError { let error_page = Page::new(request.clone()); if let Ok(page) = error_page .with_title(L10n::text("Error RESOURCE NOT FOUND")) - .with_this_in("content", error404::Error404) + .with_in("content", error404::Error404) .with_template("error") .render() { diff --git a/pagetop/src/response/page/definition.rs b/pagetop/src/response/page/definition.rs index 4b6b2c94..49bef122 100644 --- a/pagetop/src/response/page/definition.rs +++ b/pagetop/src/response/page/definition.rs @@ -102,11 +102,7 @@ impl Page { } #[fn_builder] - pub fn alter_this_in( - &mut self, - region: &'static str, - component: impl ComponentTrait, - ) -> &mut Self { + pub fn alter_in(&mut self, region: &'static str, component: impl ComponentTrait) -> &mut Self { self.regions.add_to(region, component); self } diff --git a/tests/Cargo.toml b/tests/Cargo.toml new file mode 100644 index 00000000..29ac8465 --- /dev/null +++ b/tests/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "tests" +version = "0.0.1" +edition = "2021" + +authors = [ + "Manuel Cillero " +] +description = """\ + Test for PageTop.\ +""" +homepage = "https://pagetop.cillero.es" +repository = "https://github.com/manuelcillero/pagetop" +license = "Apache-2.0 OR MIT" + +[dependencies] +actix-web = "4" +pagetop = { version = "0.0", path = "../pagetop", features = ["mysql"], default-features = false } diff --git a/tests/src/main.rs b/tests/src/main.rs new file mode 100644 index 00000000..df4adf9f --- /dev/null +++ b/tests/src/main.rs @@ -0,0 +1 @@ +mod server; diff --git a/pagetop/tests/main.rs b/tests/src/server.rs similarity index 100% rename from pagetop/tests/main.rs rename to tests/src/server.rs diff --git a/pagetop/tests/health_check.rs b/tests/src/server/health_check.rs similarity index 100% rename from pagetop/tests/health_check.rs rename to tests/src/server/health_check.rs