Define la estructura para tests y ejemplos

This commit is contained in:
Manuel Cillero 2023-06-09 10:33:54 +02:00
parent cd76355430
commit 0af85c4d77
14 changed files with 74 additions and 24 deletions

View file

@ -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",
]

4
examples/Cargo.toml Normal file
View file

@ -0,0 +1,4 @@
[workspace]
members = [
"hello-world",
]

View file

@ -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" }

View file

@ -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<Markup, FatalError> {
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
}

View file

@ -57,8 +57,8 @@ pub async fn summary(request: server::HttpRequest) -> ResultPage<Markup, FatalEr
Page::new(request)
.with_context(ContextOp::Theme("Bootsier"))
.with_title(L10n::text("Admin"))
.with_this_in("top-menu", top_menu)
.with_this_in(
.with_in("top-menu", top_menu)
.with_in(
"content",
grid::Row::new()
.with_column(grid::Column::new().with_component(side_menu))

View file

@ -39,11 +39,11 @@ async fn demo(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
"/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()
}

View file

@ -43,7 +43,7 @@ impl ModuleTrait for User {
async fn login(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
Page::new(request)
.with_title(L10n::text("Identificación del usuario"))
.with_this_in(
.with_in(
"content",
Container::new()
.with_id("welcome")

View file

@ -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",

View file

@ -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()
{

View file

@ -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
}

18
tests/Cargo.toml Normal file
View file

@ -0,0 +1,18 @@
[package]
name = "tests"
version = "0.0.1"
edition = "2021"
authors = [
"Manuel Cillero <manuel@cillero.es>"
]
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 }

1
tests/src/main.rs Normal file
View file

@ -0,0 +1 @@
mod server;