🎨 Unifica parámetros y estilos del tema básico

Ofrece dos composiciones de página dirigidas a una introducción de
contenidos neutra o con referencias a PageTop.
This commit is contained in:
Manuel Cillero 2025-09-18 23:38:25 +02:00
parent aae6c7df15
commit 36e2d9bec8
8 changed files with 130 additions and 84 deletions

View file

@ -25,55 +25,30 @@ async fn homepage(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
let app = &global::SETTINGS.app.name;
Page::new(request)
.with_theme("basic")
.with_layout("intro")
.with_theme("Basic")
.with_layout("PageTopIntro")
.with_title(L10n::l("welcome_title"))
.with_description(L10n::l("welcome_intro").with_arg("app", app))
.with_param("intro_button_text", L10n::l("welcome_powered"))
.with_param("intro_button_link", "https://pagetop.cillero.es".to_string())
.with_assets(AssetsOp::AddJavaScript(JavaScript::on_load_async("welcome-js", |cx|
util::indoc!(r#"
try {
const resp = await fetch("https://crates.io/api/v1/crates/pagetop");
const data = await resp.json();
const date = new Date(data.versions[0].created_at);
const formatted = date.toLocaleDateString("LANGID", { year: "numeric", month: "2-digit", day: "2-digit" });
document.getElementById("welcome-release").src = `https://img.shields.io/badge/Release%20date-${encodeURIComponent(formatted)}-blue?label=LABEL&style=for-the-badge`;
document.getElementById("welcome-badges").style.display = "block";
} catch (e) {
console.error("Failed to fetch release date from crates.io:", e);
}
"#)
.replace("LANGID", cx.langid().to_string().as_str())
.replace("LABEL", L10n::l("welcome_release_label").using(cx).as_str())
.to_string(),
)))
.add_component(Html::with(|cx| html! {
p { (L10n::l("welcome_text1").using(cx)) }
div id="welcome-badges" style="display: none; margin-bottom: 1.1rem;" {
img
src="https://img.shields.io/crates/v/pagetop.svg?label=PageTop&style=for-the-badge"
alt=[L10n::l("welcome_pagetop_label").lookup(cx)] {} (" ")
img
id="welcome-release"
alt=[L10n::l("welcome_release_label").lookup(cx)] {} (" ")
img
src=(format!(
"https://img.shields.io/badge/license-MIT%2FApache-blue.svg?label={}&style=for-the-badge",
L10n::l("welcome_license_label").lookup(cx).unwrap_or_default()
))
alt=[L10n::l("welcome_license_label").lookup(cx)] {}
}
p { (L10n::l("welcome_text2").using(cx)) }
}))
.with_param("intro_button_txt", L10n::l("welcome_powered"))
.with_param("intro_button_lnk", "https://pagetop.cillero.es".to_string())
.add_component(
Block::new()
.with_title(L10n::l("welcome_notice_title"))
.add_component(Html::with(move |cx| html! {
p { (L10n::l("welcome_notice_1").using(cx)) }
p { (L10n::l("welcome_notice_2").using(cx)) }
p { (L10n::l("welcome_notice_3").using(cx)) }
p { (L10n::l("welcome_notice_4").with_arg("app", app).using(cx)) }
.with_title(L10n::l("welcome_status_title"))
.add_component(Html::with(move |cx| {
html! {
p { (L10n::l("welcome_status_1").using(cx)) }
p { (L10n::l("welcome_status_2").using(cx)) }
}
})),
)
.add_component(
Block::new()
.with_title(L10n::l("welcome_support_title"))
.add_component(Html::with(move |cx| {
html! {
p { (L10n::l("welcome_support_1").using(cx)) }
p { (L10n::l("welcome_support_2").with_arg("app", app).using(cx)) }
}
})),
)
.render()