👽️ Aplica cambio de API para Context

This commit is contained in:
Manuel Cillero 2023-06-28 23:47:56 +02:00
parent a1d51d6d0f
commit 9552ae0af5
17 changed files with 96 additions and 100 deletions

View file

@ -115,11 +115,7 @@ impl ThemeTrait for Bootsier {
}
}
fn render_component(
&self,
component: &dyn ComponentTrait,
rcx: &mut RenderContext,
) -> Option<Markup> {
fn render_component(&self, component: &dyn ComponentTrait, cx: &mut Context) -> Option<Markup> {
match component.handle() {
ERROR_404 => Some(html! {
div class="jumbotron" {
@ -132,18 +128,18 @@ impl ThemeTrait for Bootsier {
div class="media-body" {
h1 class="display-4" { ("RESOURCE NOT FOUND") }
p class="lead" {
(L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(rcx))
(L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(cx))
}
hr class="my-4";
p {
(L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(rcx))
(L10n::t("e404-description", &LOCALE_BOOTSIER).prepare(cx))
}
a
class="btn btn-primary btn-lg"
href="/"
role="button"
{
(L10n::t("back-homepage", &LOCALE_BOOTSIER).prepare(rcx))
(L10n::t("back-homepage", &LOCALE_BOOTSIER).prepare(cx))
}
}
}

View file

@ -43,7 +43,7 @@ impl ThemeTrait for Bulmix {
fn before_prepare_component(
&self,
component: &mut dyn ComponentTrait,
_rcx: &mut RenderContext,
_cx: &mut Context,
) {
match component.handle() {
COMPONENT_ANCHOR => {
@ -122,7 +122,7 @@ impl ThemeTrait for Bulmix {
fn render_component(
&self,
component: &dyn ComponentTrait,
_rcx: &mut RenderContext,
_cx: &mut Context,
) -> Option<Markup> {
match component.handle() {
COMPONENT_ICON => {

View file

@ -33,12 +33,12 @@ impl ModuleTrait for JQuery {
}
impl JQuery {
pub fn add_in(rcx: &mut RenderContext) {
rcx.set_param::<bool>(JQUERY_PARAM, true);
pub fn add_in(cx: &mut Context) {
cx.set_param::<bool>(JQUERY_PARAM, true);
}
pub fn remove_from(rcx: &mut RenderContext) {
rcx.set_param::<bool>(JQUERY_PARAM, false);
pub fn remove_from(cx: &mut Context) {
cx.set_param::<bool>(JQUERY_PARAM, false);
}
}

View file

@ -41,33 +41,33 @@ impl ComponentTrait for MegaMenuItem {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
match self.item_type() {
MegaMenuItemType::Void => PrepareMarkup::None,
MegaMenuItemType::Label(label) => PrepareMarkup::With(html! {
li class="label" { a href="#" { (label.prepare(rcx)) } }
li class="label" { a href="#" { (label.prepare(cx)) } }
}),
MegaMenuItemType::Link(label, path) => PrepareMarkup::With(html! {
li class="link" { a href=(path) { (label.prepare(rcx)) } }
li class="link" { a href=(path) { (label.prepare(cx)) } }
}),
MegaMenuItemType::LinkBlank(label, path) => PrepareMarkup::With(html! {
li class="link_blank" {
a href=(path) target="_blank" { (label.prepare(rcx)) }
a href=(path) target="_blank" { (label.prepare(cx)) }
}
}),
MegaMenuItemType::Html(content) => PrepareMarkup::With(html! {
li class="html" { (content.prepare(rcx)) }
li class="html" { (content.prepare(cx)) }
}),
MegaMenuItemType::Submenu(label, menu) => PrepareMarkup::With(html! {
li class="submenu" {
a href="#" { (label.prepare(rcx)) }
a href="#" { (label.prepare(cx)) }
ul {
(menu.items().prepare(rcx))
(menu.items().prepare(cx))
}
}
}),
@ -184,16 +184,16 @@ impl ComponentTrait for MegaMenu {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
run_actions_before_prepare_component(self, rcx);
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_component(self, cx);
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
rcx.alter(ContextOp::AddStyleSheet(StyleSheet::located(
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
cx.alter(ContextOp::AddStyleSheet(StyleSheet::located(
"/megamenu/css/menu.css?v=1.1.1",
)))
.alter(ContextOp::AddStyleSheet(StyleSheet::located(
@ -202,13 +202,13 @@ impl ComponentTrait for MegaMenu {
.alter(ContextOp::AddJavaScript(JavaScript::located(
"/megamenu/js/menu.min.js?v=1.1.1",
)));
JQuery::add_in(rcx);
JQuery::add_in(cx);
let id = rcx.required_id::<MegaMenu>(self.id());
let id = cx.required_id::<MegaMenu>(self.id());
PrepareMarkup::With(html! {
ul id=(id) class=[self.classes().get()] {
(self.items().prepare(rcx))
(self.items().prepare(cx))
}
script type="text/javascript" defer {
"jQuery(function(){jQuery('#" (id) "').smartmenus({"

View file

@ -58,12 +58,12 @@ impl ComponentTrait for Anchor {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
#[rustfmt::skip]
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let target = match &self.target() {
AnchorTarget::Blank => Some("_blank"),
AnchorTarget::Parent => Some("_parent"),
@ -78,9 +78,9 @@ impl ComponentTrait for Anchor {
href=[self.href().get()]
target=[target]
{
(self.left_icon().prepare(rcx))
(" ") span { (self.html().prepare(rcx)) } (" ")
(self.right_icon().prepare(rcx))
(self.left_icon().prepare(cx))
(" ") span { (self.html().prepare(cx)) } (" ")
(self.right_icon().prepare(cx))
}
})
}

View file

@ -46,47 +46,47 @@ impl ComponentTrait for Container {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
run_actions_before_prepare_component(self, rcx);
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_component(self, cx);
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
match self.container_type() {
ContainerType::Header => PrepareMarkup::With(html! {
header id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
}
}),
ContainerType::Footer => PrepareMarkup::With(html! {
footer id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
}
}),
ContainerType::Main => PrepareMarkup::With(html! {
main id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
}
}),
ContainerType::Section => PrepareMarkup::With(html! {
section id=[self.id()] class=[self.classes().get()] {
div class=[self.inner_classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
}
}),
_ => PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
}),
}

View file

@ -41,18 +41,18 @@ impl ComponentTrait for Button {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let button_type = match self.button_type() {
ButtonType::Button => "button",
ButtonType::Submit => "submit",
ButtonType::Reset => "reset",
};
let id = self.name().get().map(|name| concat_string!("edit-", name));
let value = self.value().prepare(rcx);
let value = self.value().prepare(cx);
PrepareMarkup::With(html! {
button
type=(button_type)

View file

@ -36,11 +36,11 @@ impl ComponentTrait for Date {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, _: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, _: &mut Context) -> PrepareMarkup {
let id = self.name().get().map(|name| concat_string!("edit-", name));
PrepareMarkup::With(html! {
div class=[self.classes().get()] {

View file

@ -44,15 +44,15 @@ impl ComponentTrait for Form {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
run_actions_before_prepare_component(self, rcx);
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_component(self, cx);
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let method = match self.method() {
FormMethod::Post => Some("post".to_owned()),
FormMethod::Get => None,
@ -65,7 +65,7 @@ impl ComponentTrait for Form {
method=[method]
accept-charset=[self.charset().get()]
{
div { (self.elements().prepare(rcx)) }
div { (self.elements().prepare(cx)) }
}
})
}

View file

@ -23,7 +23,7 @@ impl ComponentTrait for Hidden {
self.weight
}
fn prepare_component(&self, _: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, _: &mut Context) -> PrepareMarkup {
let id = self.name().get().map(|name| concat_string!("value-", name));
PrepareMarkup::With(html! {
input type="hidden" id=[id] name=[self.name().get()] value=[self.value().get()];

View file

@ -56,12 +56,12 @@ impl ComponentTrait for Input {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
#[rustfmt::skip]
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let type_input = match self.input_type() {
InputType::Textfield => "text",
InputType::Password => "password",
@ -71,8 +71,8 @@ impl ComponentTrait for Input {
InputType::Url => "url",
};
let id = self.name().get().map(|name| concat_string!("edit-", name));
let label = self.label().prepare(rcx);
let description = self.help_text().prepare(rcx);
let label = self.label().prepare(cx);
let description = self.help_text().prepare(cx);
PrepareMarkup::With(html! {
div class=[self.classes().get()] {
@if !label.is_empty() {

View file

@ -65,18 +65,18 @@ impl ComponentTrait for Column {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
run_actions_before_prepare_component(self, rcx);
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_component(self, cx);
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] {
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
})
}

View file

@ -34,18 +34,18 @@ impl ComponentTrait for Row {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
run_actions_before_prepare_component(self, rcx);
fn before_prepare_component(&mut self, cx: &mut Context) {
run_actions_before_prepare_component(self, cx);
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
div id=[self.id()] class=[self.classes().get()] {
(self.columns().prepare(rcx))
(self.columns().prepare(cx))
}
})
}

View file

@ -57,20 +57,20 @@ impl ComponentTrait for Heading {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
let id = self.id();
let classes = self.classes().get();
PrepareMarkup::With(html! { @match &self.heading_type() {
HeadingType::H1 => h1 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H2 => h2 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H3 => h3 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H4 => h4 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H5 => h5 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H6 => h6 id=[id] class=[classes] { (self.text().prepare(rcx)) },
HeadingType::H1 => h1 id=[id] class=[classes] { (self.text().prepare(cx)) },
HeadingType::H2 => h2 id=[id] class=[classes] { (self.text().prepare(cx)) },
HeadingType::H3 => h3 id=[id] class=[classes] { (self.text().prepare(cx)) },
HeadingType::H4 => h4 id=[id] class=[classes] { (self.text().prepare(cx)) },
HeadingType::H5 => h5 id=[id] class=[classes] { (self.text().prepare(cx)) },
HeadingType::H6 => h6 id=[id] class=[classes] { (self.text().prepare(cx)) },
}})
}

View file

@ -24,17 +24,17 @@ impl ComponentTrait for Icon {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn before_prepare_component(&mut self, rcx: &mut RenderContext) {
rcx.alter(ContextOp::AddStyleSheet(StyleSheet::located(
fn before_prepare_component(&mut self, cx: &mut Context) {
cx.alter(ContextOp::AddStyleSheet(StyleSheet::located(
"/minimal/icons/bootstrap-icons.css?v=1.8.2",
)));
}
fn prepare_component(&self, _: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, _: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! { i class=[self.classes().get()] {}; })
}

View file

@ -30,11 +30,11 @@ impl ComponentTrait for Image {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, _: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, _: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
img
src=[self.source().get()]

View file

@ -42,17 +42,17 @@ impl ComponentTrait for Paragraph {
self.weight
}
fn is_renderable(&self, rcx: &RenderContext) -> bool {
(self.renderable.check)(rcx)
fn is_renderable(&self, cx: &Context) -> bool {
(self.renderable.check)(cx)
}
fn prepare_component(&self, rcx: &mut RenderContext) -> PrepareMarkup {
fn prepare_component(&self, cx: &mut Context) -> PrepareMarkup {
PrepareMarkup::With(html! {
p
id=[self.id()]
class=[self.classes().get()]
{
(self.components().prepare(rcx))
(self.components().prepare(cx))
}
})
}