✅ Define la estructura para tests y ejemplos
This commit is contained in:
parent
cd76355430
commit
0af85c4d77
14 changed files with 74 additions and 24 deletions
12
Cargo.toml
12
Cargo.toml
|
|
@ -7,19 +7,21 @@ members = [
|
||||||
"pagetop-build",
|
"pagetop-build",
|
||||||
"pagetop-jquery",
|
"pagetop-jquery",
|
||||||
"pagetop-homedemo",
|
"pagetop-homedemo",
|
||||||
"pagetop-megamenu",
|
|
||||||
# Components.
|
# Components.
|
||||||
"pagetop-minimal",
|
"pagetop-minimal",
|
||||||
# Themes.
|
"pagetop-megamenu",
|
||||||
"pagetop-aliner",
|
|
||||||
"pagetop-bootsier",
|
|
||||||
"pagetop-bulmix",
|
|
||||||
# Modules.
|
# Modules.
|
||||||
"pagetop-admin",
|
"pagetop-admin",
|
||||||
"pagetop-user",
|
"pagetop-user",
|
||||||
"pagetop-node",
|
"pagetop-node",
|
||||||
|
# Themes.
|
||||||
|
"pagetop-aliner",
|
||||||
|
"pagetop-bootsier",
|
||||||
|
"pagetop-bulmix",
|
||||||
]
|
]
|
||||||
|
|
||||||
exclude = [
|
exclude = [
|
||||||
"drust",
|
"drust",
|
||||||
|
"examples",
|
||||||
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
4
examples/Cargo.toml
Normal file
4
examples/Cargo.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"hello-world",
|
||||||
|
]
|
||||||
9
examples/hello-world/Cargo.toml
Normal file
9
examples/hello-world/Cargo.toml
Normal 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" }
|
||||||
20
examples/hello-world/src/main.rs
Normal file
20
examples/hello-world/src/main.rs
Normal 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
|
||||||
|
}
|
||||||
|
|
@ -57,8 +57,8 @@ pub async fn summary(request: server::HttpRequest) -> ResultPage<Markup, FatalEr
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_context(ContextOp::Theme("Bootsier"))
|
.with_context(ContextOp::Theme("Bootsier"))
|
||||||
.with_title(L10n::text("Admin"))
|
.with_title(L10n::text("Admin"))
|
||||||
.with_this_in("top-menu", top_menu)
|
.with_in("top-menu", top_menu)
|
||||||
.with_this_in(
|
.with_in(
|
||||||
"content",
|
"content",
|
||||||
grid::Row::new()
|
grid::Row::new()
|
||||||
.with_column(grid::Column::new().with_component(side_menu))
|
.with_column(grid::Column::new().with_component(side_menu))
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@ async fn demo(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
|
||||||
"/homedemo/css/styles.css",
|
"/homedemo/css/styles.css",
|
||||||
)))
|
)))
|
||||||
.with_body_classes(ClassesOp::AddFirst, "default-homepage")
|
.with_body_classes(ClassesOp::AddFirst, "default-homepage")
|
||||||
.with_this_in("content", hello_world())
|
.with_in("content", hello_world())
|
||||||
.with_this_in("content", welcome())
|
.with_in("content", welcome())
|
||||||
.with_this_in("content", about_pagetop())
|
.with_in("content", about_pagetop())
|
||||||
.with_this_in("content", promo_pagetop())
|
.with_in("content", promo_pagetop())
|
||||||
.with_this_in("content", reporting_issues())
|
.with_in("content", reporting_issues())
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ impl ModuleTrait for User {
|
||||||
async fn login(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
|
async fn login(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_title(L10n::text("Identificación del usuario"))
|
.with_title(L10n::text("Identificación del usuario"))
|
||||||
.with_this_in(
|
.with_in(
|
||||||
"content",
|
"content",
|
||||||
Container::new()
|
Container::new()
|
||||||
.with_id("welcome")
|
.with_id("welcome")
|
||||||
|
|
|
||||||
|
|
@ -202,10 +202,10 @@ pub struct Settings {
|
||||||
/// Ver [`Settings`].
|
/// Ver [`Settings`].
|
||||||
pub struct App {
|
pub struct App {
|
||||||
/// El nombre de la aplicación.
|
/// El nombre de la aplicación.
|
||||||
/// Por defecto: *"PageTop Application"*.
|
/// Por defecto: *"PageTop App"*.
|
||||||
pub name: String,
|
pub name: String,
|
||||||
/// Una descripción breve de la aplicación.
|
/// 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,
|
pub description: String,
|
||||||
/// Tema predeterminado.
|
/// Tema predeterminado.
|
||||||
/// Por defecto: *"Basic"*.
|
/// Por defecto: *"Basic"*.
|
||||||
|
|
@ -308,8 +308,8 @@ pub struct Server {
|
||||||
|
|
||||||
define_config!(SETTINGS as Settings,
|
define_config!(SETTINGS as Settings,
|
||||||
// [app]
|
// [app]
|
||||||
"app.name" => "PageTop Application",
|
"app.name" => "PageTop App",
|
||||||
"app.description" => "Developed with the amazing PageTop framework.",
|
"app.description" => "Modular web solutions made simple with PageTop.",
|
||||||
"app.theme" => "Basic",
|
"app.theme" => "Basic",
|
||||||
"app.language" => "en-US",
|
"app.language" => "en-US",
|
||||||
"app.direction" => "ltr",
|
"app.direction" => "ltr",
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ impl fmt::Display for FatalError {
|
||||||
let error_page = Page::new(request.clone());
|
let error_page = Page::new(request.clone());
|
||||||
if let Ok(page) = error_page
|
if let Ok(page) = error_page
|
||||||
.with_title(L10n::text("Error FORBIDDEN"))
|
.with_title(L10n::text("Error FORBIDDEN"))
|
||||||
.with_this_in("content", error403::Error403)
|
.with_in("content", error403::Error403)
|
||||||
.with_template("error")
|
.with_template("error")
|
||||||
.render()
|
.render()
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +47,7 @@ impl fmt::Display for FatalError {
|
||||||
let error_page = Page::new(request.clone());
|
let error_page = Page::new(request.clone());
|
||||||
if let Ok(page) = error_page
|
if let Ok(page) = error_page
|
||||||
.with_title(L10n::text("Error RESOURCE NOT FOUND"))
|
.with_title(L10n::text("Error RESOURCE NOT FOUND"))
|
||||||
.with_this_in("content", error404::Error404)
|
.with_in("content", error404::Error404)
|
||||||
.with_template("error")
|
.with_template("error")
|
||||||
.render()
|
.render()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -102,11 +102,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_this_in(
|
pub fn alter_in(&mut self, region: &'static str, component: impl ComponentTrait) -> &mut Self {
|
||||||
&mut self,
|
|
||||||
region: &'static str,
|
|
||||||
component: impl ComponentTrait,
|
|
||||||
) -> &mut Self {
|
|
||||||
self.regions.add_to(region, component);
|
self.regions.add_to(region, component);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
tests/Cargo.toml
Normal file
18
tests/Cargo.toml
Normal 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
1
tests/src/main.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mod server;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue