use crate::prelude::*; /// Página de bienvenida de PageTop. /// /// Esta extensión se instala por defecto si el ajuste de configuración [`global::App::welcome`] es /// `true`. Muestra una página de bienvenida de PageTop en la ruta raíz (`/`). /// /// No obstante, cualquier extensión puede sobrescribir este comportamiento si utiliza estas mismas /// rutas. /// /// Resulta útil en demos o para comprobar rápidamente que el servidor ha arrancado correctamente. pub struct Welcome; impl Extension for Welcome { fn name(&self) -> L10n { L10n::l("welcome_extension_name") } fn description(&self) -> L10n { L10n::l("welcome_extension_description") } fn configure_service(&self, scfg: &mut service::web::ServiceConfig) { scfg.route("/", service::web::get().to(home)); } } async fn home(request: HttpRequest) -> ResultPage { let app = &global::SETTINGS.app.name; Page::new(request) .with_title(L10n::l("welcome_title")) .with_child( Intro::new() .with_child( Block::new() .with_title(L10n::l("welcome_status_title")) .with_child(Html::with(move |cx| { html! { p class="intro-text-lead" { (L10n::l("welcome_status_1").using(cx)) } p class="intro-text-lead" { (L10n::l("welcome_status_2").using(cx)) } } })), ) .with_child( Block::new() .with_title(L10n::l("welcome_support_title")) .with_child(Html::with(move |cx| { html! { p class="intro-text-lead" { (L10n::l("welcome_support_1").using(cx)) } p class="intro-text-lead" { (L10n::l("welcome_support_2").with_arg("app", app).using(cx)) } } })), ), ) .render() }