👽️ Apply latest changes to the API

This commit is contained in:
Manuel Cillero 2023-10-21 21:33:39 +02:00
parent 03d538eb41
commit 718bc5d769
4 changed files with 114 additions and 105 deletions

View file

@ -4,150 +4,150 @@ use pagetop::prelude::*;
pub async fn summary(request: service::HttpRequest) -> ResultPage<Markup, FatalError> {
let top_menu = Menu::new()
.with_item(menu::Item::label(L10n::t("module_name", &LOCALES_ADMIN)))
.with_item(menu::Item::label(L10n::n("Ejemplo \"Label\"")))
.with_item(menu::Item::link(L10n::n("Ejemplo \"Link\""), |_| {
.add_item(menu::Item::label(L10n::t("module_name", &LOCALES_ADMIN)))
.add_item(menu::Item::label(L10n::n("Ejemplo \"Label\"")))
.add_item(menu::Item::link(L10n::n("Ejemplo \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Ejemplo \"LinkBlank\""),
|_| "https://www.google.es",
))
.with_item(menu::Item::submenu(
.add_item(menu::Item::submenu(
L10n::n("Ejemplo Submenú"),
menu::Submenu::new()
.with_title(L10n::n("Título submenú"))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
))
.with_item(menu::Item::submenu(
.add_item(menu::Item::submenu(
L10n::n("Otro submenú con un texto muy, pero que muy largo"),
menu::Submenu::new()
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
))
.with_item(menu::Item::label(L10n::n("Opción \"Label\""))),
.add_item(menu::Item::label(L10n::n("Opción \"Label\""))),
))
.with_item(menu::Item::label(L10n::n("Opción \"Label\""))),
.add_item(menu::Item::label(L10n::n("Opción \"Label\""))),
))
.with_item(menu::Item::megamenu(
.add_item(menu::Item::megamenu(
L10n::n("Ejemplo Megamenú 1"),
menu::Megamenu::new()
.with_group(
.add_group(
menu::Group::new()
.with_element(menu::Element::submenu(
.add_element(menu::Element::submenu(
menu::Submenu::new()
.with_title(L10n::n("Título submenú"))
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
)),
))
.with_element(menu::Element::submenu(
.add_element(menu::Element::submenu(
menu::Submenu::new()
.with_title(L10n::n("Título submenú"))
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
)),
)),
)
.with_group(
menu::Group::new().with_element(menu::Element::submenu(
.add_group(
menu::Group::new().add_element(menu::Element::submenu(
menu::Submenu::new()
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
))
.with_item(menu::Item::label(L10n::n("Opción \"Label\""))),
.add_item(menu::Item::label(L10n::n("Opción \"Label\""))),
)),
)
.with_group(
.add_group(
menu::Group::new()
.with_element(menu::Element::submenu(
.add_element(menu::Element::submenu(
menu::Submenu::new()
.with_title(L10n::n("Título submenú"))
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
)),
))
.with_element(menu::Element::submenu(
.add_element(menu::Element::submenu(
menu::Submenu::new()
.with_title(L10n::n("Título submenú"))
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
)),
)),
)
.with_group(
menu::Group::new().with_element(menu::Element::submenu(
.add_group(
menu::Group::new().add_element(menu::Element::submenu(
menu::Submenu::new()
.with_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.with_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
.add_item(menu::Item::label(L10n::n("Opción \"Label\"")))
.add_item(menu::Item::link(L10n::n("Opción \"Link\""), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(
.add_item(menu::Item::link_blank(
L10n::n("Opción \"LinkBlank\""),
|_| "https://www.google.es",
))
.with_item(menu::Item::label(L10n::n("Opción \"Label\""))),
.add_item(menu::Item::label(L10n::n("Opción \"Label\""))),
)),
),
));
let side_menu = Menu::new()
.with_item(menu::Item::label(L10n::n("Opción 1")))
.with_item(menu::Item::link(L10n::n("Opción 2"), |_| {
.add_item(menu::Item::label(L10n::n("Opción 1")))
.add_item(menu::Item::link(L10n::n("Opción 2"), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::link_blank(L10n::n("Opción 3"), |_| {
.add_item(menu::Item::link_blank(L10n::n("Opción 3"), |_| {
"https://www.google.es"
}))
.with_item(menu::Item::submenu(
.add_item(menu::Item::submenu(
L10n::n("Submenú 1"),
menu::Submenu::new()
.with_item(menu::Item::label(L10n::n("Opción 1")))
.with_item(menu::Item::label(L10n::n("Opción 2"))),
.add_item(menu::Item::label(L10n::n("Opción 1")))
.add_item(menu::Item::label(L10n::n("Opción 2"))),
)) /*
.with_item(menu::Item::separator()) */
.with_item(menu::Item::submenu(
.add_item(menu::Item::separator()) */
.add_item(menu::Item::submenu(
L10n::n("Submenú 2"),
menu::Submenu::new()
.with_item(menu::Item::label(L10n::n("Opción 1")))
.with_item(menu::Item::label(L10n::n("Opción 2"))),
.add_item(menu::Item::label(L10n::n("Opción 1")))
.add_item(menu::Item::label(L10n::n("Opción 2"))),
))
.with_item(menu::Item::label(L10n::n("Opción 4")));
.add_item(menu::Item::label(L10n::n("Opción 4")));
Page::new(request)
//.with_context(ContextOp::Theme("Bootsier"))
@ -156,11 +156,11 @@ pub async fn summary(request: service::HttpRequest) -> ResultPage<Markup, FatalE
.with_in(
"content",
flex::Container::new()
.with_item(flex::Item::new().with_component(Html::with(html! {
.add_item(flex::Item::new().add_component(Html::with(html! {
p { "Columna 1"}
})))
.with_item(flex::Item::new().with_component(top_menu))
.with_item(flex::Item::new().with_component(Html::with(html! {
.add_item(flex::Item::new().add_component(top_menu))
.add_item(flex::Item::new().add_component(Html::with(html! {
p { "Columna 3"}
}))),
)

View file

@ -108,18 +108,21 @@ impl ThemeTrait for Bootsier {
div class="media-body" {
h1 class="display-4" { ("RESOURCE NOT FOUND") }
p class="lead" {
(L10n::t("e404-description", &LOCALES_BOOTSIER).prepare(cx))
(L10n::t("e404-description", &LOCALES_BOOTSIER)
.escaped(cx.langid()))
}
hr class="my-4";
p {
(L10n::t("e404-description", &LOCALES_BOOTSIER).prepare(cx))
(L10n::t("e404-description", &LOCALES_BOOTSIER)
.escaped(cx.langid()))
}
a
class="btn btn-primary btn-lg"
href="/"
role="button"
{
(L10n::t("back-homepage", &LOCALES_BOOTSIER).prepare(cx))
(L10n::t("back-homepage", &LOCALES_BOOTSIER)
.escaped(cx.langid()))
}
}
}

View file

@ -43,19 +43,19 @@ async fn demo(request: service::HttpRequest) -> ResultPage<Markup, FatalError> {
}
fn hello_world() -> Wrapper {
Wrapper::header().with_id("hello-world").with_component(
Wrapper::header().with_id("hello-world").add_component(
flex::Container::new()
.with_direction(flex::Direction::Column(BreakPoint::MD))
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "hello-col-text")
.with_size(flex::ItemSize::Percent40)
.with_component(
.add_component(
Heading::h1(L10n::t("page_title", &LOCALES_HOMEDEMO))
.with_display(HeadingDisplay::Medium),
)
.with_component(
Paragraph::with(L10n::e("hello_intro", &LOCALES_HOMEDEMO).with_arg(
.add_component(
Paragraph::translated(L10n::t("hello_intro", &LOCALES_HOMEDEMO).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
@ -64,8 +64,8 @@ fn hello_world() -> Wrapper {
))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(
L10n::e("hello_powered", &LOCALES_HOMEDEMO).with_arg(
.add_component(Paragraph::translated(
L10n::t("hello_powered", &LOCALES_HOMEDEMO).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
@ -73,7 +73,7 @@ fn hello_world() -> Wrapper {
),
),
))
.with_component(
.add_component(
Anchor::button(
"https://github.com/manuelcillero/pagetop",
L10n::t("hello_code", &LOCALES_HOMEDEMO),
@ -82,17 +82,17 @@ fn hello_world() -> Wrapper {
.with_left_icon(Icon::with("git"))
.with_classes(ClassesOp::Add, "code-link"),
)
.with_component(
.add_component(
Anchor::link("#welcome", L10n::t("hello_welcome", &LOCALES_HOMEDEMO))
.with_left_icon(Icon::with("arrow-down-circle-fill"))
.with_classes(ClassesOp::Add, "welcome-link"),
),
)
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "hello-col-image")
.with_size(flex::ItemSize::Percent60)
.with_component(Image::with("/homedemo/images/header.svg")),
.add_component(Image::with("/homedemo/images/header.svg")),
),
)
}
@ -101,9 +101,9 @@ fn welcome() -> Wrapper {
Wrapper::section()
.with_id("welcome")
.with_classes(ClassesOp::Add, "welcome-col-text")
.with_component(Heading::h2(L10n::t("welcome_page", &LOCALES_HOMEDEMO)))
.with_component(
Heading::h3(L10n::e("welcome_subtitle", &LOCALES_HOMEDEMO).with_arg(
.add_component(Heading::h2(L10n::t("welcome_page", &LOCALES_HOMEDEMO)))
.add_component(
Heading::h3(L10n::t("welcome_subtitle", &LOCALES_HOMEDEMO).with_arg(
"app",
format!(
"<span class=\"app-name\">{}</span>",
@ -112,34 +112,40 @@ fn welcome() -> Wrapper {
))
.with_display(HeadingDisplay::Subtitle),
)
.with_component(
Paragraph::with(L10n::t("welcome_text1", &LOCALES_HOMEDEMO))
.add_component(
Paragraph::translated(L10n::t("welcome_text1", &LOCALES_HOMEDEMO))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(L10n::t("welcome_text2", &LOCALES_HOMEDEMO)))
.add_component(Paragraph::translated(L10n::t(
"welcome_text2",
&LOCALES_HOMEDEMO,
)))
}
fn about_pagetop() -> Wrapper {
Wrapper::new().with_id("pagetop").with_component(
Wrapper::new().with_id("pagetop").add_component(
flex::Container::new()
.with_direction(flex::Direction::Column(BreakPoint::SM))
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "pagetop-col-image")
.with_size(flex::ItemSize::Percent40)
.with_component(Image::with("/homedemo/images/about.svg")),
.add_component(Image::with("/homedemo/images/about.svg")),
)
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "pagetop-col-text")
.with_component(Heading::h2(L10n::t("pagetop_title", &LOCALES_HOMEDEMO)))
.with_component(
Paragraph::with(L10n::t("pagetop_text1", &LOCALES_HOMEDEMO))
.add_component(Heading::h2(L10n::t("pagetop_title", &LOCALES_HOMEDEMO)))
.add_component(
Paragraph::translated(L10n::t("pagetop_text1", &LOCALES_HOMEDEMO))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(L10n::t("pagetop_text2", &LOCALES_HOMEDEMO)))
.with_component(Paragraph::with(
L10n::e("pagetop_text3", &LOCALES_HOMEDEMO)
.add_component(Paragraph::translated(L10n::t(
"pagetop_text2",
&LOCALES_HOMEDEMO,
)))
.add_component(Paragraph::translated(
L10n::t("pagetop_text3", &LOCALES_HOMEDEMO)
.with_arg("href", "https://docs.rs/pagetop/latest/pagetop"),
)),
),
@ -147,20 +153,20 @@ fn about_pagetop() -> Wrapper {
}
fn promo_pagetop() -> Wrapper {
Wrapper::new().with_id("promo").with_component(
Wrapper::new().with_id("promo").add_component(
flex::Container::new()
.with_direction(flex::Direction::Column(BreakPoint::MD))
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "promo-col-text")
.with_size(flex::ItemSize::Percent60)
.with_component(Heading::h2(L10n::t(
.add_component(Heading::h2(L10n::t(
"pagetop_promo_title",
&LOCALES_HOMEDEMO,
)))
.with_component(
Paragraph::with(
L10n::e("pagetop_promo_text1", &LOCALES_HOMEDEMO).with_arg(
.add_component(
Paragraph::translated(
L10n::t("pagetop_promo_text1", &LOCALES_HOMEDEMO).with_arg(
"pagetop",
format!(
"<a href=\"{}\" target=\"_blank\">{}</a>",
@ -171,37 +177,37 @@ fn promo_pagetop() -> Wrapper {
.with_display(ParagraphDisplay::Small),
),
)
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "promo-col-image")
.with_size(flex::ItemSize::Percent40)
.with_component(Image::with("/homedemo/images/pagetop.png")),
.add_component(Image::with("/homedemo/images/pagetop.png")),
),
)
}
fn reporting_issues() -> Wrapper {
Wrapper::new().with_id("reporting").with_component(
Wrapper::new().with_id("reporting").add_component(
flex::Container::new()
.with_direction(flex::Direction::Column(BreakPoint::MD))
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "reporting-col-image")
.with_component(Image::with("/homedemo/images/support.jpg")),
.add_component(Image::with("/homedemo/images/support.jpg")),
)
.with_item(
.add_item(
flex::Item::new()
.with_inner_classes(ClassesOp::Add, "reporting-col-text")
.with_size(flex::ItemSize::Percent50)
.with_component(Heading::h2(L10n::t(
.add_component(Heading::h2(L10n::t(
"report_problems_title",
&LOCALES_HOMEDEMO,
)))
.with_component(
Paragraph::with(L10n::t("report_problems_text1", &LOCALES_HOMEDEMO))
.add_component(
Paragraph::translated(L10n::t("report_problems_text1", &LOCALES_HOMEDEMO))
.with_display(ParagraphDisplay::Small),
)
.with_component(Paragraph::with(L10n::t(
.add_component(Paragraph::translated(L10n::t(
"report_problems_text2",
&LOCALES_HOMEDEMO,
))),

View file

@ -42,7 +42,7 @@ async fn login(request: service::HttpRequest) -> ResultPage<Markup, FatalError>
"content",
Wrapper::new()
.with_id("welcome")
.with_component(form_login()),
.add_component(form_login()),
)
.render()
}