Recupera la versión con valor propio en activos

This commit is contained in:
Manuel Cillero 2023-07-06 18:29:01 +02:00
parent 4673b82a93
commit f85a35b5f4
5 changed files with 33 additions and 25 deletions

View file

@ -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 {

View file

@ -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]

View file

@ -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::<bool>(JQUERY_PARAM, true);
pub fn enable_jquery(&self, cx: &mut Context) -> &Self {
cx.set_param::<bool>(PARAM_JQUERY, true);
self
}
pub fn remove_from(cx: &mut Context) {
cx.set_param::<bool>(JQUERY_PARAM, false);
pub fn disable_jquery(&self, cx: &mut Context) -> &Self {
cx.set_param::<bool>(PARAM_JQUERY, false);
self
}
}
fn before_render_page(page: &mut Page) {
if let Some(true) = page.context().get_param::<bool>(JQUERY_PARAM) {
if let Some(true) = page.context().get_param::<bool>(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),
));

View file

@ -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::<MegaMenu>(self.id());

View file

@ -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 {