♻️ Refactor to include homedemo as welcome package
This commit is contained in:
parent
ae030b5889
commit
d50edff466
25 changed files with 357 additions and 438 deletions
|
|
@ -4,4 +4,6 @@ pub mod action;
|
|||
|
||||
pub mod component;
|
||||
|
||||
pub mod package;
|
||||
|
||||
pub mod theme;
|
||||
|
|
|
|||
2
src/base/package.rs
Normal file
2
src/base/package.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mod welcome;
|
||||
pub use welcome::Welcome;
|
||||
200
src/base/package/welcome.rs
Normal file
200
src/base/package/welcome.rs
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub struct Welcome;
|
||||
|
||||
impl PackageTrait for Welcome {
|
||||
fn name(&self) -> L10n {
|
||||
L10n::l("welcome_package_name")
|
||||
}
|
||||
|
||||
fn description(&self) -> L10n {
|
||||
L10n::l("welcome_package_description")
|
||||
}
|
||||
|
||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||
scfg.route("/", service::web::get().to(demo));
|
||||
}
|
||||
}
|
||||
|
||||
async fn demo(request: service::HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||
Page::new(request)
|
||||
.with_title(L10n::l("welcome_title"))
|
||||
.with_context(ContextOp::AddStyleSheet(StyleSheet::at(
|
||||
"/base/css/welcome.css",
|
||||
)))
|
||||
.with_body_id("welcome")
|
||||
.with_component_in("content", hello_world())
|
||||
.with_component_in("content", welcome())
|
||||
.with_component_in("content", about_pagetop())
|
||||
.with_component_in("content", promo_pagetop())
|
||||
.with_component_in("content", reporting_issues())
|
||||
.render()
|
||||
}
|
||||
|
||||
fn hello_world() -> Wrapper {
|
||||
Wrapper::header()
|
||||
.with_classes(ClassesOp::Add, "hello-world")
|
||||
.add_component(
|
||||
flex::Container::new()
|
||||
.with_direction(flex::Direction::Column(BreakPoint::MD))
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "hello-col-text")
|
||||
.with_size(flex::ItemSize::Percent40)
|
||||
.add_component(
|
||||
Heading::h1(L10n::l("welcome_title")).with_size(HeadingSize::Medium),
|
||||
)
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::l("welcome_intro").with_arg(
|
||||
"app",
|
||||
format!(
|
||||
"<span class=\"app-name\">{}</span>",
|
||||
&config::SETTINGS.app.name,
|
||||
),
|
||||
))
|
||||
.with_font_size(FontSize::Medium),
|
||||
)
|
||||
.add_component(Paragraph::translated(L10n::l("welcome_powered").with_arg(
|
||||
"pagetop",
|
||||
format!(
|
||||
"<a href=\"{}\" target=\"_blank\">{}</a>",
|
||||
"https://pagetop.cillero.es", "PageTop",
|
||||
),
|
||||
)))
|
||||
.add_component(
|
||||
Button::anchor(
|
||||
"https://github.com/manuelcillero/pagetop",
|
||||
L10n::l("welcome_code"),
|
||||
)
|
||||
.with_target(ButtonTarget::Blank)
|
||||
.with_left_icon(Some(Icon::with("git")))
|
||||
.with_classes(ClassesOp::Add, "code-link")
|
||||
.with_font_size(FontSize::Medium),
|
||||
)
|
||||
.add_component(
|
||||
Button::anchor("#welcome-page", L10n::l("welcome"))
|
||||
.with_style(ButtonStyle::Link)
|
||||
.with_left_icon(Some(Icon::with("arrow-down-circle-fill")))
|
||||
.with_classes(ClassesOp::Add, "welcome-link")
|
||||
.with_font_size(FontSize::Medium),
|
||||
),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "hello-col-image")
|
||||
.with_size(flex::ItemSize::Percent60)
|
||||
.add_component(Image::with("/base/images/header.svg")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn welcome() -> Wrapper {
|
||||
Wrapper::section()
|
||||
.with_id("welcome-page")
|
||||
.with_classes(ClassesOp::Add, "welcome")
|
||||
.add_component(Heading::h2(L10n::l("welcome_page")))
|
||||
.add_component(
|
||||
Heading::h3(L10n::l("welcome_subtitle").with_arg(
|
||||
"app",
|
||||
format!(
|
||||
"<span class=\"app-name\">{}</span>",
|
||||
&config::SETTINGS.app.name
|
||||
),
|
||||
))
|
||||
.with_size(HeadingSize::Subtitle),
|
||||
)
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::l("welcome_text1")).with_font_size(FontSize::Medium),
|
||||
)
|
||||
.add_component(Paragraph::translated(L10n::l("welcome_text2")))
|
||||
}
|
||||
|
||||
fn about_pagetop() -> Wrapper {
|
||||
Wrapper::new()
|
||||
.with_classes(ClassesOp::Add, "pagetop")
|
||||
.add_component(
|
||||
flex::Container::new()
|
||||
.with_direction(flex::Direction::Column(BreakPoint::SM))
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "pagetop-col-image")
|
||||
.with_size(flex::ItemSize::Percent40)
|
||||
.add_component(Image::with("/base/images/about.svg")),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "pagetop-col-text")
|
||||
.add_component(Heading::h2(L10n::l("welcome_pagetop_title")))
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::l("welcome_pagetop_text1"))
|
||||
.with_font_size(FontSize::Medium),
|
||||
)
|
||||
.add_component(Paragraph::translated(L10n::l("welcome_pagetop_text2")))
|
||||
.add_component(Paragraph::translated(L10n::l("welcome_pagetop_text3"))),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn promo_pagetop() -> Wrapper {
|
||||
Wrapper::new()
|
||||
.with_classes(ClassesOp::Add, "promo")
|
||||
.add_component(
|
||||
flex::Container::new()
|
||||
.with_direction(flex::Direction::Column(BreakPoint::MD))
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "promo-col-text")
|
||||
.with_size(flex::ItemSize::Percent50)
|
||||
.add_component(Heading::h2(L10n::l("welcome_promo_title")))
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::l("welcome_promo_text1").with_arg(
|
||||
"pagetop",
|
||||
format!(
|
||||
"<a href=\"{}\" target=\"_blank\">{}</a>",
|
||||
"https://crates.io/crates/pagetop", "PageTop",
|
||||
),
|
||||
))
|
||||
.with_font_size(FontSize::Medium),
|
||||
),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "promo-col-image")
|
||||
.with_size(flex::ItemSize::Percent50)
|
||||
.add_component(Image::with("/base/images/pagetop.png")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn reporting_issues() -> Wrapper {
|
||||
Wrapper::new()
|
||||
.with_classes(ClassesOp::Add, "issues")
|
||||
.add_component(
|
||||
flex::Container::new()
|
||||
.with_direction(flex::Direction::Column(BreakPoint::MD))
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "issues-col-image")
|
||||
.add_component(Image::with("/base/images/issues.jpg")),
|
||||
)
|
||||
.add_item(
|
||||
flex::Item::new()
|
||||
.with_inner_classes(ClassesOp::Add, "issues-col-text")
|
||||
.with_size(flex::ItemSize::Percent50)
|
||||
.add_component(Heading::h2(L10n::l("welcome_issues_title")))
|
||||
.add_component(
|
||||
Paragraph::translated(L10n::l("welcome_issues_text1"))
|
||||
.with_font_size(FontSize::Medium),
|
||||
)
|
||||
.add_component(Paragraph::translated(
|
||||
L10n::l("welcome_issues_text2").with_arg(
|
||||
"app",
|
||||
format!(
|
||||
"<span class=\"app-name\">{}</span>",
|
||||
&config::SETTINGS.app.name,
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@ pub fn register_packages(app: PackageRef) {
|
|||
// Enable application packages.
|
||||
add_to_enabled(&mut list, app);
|
||||
|
||||
// Enable default welcome page.
|
||||
add_to_enabled(&mut list, &crate::base::package::Welcome);
|
||||
|
||||
list.reverse();
|
||||
ENABLED_PACKAGES.write().unwrap().append(&mut list);
|
||||
}
|
||||
|
|
|
|||
26
src/locale/en-US/welcome.ftl
Normal file
26
src/locale/en-US/welcome.ftl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
welcome_package_name = Default homepage
|
||||
welcome_package_description = Displays a demo homepage when none is configured.
|
||||
|
||||
welcome_title = Hello world!
|
||||
|
||||
welcome_intro = This page is used to check the proper operation of the { $app } installation.
|
||||
welcome_powered = This web solution is powered by { $pagetop }.
|
||||
welcome_code = Code
|
||||
welcome = Welcome
|
||||
|
||||
welcome_page = Welcome page
|
||||
welcome_subtitle = Are you user of { $app }?
|
||||
welcome_text1 = If you don't know what this page is about, this probably means that the site is either experiencing problems or is undergoing routine maintenance.
|
||||
welcome_text2 = If the problem persists, please contact your system administrator.
|
||||
|
||||
welcome_pagetop_title = About PageTop
|
||||
welcome_pagetop_text1 = If you can read this page, it means that the PageTop server is working properly, but has not yet been configured.
|
||||
welcome_pagetop_text2 = PageTop is a <a href="https://www.rust-lang.org" target="_blank">Rust</a>-based web development framework to build modular, extensible, and configurable web solutions.
|
||||
welcome_pagetop_text3 = For more information on PageTop please visit the <a href="https://docs.rs/pagetop/latest/pagetop" target="_blank">technical documentation</a>.
|
||||
|
||||
welcome_promo_title = Promoting PageTop
|
||||
welcome_promo_text1 = You are free to use the image below on applications powered by { $pagetop }. Thanks for using PageTop!
|
||||
|
||||
welcome_issues_title = Reporting problems
|
||||
welcome_issues_text1 = Please use <a href="https://github.com/manuelcillero/pagetop/issues" target="_blank">GitHub to report any issues</a> with PageTop. However, check the existing error reports before submitting a new issue.
|
||||
welcome_issues_text2 = If the issues are specific to { $app }, please refer to its official repository or support channel, rather than directly to PageTop.
|
||||
26
src/locale/es-ES/welcome.ftl
Normal file
26
src/locale/es-ES/welcome.ftl
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
welcome_package_name = Página de inicio predeterminada
|
||||
welcome_package_description = Muestra una página de demostración predeterminada cuando no hay ninguna configurada.
|
||||
|
||||
welcome_title = ¡Hola mundo!
|
||||
|
||||
welcome_intro = Esta página se utiliza para verificar el correcto funcionamiento de la instalación de { $app }.
|
||||
welcome_powered = Esta solución web funciona con { $pagetop }.
|
||||
welcome_code = Código
|
||||
welcome = Bienvenida
|
||||
|
||||
welcome_page = Página de bienvenida
|
||||
welcome_subtitle = ¿Eres usuario de { $app }?
|
||||
welcome_text1 = Si no sabes de qué trata esta página, probablemente significa que el sitio está experimentando problemas o está pasando por un mantenimiento de rutina.
|
||||
welcome_text2 = Si el problema persiste, póngase en contacto con el administrador del sistema.
|
||||
|
||||
welcome_pagetop_title = Sobre PageTop
|
||||
welcome_pagetop_text1 = Si puedes leer esta página, significa que el servidor PageTop funciona correctamente, pero aún no se ha configurado.
|
||||
welcome_pagetop_text2 = PageTop es un entorno de desarrollo web basado en <a href="https://www.rust-lang.org/es" target="_blank">Rust</a> para construir soluciones web modulares, extensibles y configurables.
|
||||
welcome_pagetop_text3 = Para más información sobre PageTop, por favor visita la <a href="https://docs.rs/pagetop/latest/pagetop" target="_blank">documentación técnica</a>.
|
||||
|
||||
welcome_promo_title = Promociona PageTop
|
||||
welcome_promo_text1 = Eres libre de usar la siguiente imagen en aplicaciones desarrolladas con { $pagetop }. ¡Gracias por usar PageTop!
|
||||
|
||||
welcome_issues_title = Informando problemas
|
||||
welcome_issues_text1 = Por favor, utiliza <a href="https://github.com/manuelcillero/pagetop/issues" target="_blank">GitHub para reportar cualquier problema</a> con PageTop. No obstante, comprueba los informes de errores existentes antes de enviar uno nuevo.
|
||||
welcome_issues_text2 = Si son fallos específicos de { $app }, por favor acude a su repositorio o canal de soporte oficial y no al de PageTop directamente.
|
||||
Loading…
Add table
Add a link
Reference in a new issue