Compare commits
No commits in common. "dcc83692c12a8ecbef72d573e9c94fa8b853e850" and "9f79e4179a57893f78701526ad40d91bd8dc1ace" have entirely different histories.
dcc83692c1
...
9f79e4179a
9 changed files with 23 additions and 72 deletions
|
|
@ -14,11 +14,7 @@ async fn hello_name(
|
||||||
) -> ResultPage<Markup, ErrorPage> {
|
) -> ResultPage<Markup, ErrorPage> {
|
||||||
let name = path.into_inner();
|
let name = path.into_inner();
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_child(Html::with(move |_| {
|
.add_child(Html::with(move |_| html! { h1 { "Hello " (name) "!" } }))
|
||||||
html! {
|
|
||||||
h1 style="text-align: center;" { "Hello " (name) "!" }
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,7 @@ impl Extension for HelloWorld {
|
||||||
|
|
||||||
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.add_child(Html::with(|_| {
|
.add_child(Html::with(|_| html! { h1 { "Hello World!" } }))
|
||||||
html! {
|
|
||||||
h1 style="text-align: center;" { "Hello World!" }
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.render()
|
.render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ impl Extension for SuperMenu {
|
||||||
})),
|
})),
|
||||||
));
|
));
|
||||||
|
|
||||||
InRegion::Global(&DefaultRegion::Header).add(Child::with(
|
InRegion::Named("header").add(Child::with(
|
||||||
Container::new()
|
Container::new()
|
||||||
.with_width(container::Width::FluidMax(UnitValue::RelRem(75.0)))
|
.with_width(container::Width::FluidMax(UnitValue::RelRem(75.0)))
|
||||||
.add_child(navbar_menu),
|
.add_child(navbar_menu),
|
||||||
|
|
|
||||||
|
|
@ -102,34 +102,6 @@ pub mod prelude {
|
||||||
pub use crate::theme::*;
|
pub use crate::theme::*;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Plantillas que Bootsier añade.
|
|
||||||
#[derive(AutoDefault)]
|
|
||||||
pub enum BootsierTemplate {
|
|
||||||
/// Plantilla predeterminada de Bootsier.
|
|
||||||
#[default]
|
|
||||||
Standard,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Template for BootsierTemplate {
|
|
||||||
fn render(&'static self, cx: &mut Context) -> Markup {
|
|
||||||
match self {
|
|
||||||
Self::Standard => theme::Container::new()
|
|
||||||
.with_classes(ClassesOp::Add, "container-wrapper")
|
|
||||||
.with_width(theme::container::Width::FluidMax(
|
|
||||||
config::SETTINGS.bootsier.max_width,
|
|
||||||
))
|
|
||||||
.add_child(Html::with(|cx| {
|
|
||||||
html! {
|
|
||||||
(DefaultRegion::Header.render(cx))
|
|
||||||
(DefaultRegion::Content.render(cx))
|
|
||||||
(DefaultRegion::Footer.render(cx))
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
}
|
|
||||||
.render(cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Implementa el tema.
|
/// Implementa el tema.
|
||||||
pub struct Bootsier;
|
pub struct Bootsier;
|
||||||
|
|
||||||
|
|
@ -145,11 +117,6 @@ impl Extension for Bootsier {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Theme for Bootsier {
|
impl Theme for Bootsier {
|
||||||
#[inline]
|
|
||||||
fn default_template(&self) -> TemplateRef {
|
|
||||||
&BootsierTemplate::Standard
|
|
||||||
}
|
|
||||||
|
|
||||||
fn before_render_page_body(&self, page: &mut Page) {
|
fn before_render_page_body(&self, page: &mut Page) {
|
||||||
page.alter_assets(ContextOp::AddStyleSheet(
|
page.alter_assets(ContextOp::AddStyleSheet(
|
||||||
StyleSheet::from("/bootsier/bs/bootstrap.min.css")
|
StyleSheet::from("/bootsier/bs/bootstrap.min.css")
|
||||||
|
|
@ -160,10 +127,16 @@ impl Theme for Bootsier {
|
||||||
JavaScript::defer("/bootsier/js/bootstrap.bundle.min.js")
|
JavaScript::defer("/bootsier/js/bootstrap.bundle.min.js")
|
||||||
.with_version(BOOTSTRAP_VERSION)
|
.with_version(BOOTSTRAP_VERSION)
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
))
|
));
|
||||||
.alter_child_in(
|
}
|
||||||
&DefaultRegion::Footer,
|
|
||||||
ChildOp::AddIfEmpty(Child::with(PoweredBy::new())),
|
fn render_page_body(&self, page: &mut Page) -> Markup {
|
||||||
);
|
theme::Container::new()
|
||||||
|
.with_id("container-wrapper")
|
||||||
|
.with_width(theme::container::Width::FluidMax(
|
||||||
|
config::SETTINGS.bootsier.max_width,
|
||||||
|
))
|
||||||
|
.add_child(Template::named(page.template()))
|
||||||
|
.render(page.context())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,3 @@ $utilities: map-merge(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Region Footer
|
|
||||||
.region-footer {
|
|
||||||
padding: .75rem 0 3rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ pub fn builder_fn(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
alter_name_str
|
alter_name_str
|
||||||
);
|
);
|
||||||
let with_alter_doc = concat!(
|
let with_alter_doc = concat!(
|
||||||
"Permite modificar la instancia actual (`&mut self`) con los mismos argumentos, ",
|
"Modifica la instancia actual (`&mut self`) con los mismos argumentos, ",
|
||||||
"sin consumirla."
|
"sin consumirla."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,9 @@ impl Html {
|
||||||
|
|
||||||
/// Crea una instancia que generará el `Markup`, con acceso opcional al contexto.
|
/// Crea una instancia que generará el `Markup`, con acceso opcional al contexto.
|
||||||
///
|
///
|
||||||
/// El método [`Self::prepare_component()`] delega el renderizado a la función que aquí se
|
/// El método [`prepare_component()`](crate::core::component::Component::prepare_component)
|
||||||
/// proporciona, que recibe una referencia mutable al [`Context`].
|
/// delega el renderizado en la función proporcionada, que recibe una referencia mutable al
|
||||||
|
/// contexto de renderizado ([`Context`]).
|
||||||
pub fn with<F>(f: F) -> Self
|
pub fn with<F>(f: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(&mut Context) -> Markup + Send + Sync + 'static,
|
F: Fn(&mut Context) -> Markup + Send + Sync + 'static,
|
||||||
|
|
@ -63,8 +64,8 @@ impl Html {
|
||||||
/// Sustituye la función que genera el `Markup`.
|
/// Sustituye la función que genera el `Markup`.
|
||||||
///
|
///
|
||||||
/// Permite a otras extensiones modificar la función de renderizado que se ejecutará cuando
|
/// Permite a otras extensiones modificar la función de renderizado que se ejecutará cuando
|
||||||
/// [`Self::prepare_component()`] invoque esta instancia. La nueva función también recibe una
|
/// [`prepare_component()`](crate::core::component::Component::prepare_component) invoque esta
|
||||||
/// referencia al [`Context`].
|
/// instancia. La nueva función también recibe una referencia al contexto ([`Context`]).
|
||||||
#[builder_fn]
|
#[builder_fn]
|
||||||
pub fn with_fn<F>(mut self, f: F) -> Self
|
pub fn with_fn<F>(mut self, f: F) -> Self
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::{builder_fn, join};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// Operaciones para modificar recursos asociados al [`Context`] de un documento.
|
/// Operaciones para modificar recursos asociados al contexto ([`Context`]) de un documento.
|
||||||
pub enum ContextOp {
|
pub enum ContextOp {
|
||||||
/// Define el *favicon* del documento. Sobrescribe cualquier valor anterior.
|
/// Define el *favicon* del documento. Sobrescribe cualquier valor anterior.
|
||||||
SetFavicon(Option<Favicon>),
|
SetFavicon(Option<Favicon>),
|
||||||
|
|
@ -386,7 +386,7 @@ impl Context {
|
||||||
/// 3. Un idioma válido extraído de la cabecera `Accept-Language` del navegador.
|
/// 3. Un idioma válido extraído de la cabecera `Accept-Language` del navegador.
|
||||||
/// 4. Y si ninguna de las opciones anteriores aplica, se usa el idioma de respaldo (`"en-US"`).
|
/// 4. Y si ninguna de las opciones anteriores aplica, se usa el idioma de respaldo (`"en-US"`).
|
||||||
///
|
///
|
||||||
/// Resulta útil para usar el [`Context`] como fuente de traducción en
|
/// Resulta útil para usar un contexto ([`Context`]) como fuente de traducción en
|
||||||
/// [`L10n::lookup()`](crate::locale::L10n::lookup) o [`L10n::using()`](crate::locale::L10n::using).
|
/// [`L10n::lookup()`](crate::locale::L10n::lookup) o [`L10n::using()`](crate::locale::L10n::using).
|
||||||
impl LangId for Context {
|
impl LangId for Context {
|
||||||
fn langid(&self) -> &'static LanguageIdentifier {
|
fn langid(&self) -> &'static LanguageIdentifier {
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,13 @@
|
||||||
--intro-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
--intro-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
|
||||||
overflow-x: clip;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro {
|
.intro {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 350px;
|
min-width: 350px;
|
||||||
color: var(--intro-color);
|
color: var(--intro-color);
|
||||||
background-color: var(--intro-bg-color);
|
background-color: var(--intro-bg-color);
|
||||||
|
|
||||||
left: 50%;
|
width: 100%;
|
||||||
right: 50%;
|
|
||||||
margin-left: -50vw;
|
|
||||||
margin-right: -50vw;
|
|
||||||
width: 100vw;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue