From f85a35b5f451fc01805cf179379168025255b229 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Thu, 6 Jul 2023 18:29:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=8F=AA=20Recupera=20la=20versi=C3=B3n=20con?= =?UTF-8?q?=20valor=20propio=20en=20activos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop-bootsier/src/lib.rs | 9 ++++++--- pagetop-bulmix/src/lib.rs | 6 ++++-- pagetop-jquery/src/lib.rs | 17 ++++++++++------- pagetop-megamenu/src/component.rs | 20 ++++++++++---------- pagetop-minimal/src/component/icon.rs | 6 +++--- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/pagetop-bootsier/src/lib.rs b/pagetop-bootsier/src/lib.rs index 7005fb89..ac6d79b6 100644 --- a/pagetop-bootsier/src/lib.rs +++ b/pagetop-bootsier/src/lib.rs @@ -46,13 +46,16 @@ impl ThemeTrait for Bootsier { fn before_prepare_page(&self, page: &mut Page) { page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( - StyleSheet::located("/bootsier/css/bootstrap.min.css?v=5.1.3").with_weight(-99), + StyleSheet::located("/bootsier/css/bootstrap.min.css") + .with_version("5.1.3") + .with_weight(-99), )) .alter_context(ContextOp::AddJavaScript( - JavaScript::located("/bootsier/js/bootstrap.bundle.min.js?v=5.1.3") + JavaScript::located("/bootsier/js/bootstrap.bundle.min.js") + .with_version("5.1.3") .with_weight(-99), )); - JQuery::add_in(page.context()); + JQuery.enable_jquery(page.context()); } fn prepare_page_body(&self, page: &mut Page) -> Markup { diff --git a/pagetop-bulmix/src/lib.rs b/pagetop-bulmix/src/lib.rs index 3ab5e2cc..688c6ae6 100644 --- a/pagetop-bulmix/src/lib.rs +++ b/pagetop-bulmix/src/lib.rs @@ -34,9 +34,11 @@ impl ThemeTrait for Bulmix { fn before_prepare_page(&self, page: &mut Page) { page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico"))) .alter_context(ContextOp::AddStyleSheet( - StyleSheet::located("/bulmix/css/bulma.min.css?v=0.9.4").with_weight(-99), + StyleSheet::located("/bulmix/css/bulma.min.css") + .with_version("0.9.4") + .with_weight(-99), )); - JQuery::add_in(page.context()); + JQuery.enable_jquery(page.context()); } #[rustfmt::skip] diff --git a/pagetop-jquery/src/lib.rs b/pagetop-jquery/src/lib.rs index 5871131d..5fa8e4ad 100644 --- a/pagetop-jquery/src/lib.rs +++ b/pagetop-jquery/src/lib.rs @@ -6,7 +6,7 @@ use_locale!(LOCALE_JQUERY); use_static!(jquery); -const JQUERY_PARAM: &str = "jquery.add"; +const PARAM_JQUERY: &str = "jquery.js"; pub struct JQuery; @@ -33,19 +33,22 @@ impl ModuleTrait for JQuery { } impl JQuery { - pub fn add_in(cx: &mut Context) { - cx.set_param::(JQUERY_PARAM, true); + pub fn enable_jquery(&self, cx: &mut Context) -> &Self { + cx.set_param::(PARAM_JQUERY, true); + self } - pub fn remove_from(cx: &mut Context) { - cx.set_param::(JQUERY_PARAM, false); + pub fn disable_jquery(&self, cx: &mut Context) -> &Self { + cx.set_param::(PARAM_JQUERY, false); + self } } fn before_render_page(page: &mut Page) { - if let Some(true) = page.context().get_param::(JQUERY_PARAM) { + if let Some(true) = page.context().get_param::(PARAM_JQUERY) { page.context().alter(ContextOp::AddJavaScript( - JavaScript::located("/jquery/jquery.min.js?v=3.6.0") + JavaScript::located("/jquery/jquery.min.js") + .with_version("3.6.0") .with_weight(isize::MIN) .with_mode(ModeJS::Normal), )); diff --git a/pagetop-megamenu/src/component.rs b/pagetop-megamenu/src/component.rs index c0bc580d..4e7c60ae 100644 --- a/pagetop-megamenu/src/component.rs +++ b/pagetop-megamenu/src/component.rs @@ -193,16 +193,16 @@ impl ComponentTrait for MegaMenu { } 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( - "/megamenu/css/menu-clean.css?v=1.1.1", - ))) - .alter(ContextOp::AddJavaScript(JavaScript::located( - "/megamenu/js/menu.min.js?v=1.1.1", - ))); - JQuery::add_in(cx); + cx.alter(ContextOp::AddStyleSheet( + StyleSheet::located("/megamenu/css/menu.css").with_version("1.1.1"), + )) + .alter(ContextOp::AddStyleSheet( + StyleSheet::located("/megamenu/css/menu-clean.css").with_version("1.1.1"), + )) + .alter(ContextOp::AddJavaScript( + JavaScript::located("/megamenu/js/menu.min.js").with_version("1.1.1"), + )); + JQuery.enable_jquery(cx); let id = cx.required_id::(self.id()); diff --git a/pagetop-minimal/src/component/icon.rs b/pagetop-minimal/src/component/icon.rs index fd822949..5389cdae 100644 --- a/pagetop-minimal/src/component/icon.rs +++ b/pagetop-minimal/src/component/icon.rs @@ -29,9 +29,9 @@ impl ComponentTrait for Icon { } fn before_prepare_component(&mut self, cx: &mut Context) { - cx.alter(ContextOp::AddStyleSheet(StyleSheet::located( - "/minimal/icons/bootstrap-icons.css?v=1.8.2", - ))); + cx.alter(ContextOp::AddStyleSheet( + StyleSheet::located("/minimal/icons/bootstrap-icons.css").with_version("1.8.2"), + )); } fn prepare_component(&self, _: &mut Context) -> PrepareMarkup {