Añade módulo User y componentes para formularios

This commit is contained in:
Manuel Cillero 2022-02-20 23:01:11 +01:00
parent 1d438dff57
commit d38df3a5b6
21 changed files with 1228 additions and 26 deletions

View file

@ -14,16 +14,57 @@ impl Module for HomepageModule {
}
fn configure_module(&self, cfg: &mut server::web::ServiceConfig) {
cfg.service(server::web::resource("/").to(home));
cfg.service(server::web::resource("/{name}").to(home));
cfg.route("/", server::web::get().to(home));
}
}
async fn home(req: server::HttpRequest) -> server::Result<Markup> {
let name: String = req.match_info().get("name").unwrap_or("World").into();
async fn home() -> server::Result<Markup> {
Page::prepare()
.add_to("content", Chunck::markup(html! {
h1 { (t("greetings", &args![ "name" => name])) }
}))
.with_title(
l("page_title").as_str()
)
.add_to("content", Container::prepare()
.with_id("welcome")
.add(Chunck::markup(html! {
h1 { (l("page_title")) }
p { (e("text_welcome", &args![
"app" => format!("<strong>{}</strong>", &SETTINGS.app.name),
"pagetop" => "<a href=\"https://pagetop-rs\">PageTop</a>"
])) }
}))
)
.add_to("content", Container::prepare()
.add(Container::row()
.add(Container::column()
.with_id("visitors")
.add(Chunck::markup(html! {
h2 { (l("title_normal_user")) }
p { (l("text1_normal_user")) }
p { (l("text2_normal_user")) }
})))
.add(Container::column()
.with_id("pagetop")
.add(Chunck::markup(html! {
h2 { (l("title_about_pagetop")) }
p { (l("text1_about_pagetop")) }
p { (l("text2_about_pagetop")) }
h2 { (l("title_promo_pagetop")) }
p { (e("text1_promo_pagetop", &args![
"pagetop" =>
"<a href=\"https://pagetop-rs\">PageTop</a>"
])) }
}))
)
)
)
.add_to("content", Container::prepare()
.with_id("reporting")
.add(Chunck::markup(html! {
h2 { (l("title_report_problems")) }
p { (l("text1_report_problems")) }
p { (l("text2_report_problems")) }
}))
)
.render()
}