Structure files according to MVC
This commit is contained in:
parent
7f42e04494
commit
fc9d7059f4
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -351,7 +351,6 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"maud",
|
"maud",
|
||||||
"rocket",
|
"rocket",
|
||||||
"rocket_session",
|
|
||||||
"serde",
|
"serde",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
]
|
]
|
||||||
@ -1430,17 +1429,6 @@ dependencies = [
|
|||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rocket_session"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9a1a0f6637aba596ac1975584479638b9350d54187f4c745584d046b3dd1ea6f"
|
|
||||||
dependencies = [
|
|
||||||
"parking_lot",
|
|
||||||
"rand",
|
|
||||||
"rocket",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rsa"
|
name = "rsa"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
|
@ -8,6 +8,5 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
maud = { version = "0.26.0", features = ["rocket"] }
|
maud = { version = "0.26.0", features = ["rocket"] }
|
||||||
rocket = "0.5.0"
|
rocket = "0.5.0"
|
||||||
rocket_session = "0.3.0"
|
|
||||||
serde = "1.0.196"
|
serde = "1.0.196"
|
||||||
sqlx = { version = "0.7.3", features = ["postgres"] }
|
sqlx = { version = "0.7.3", features = ["postgres"] }
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
use maud::Markup;
|
||||||
|
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
pub mod register;
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
pub fn index() -> Markup {
|
||||||
|
crate::view::login::login()
|
||||||
|
}
|
||||||
|
|
||||||
|
6
src/controller/register.rs
Normal file
6
src/controller/register.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
use maud::Markup;
|
||||||
|
|
||||||
|
#[get("/register")]
|
||||||
|
pub fn get() -> Markup {
|
||||||
|
crate::view::register::register()
|
||||||
|
}
|
@ -11,7 +11,8 @@ extern crate rocket;
|
|||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
rocket::build()
|
rocket::build()
|
||||||
.mount("/", routes![
|
.mount("/", routes![
|
||||||
view::index,
|
controller::index,
|
||||||
|
|
||||||
])
|
])
|
||||||
.mount("/f", routes![
|
.mount("/f", routes![
|
||||||
controller::user::create_user,
|
controller::user::create_user,
|
||||||
|
9
src/view/login.rs
Normal file
9
src/view/login.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
use maud::{html, Markup};
|
||||||
|
|
||||||
|
use super::default_skeleton;
|
||||||
|
|
||||||
|
pub fn login() -> Markup {
|
||||||
|
default_skeleton(html! {
|
||||||
|
"TODO"
|
||||||
|
})
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
use maud::{html, Markup, DOCTYPE};
|
use maud::{html, Markup, DOCTYPE};
|
||||||
|
|
||||||
mod fragments;
|
pub mod fragments;
|
||||||
|
pub mod login;
|
||||||
|
pub mod register;
|
||||||
|
|
||||||
#[get("/")]
|
pub fn default_skeleton(content: Markup) -> Markup {
|
||||||
pub fn index() -> Markup {
|
|
||||||
html! {
|
html! {
|
||||||
(DOCTYPE)
|
(DOCTYPE)
|
||||||
html lang="es" {
|
html lang="es" {
|
||||||
@ -18,42 +19,7 @@ pub fn index() -> Markup {
|
|||||||
script defer src="https://unpkg.com/htmx.org/dist/ext/loading-states.js" {}
|
script defer src="https://unpkg.com/htmx.org/dist/ext/loading-states.js" {}
|
||||||
}
|
}
|
||||||
body hx-ext="response-targets, class-tools, loading-states" {
|
body hx-ext="response-targets, class-tools, loading-states" {
|
||||||
h1 { "Registrar nuevo usuario" }
|
(content)
|
||||||
div
|
|
||||||
x-data="{user_name: '', user_surname: '', user_email: '', user_password: ''}"
|
|
||||||
{
|
|
||||||
form
|
|
||||||
hx-post="/f/user"
|
|
||||||
hx-target="#user_create_response"
|
|
||||||
hx-target-400="#user_create_response"
|
|
||||||
hx-swap="outerHTML"
|
|
||||||
{
|
|
||||||
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
|
||||||
required type="text" name="user_name" placeholder="Nombres"
|
|
||||||
data-loading-disable x-model="user_name";
|
|
||||||
br;
|
|
||||||
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
|
||||||
required type="text" name="user_surname" placeholder="Apellidos"
|
|
||||||
data-loading-disable x-model="user_surname";
|
|
||||||
br;
|
|
||||||
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
|
||||||
required type="email" name="user_email" placeholder="Correo electrónico"
|
|
||||||
data-loading-disable x-model="user_email";
|
|
||||||
br;
|
|
||||||
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
|
||||||
required type="password" name="user_password" placeholder="Contraseña"
|
|
||||||
data-loading-disable x-model="user_password";
|
|
||||||
br;
|
|
||||||
button
|
|
||||||
class="bg-pink-300 text-black py-2 px-4 rounded-full cursor-pointer inline-block my-2 disabled:opacity-50"
|
|
||||||
data-loading-class="animate-pulse" type="submit"
|
|
||||||
{
|
|
||||||
"Registrar"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
br;
|
|
||||||
div id="user_create_response" {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
src/view/register.rs
Normal file
45
src/view/register.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
use maud::{html, Markup};
|
||||||
|
|
||||||
|
use super::default_skeleton;
|
||||||
|
|
||||||
|
pub fn register() -> Markup {
|
||||||
|
default_skeleton(html! {
|
||||||
|
h1 { "Registrar nuevo usuario" }
|
||||||
|
div
|
||||||
|
x-data="{user_name: '', user_surname: '', user_email: '', user_password: ''}"
|
||||||
|
{
|
||||||
|
form
|
||||||
|
hx-post="/f/user"
|
||||||
|
hx-target="#user_create_response"
|
||||||
|
hx-target-400="#user_create_response"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
{
|
||||||
|
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
||||||
|
required type="text" name="user_name" placeholder="Nombres"
|
||||||
|
data-loading-disable x-model="user_name";
|
||||||
|
br;
|
||||||
|
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
||||||
|
required type="text" name="user_surname" placeholder="Apellidos"
|
||||||
|
data-loading-disable x-model="user_surname";
|
||||||
|
br;
|
||||||
|
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
||||||
|
required type="email" name="user_email" placeholder="Correo electrónico"
|
||||||
|
data-loading-disable x-model="user_email";
|
||||||
|
br;
|
||||||
|
input class="bg-c-bg text-c-on-bg border border-c-on-bg disabled:opacity-50"
|
||||||
|
required type="password" name="user_password" placeholder="Contraseña"
|
||||||
|
data-loading-disable x-model="user_password";
|
||||||
|
br;
|
||||||
|
button
|
||||||
|
class="bg-pink-300 text-black py-2 px-4 rounded-full cursor-pointer inline-block my-2 disabled:opacity-50"
|
||||||
|
data-loading-class="animate-pulse" type="submit"
|
||||||
|
{
|
||||||
|
"Registrar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
br;
|
||||||
|
div id="user_create_response" {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user