Revierte el cambio de Basic por Monster

This commit is contained in:
Manuel Cillero 2023-07-13 20:20:30 +02:00
parent 58d6ea6719
commit a0c61b008a
12 changed files with 47 additions and 38 deletions

View file

@ -22,7 +22,7 @@ impl ModuleTrait for Aliner {
impl ThemeTrait for Aliner {
fn before_prepare_body(&self, page: &mut Page) {
page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico")))
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")))
.alter_context(ContextOp::AddStyleSheet(
StyleSheet::at("/aliner/css/styles.css").with_weight(-99),
));

View file

@ -44,7 +44,7 @@ impl ThemeTrait for Bootsier {
}
fn before_prepare_body(&self, page: &mut Page) {
page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico")))
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")))
.alter_context(ContextOp::AddStyleSheet(
StyleSheet::at("/bootsier/css/bootstrap.min.css")
.with_version("5.1.3")

View file

@ -32,7 +32,7 @@ impl ModuleTrait for Bulmix {
impl ThemeTrait for Bulmix {
fn before_prepare_body(&self, page: &mut Page) {
page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico")))
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")))
.alter_context(ContextOp::AddStyleSheet(
StyleSheet::at("/bulmix/css/bulma.min.css")
.with_version("0.9.4")

View file

@ -1,7 +1,7 @@
use pagetop_build::StaticFilesBundle;
fn main() -> std::io::Result<()> {
StaticFilesBundle::from_dir("./static/monster")
.with_name("monster")
StaticFilesBundle::from_dir("./static/theme")
.with_name("theme")
.build()
}

View file

@ -28,7 +28,7 @@ pub fn register_modules(app: ModuleStaticRef) {
let mut list: Vec<ModuleStaticRef> = Vec::new();
// Enable basic theme.
add_to_enabled(&mut list, &crate::core::theme::monster::Monster);
add_to_enabled(&mut list, &crate::core::theme::Basic);
// Enable application modules.
add_to_enabled(&mut list, app);

View file

@ -5,6 +5,7 @@ mod regions;
pub use regions::add_component_to;
pub(crate) use regions::ComponentsRegions;
pub(crate) mod all;
mod basic;
pub(crate) use basic::Basic;
pub(crate) mod monster;
pub(crate) mod all;

View file

@ -14,7 +14,7 @@ pub static THEMES: LazyStatic<RwLock<Vec<ThemeStaticRef>>> =
pub static THEME: LazyStatic<ThemeStaticRef> =
LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) {
Some(theme) => theme,
None => &crate::core::theme::monster::Monster,
None => &crate::core::theme::Basic,
});
// THEME BY NAME ***********************************************************************************

View file

@ -6,31 +6,31 @@ use crate::response::page::Page;
use crate::service;
use crate::{serve_static_files, use_handle, use_static, Handle};
use_handle!(THEME_MONSTER);
use_handle!(THEME_BASIC);
use_static!(monster);
use_static!(theme);
pub struct Monster;
pub struct Basic;
impl ModuleTrait for Monster {
impl ModuleTrait for Basic {
fn handle(&self) -> Handle {
THEME_MONSTER
THEME_BASIC
}
fn theme(&self) -> Option<ThemeStaticRef> {
Some(&Monster)
Some(&Basic)
}
fn configure_service(&self, cfg: &mut service::web::ServiceConfig) {
serve_static_files!(cfg, "/monster", monster);
serve_static_files!(cfg, "/theme", theme);
}
}
impl ThemeTrait for Monster {
impl ThemeTrait for Basic {
fn before_prepare_body(&self, page: &mut Page) {
page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico")))
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")))
.alter_context(ContextOp::AddStyleSheet(
StyleSheet::at("/monster/css/normalize.min.css").with_version("8.0.1"),
StyleSheet::at("/theme/css/normalize.min.css").with_version("8.0.1"),
));
}
}

View file

@ -37,7 +37,7 @@ pub trait ThemeTrait: ModuleTrait + Send + Sync {
fn after_prepare_body(&self, page: &mut Page) {
if page.favicon().is_none() {
page.alter_favicon(Some(Favicon::new().with_icon("/monster/favicon.ico")));
page.alter_favicon(Some(Favicon::new().with_icon("/theme/favicon.ico")));
}
}

View file

@ -155,35 +155,43 @@ macro_rules! use_locale {
#[macro_export]
macro_rules! use_static {
( $bundle:ident ) => {
mod static_bundle {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
$crate::paste! {
mod [<static_bundle_ $bundle>] {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
}
}
};
( $bundle:ident => $STATIC:ident ) => {
mod static_bundle {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
$crate::paste! {
mod [<static_bundle_ $bundle>] {
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
}
static $STATIC: LazyStatic<HashMapResources> = LazyStatic::new([
<static_bundle_ $bundle>]::$bundle
);
}
static $STATIC: LazyStatic<HashMapResources> = LazyStatic::new(static_bundle::$bundle);
};
}
#[macro_export]
macro_rules! serve_static_files {
( $cfg:ident, $path:expr, $bundle:ident ) => {{
let static_files = &$crate::config::SETTINGS.dev.static_files;
if static_files.is_empty() {
$cfg.service($crate::service::ResourceFiles::new(
$path,
static_bundle::$bundle(),
));
} else {
$cfg.service(
$crate::service::ActixFiles::new(
$crate::paste! {
let static_files = &$crate::config::SETTINGS.dev.static_files;
if static_files.is_empty() {
$cfg.service($crate::service::ResourceFiles::new(
$path,
$crate::concat_string!(static_files, $path),
)
.show_files_listing(),
);
[<static_bundle_ $bundle>]::$bundle(),
));
} else {
$cfg.service(
$crate::service::ActixFiles::new(
$path,
$crate::concat_string!(static_files, $path),
)
.show_files_listing(),
);
}
}
}};
}

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After