diff --git a/pagetop/Cargo.toml b/pagetop/Cargo.toml index ad3604d4..cac1d25b 100644 --- a/pagetop/Cargo.toml +++ b/pagetop/Cargo.toml @@ -44,7 +44,7 @@ fluent-templates = "0.7.1" unic-langid = "0.9.0" actix-web = "4.1.0" -actix-files = "0.6.1" +actix-web-files = { package = "actix-files", version = "0.6.1" } actix-web-static-files = "4.0.0" static-files = "0.2.3" diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index 0ff72856..114da34e 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -1,6 +1,8 @@ -pub use actix_web::{http, web, App, HttpMessage, HttpRequest, HttpResponse, HttpServer, Responder}; +pub use actix_web::{ + http, web, App, HttpMessage, HttpRequest, HttpResponse, HttpServer, Responder, +}; +pub use actix_web_files::Files as ActixFiles; pub use actix_web_static_files::ResourceFiles; -pub use actix_files::Files as ActixFiles; mod banner; @@ -16,4 +18,4 @@ pub use definition::AppTrait; pub mod application; -pub mod fatal_error; \ No newline at end of file +pub mod fatal_error; diff --git a/pagetop/src/app/fatal_error.rs b/pagetop/src/app/fatal_error.rs index 8bc30f50..a6e7c29d 100644 --- a/pagetop/src/app/fatal_error.rs +++ b/pagetop/src/app/fatal_error.rs @@ -1,5 +1,5 @@ -use crate::app::HttpResponse; use crate::app::http::{header::ContentType, StatusCode}; +use crate::app::HttpResponse; use crate::response::{page::Page, ResponseError}; use std::fmt; @@ -36,7 +36,7 @@ impl fmt::Display for FatalError { } else { write!(f, "Access Denied") } - }, + } // Error 404. FatalError::NotFound => { let mut error_page = Page::new(); @@ -51,7 +51,7 @@ impl fmt::Display for FatalError { } else { write!(f, "Not Found") } - }, + } // Error 412. FatalError::PreconditionFailed => write!(f, "Precondition Failed"), // Error 500. @@ -69,6 +69,7 @@ impl ResponseError for FatalError { .body(self.to_string()) } + #[rustfmt::skip] fn status_code(&self) -> StatusCode { match *self { FatalError::NotModified => StatusCode::NOT_MODIFIED, diff --git a/pagetop/src/app/locale.rs b/pagetop/src/app/locale.rs index 5354ffdb..9775867f 100644 --- a/pagetop/src/app/locale.rs +++ b/pagetop/src/app/locale.rs @@ -6,8 +6,8 @@ use unic_langid::LanguageIdentifier; /// Almacena el Identificador de Idioma Unicode ([Unicode Language Identifier] /// (https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier)) de /// la aplicación, obtenido de `SETTINGS.app.language`. -pub static LANGID: LazyStatic = LazyStatic::new(|| - match SETTINGS.app.language.parse() { +pub static LANGID: LazyStatic = + LazyStatic::new(|| match SETTINGS.app.language.parse() { Ok(language) => language, Err(_) => { trace::warn!( @@ -20,5 +20,4 @@ pub static LANGID: LazyStatic = LazyStatic::new(|| ); "en-US".parse().unwrap() } - } -); + }); diff --git a/pagetop/src/app/tracing.rs b/pagetop/src/app/tracing.rs index 4282cb7d..bc6bf515 100644 --- a/pagetop/src/app/tracing.rs +++ b/pagetop/src/app/tracing.rs @@ -17,8 +17,10 @@ use tracing_subscriber::EnvFilter; /// `Lazy` se garantiza que todos los registros almacenados se /// enviarán antes de terminar la ejecución. +#[rustfmt::skip] pub static TRACING: LazyStatic = LazyStatic::new(|| { - let env_filter = EnvFilter::try_new(&SETTINGS.log.tracing).unwrap_or_else(|_| EnvFilter::new("Info")); + let env_filter = + EnvFilter::try_new(&SETTINGS.log.tracing).unwrap_or_else(|_| EnvFilter::new("Info")); let rolling = SETTINGS.log.rolling.to_lowercase(); let (non_blocking, guard) = match rolling.as_str() { diff --git a/pagetop/src/base/component/anchor.rs b/pagetop/src/base/component/anchor.rs index 62528774..96416ace 100644 --- a/pagetop/src/base/component/anchor.rs +++ b/pagetop/src/base/component/anchor.rs @@ -18,6 +18,7 @@ pub enum AnchorTarget { pub type AnchorIcon = ComponentsBundle; +#[rustfmt::skip] pub struct Anchor { weight : isize, renderable : Renderable, @@ -33,6 +34,7 @@ pub struct Anchor { } impl ComponentTrait for Anchor { + #[rustfmt::skip] fn new() -> Self { Anchor { weight : 0, @@ -61,6 +63,7 @@ impl ComponentTrait for Anchor { (self.renderable)(context) } + #[rustfmt::skip] fn default_render(&self, context: &mut PageContext) -> Markup { let target = match &self.target() { AnchorTarget::Blank => Some("_blank"), diff --git a/pagetop/src/base/component/block.rs b/pagetop/src/base/component/block.rs index 9c05c6ef..9e76a505 100644 --- a/pagetop/src/base/component/block.rs +++ b/pagetop/src/base/component/block.rs @@ -4,6 +4,7 @@ pub_const_handler!(COMPONENT_BLOCK); hook_before_render_component!(HOOK_BEFORE_RENDER_BLOCK, Block); +#[rustfmt::skip] pub struct Block { weight : isize, renderable: Renderable, @@ -15,6 +16,7 @@ pub struct Block { } impl ComponentTrait for Block { + #[rustfmt::skip] fn new() -> Self { Block { weight : 0, diff --git a/pagetop/src/base/component/container.rs b/pagetop/src/base/component/container.rs index 1e1c5a3a..097d82b7 100644 --- a/pagetop/src/base/component/container.rs +++ b/pagetop/src/base/component/container.rs @@ -12,6 +12,7 @@ pub enum ContainerType { Wrapper, } +#[rustfmt::skip] pub struct Container { weight : isize, renderable : Renderable, @@ -24,6 +25,7 @@ pub struct Container { } impl ComponentTrait for Container { + #[rustfmt::skip] fn new() -> Self { Container { weight : 0, diff --git a/pagetop/src/base/component/form_element/button.rs b/pagetop/src/base/component/form_element/button.rs index 8d9d69ad..5e127f08 100644 --- a/pagetop/src/base/component/form_element/button.rs +++ b/pagetop/src/base/component/form_element/button.rs @@ -8,6 +8,7 @@ pub enum ButtonType { Submit, } +#[rustfmt::skip] pub struct Button { weight : isize, renderable : Renderable, @@ -21,6 +22,7 @@ pub struct Button { } impl ComponentTrait for Button { + #[rustfmt::skip] fn new() -> Self { Button { weight : 0, @@ -48,6 +50,7 @@ impl ComponentTrait for Button { (self.renderable)(context) } + #[rustfmt::skip] fn default_render(&self, _: &mut PageContext) -> Markup { let button_type = match self.button_type() { ButtonType::Button => "button", diff --git a/pagetop/src/base/component/form_element/date.rs b/pagetop/src/base/component/form_element/date.rs index 7d69a614..871aeffd 100644 --- a/pagetop/src/base/component/form_element/date.rs +++ b/pagetop/src/base/component/form_element/date.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub_const_handler!(COMPONENT_DATE); +#[rustfmt::skip] pub struct Date { weight : isize, renderable : Renderable, @@ -20,6 +21,7 @@ pub struct Date { } impl ComponentTrait for Date { + #[rustfmt::skip] fn new() -> Self { Date { weight : 0, diff --git a/pagetop/src/base/component/form_element/form.rs b/pagetop/src/base/component/form_element/form.rs index 8c5a0235..68b192fd 100644 --- a/pagetop/src/base/component/form_element/form.rs +++ b/pagetop/src/base/component/form_element/form.rs @@ -9,6 +9,7 @@ pub enum FormMethod { Post, } +#[rustfmt::skip] pub struct Form { weight : isize, renderable: Renderable, @@ -22,6 +23,7 @@ pub struct Form { } impl ComponentTrait for Form { + #[rustfmt::skip] fn new() -> Self { Form { weight : 0, diff --git a/pagetop/src/base/component/form_element/hidden.rs b/pagetop/src/base/component/form_element/hidden.rs index be1959f6..c56ee109 100644 --- a/pagetop/src/base/component/form_element/hidden.rs +++ b/pagetop/src/base/component/form_element/hidden.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub_const_handler!(COMPONENT_HIDDEN); +#[rustfmt::skip] pub struct Hidden { weight: isize, name : IdentifierValue, @@ -9,6 +10,7 @@ pub struct Hidden { } impl ComponentTrait for Hidden { + #[rustfmt::skip] fn new() -> Self { Hidden { weight: 0, diff --git a/pagetop/src/base/component/form_element/input.rs b/pagetop/src/base/component/form_element/input.rs index 7f85c6a6..15236e16 100644 --- a/pagetop/src/base/component/form_element/input.rs +++ b/pagetop/src/base/component/form_element/input.rs @@ -11,6 +11,7 @@ pub enum InputType { Url, } +#[rustfmt::skip] pub struct Input { weight : isize, renderable : Renderable, @@ -33,6 +34,7 @@ pub struct Input { } impl ComponentTrait for Input { + #[rustfmt::skip] fn new() -> Self { Input { weight : 0, @@ -69,6 +71,7 @@ impl ComponentTrait for Input { (self.renderable)(context) } + #[rustfmt::skip] fn default_render(&self, _: &mut PageContext) -> Markup { let type_input = match self.input_type() { InputType::Email => "email", @@ -130,6 +133,7 @@ impl Input { Input::new() } + #[rustfmt::skip] pub fn password() -> Self { let mut input = Input::new().with_classes( ClassesOp::Replace("form-type-textfield"), @@ -139,6 +143,7 @@ impl Input { input } + #[rustfmt::skip] pub fn search() -> Self { let mut input = Input::new().with_classes( ClassesOp::Replace("form-type-textfield"), @@ -148,6 +153,7 @@ impl Input { input } + #[rustfmt::skip] pub fn email() -> Self { let mut input = Input::new().with_classes( ClassesOp::Replace("form-type-textfield"), @@ -157,6 +163,7 @@ impl Input { input } + #[rustfmt::skip] pub fn telephone() -> Self { let mut input = Input::new().with_classes( ClassesOp::Replace("form-type-textfield"), @@ -166,6 +173,7 @@ impl Input { input } + #[rustfmt::skip] pub fn url() -> Self { let mut input = Input::new().with_classes( ClassesOp::Replace("form-type-textfield"), diff --git a/pagetop/src/base/component/grid/column.rs b/pagetop/src/base/component/grid/column.rs index e7ed5bb9..5ddba56c 100644 --- a/pagetop/src/base/component/grid/column.rs +++ b/pagetop/src/base/component/grid/column.rs @@ -4,16 +4,16 @@ pub_const_handler!(COMPONENT_COLUMN); hook_before_render_component!(HOOK_BEFORE_RENDER_COLUMN, Column); -const SIZE_DEFAULT: &str = "col-md"; -const SIZE_1_OF_12: &str = "col-md-1"; -const SIZE_2_OF_12: &str = "col-md-2"; -const SIZE_3_OF_12: &str = "col-md-3"; -const SIZE_4_OF_12: &str = "col-md-4"; -const SIZE_5_OF_12: &str = "col-md-5"; -const SIZE_6_OF_12: &str = "col-md-6"; -const SIZE_7_OF_12: &str = "col-md-7"; -const SIZE_8_OF_12: &str = "col-md-8"; -const SIZE_9_OF_12: &str = "col-md-9"; +const SIZE__DEFAULT: &str = "col-md"; +const SIZE__1_OF_12: &str = "col-md-1"; +const SIZE__2_OF_12: &str = "col-md-2"; +const SIZE__3_OF_12: &str = "col-md-3"; +const SIZE__4_OF_12: &str = "col-md-4"; +const SIZE__5_OF_12: &str = "col-md-5"; +const SIZE__6_OF_12: &str = "col-md-6"; +const SIZE__7_OF_12: &str = "col-md-7"; +const SIZE__8_OF_12: &str = "col-md-8"; +const SIZE__9_OF_12: &str = "col-md-9"; const SIZE_10_OF_12: &str = "col-md-10"; const SIZE_11_OF_12: &str = "col-md-11"; const SIZE_12_OF_12: &str = "col-md-12"; @@ -33,6 +33,8 @@ pub enum ColumnSize { Is11of12, IsFull, } + +#[rustfmt::skip] pub struct Column { weight : isize, renderable: Renderable, @@ -44,12 +46,13 @@ pub struct Column { } impl ComponentTrait for Column { + #[rustfmt::skip] fn new() -> Self { Column { weight : 0, renderable: render_always, id : IdentifierValue::new(), - classes : Classes::new_with_default(SIZE_DEFAULT), + classes : Classes::new_with_default(SIZE__DEFAULT), size : ColumnSize::Default, components: ComponentsBundle::new(), template : "default".to_owned(), @@ -149,18 +152,19 @@ impl Column { self } + #[rustfmt::skip] pub fn alter_size(&mut self, size: ColumnSize) -> &mut Self { match size { - ColumnSize::Default => self.alter_classes(ClassesOp::SetDefault, SIZE_DEFAULT), - ColumnSize::Is1of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_1_OF_12), - ColumnSize::Is2of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_2_OF_12), - ColumnSize::Is3of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_3_OF_12), - ColumnSize::Is4of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_4_OF_12), - ColumnSize::Is5of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_5_OF_12), - ColumnSize::Is6of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_6_OF_12), - ColumnSize::Is7of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_7_OF_12), - ColumnSize::Is8of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_8_OF_12), - ColumnSize::Is9of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_9_OF_12), + ColumnSize::Default => self.alter_classes(ClassesOp::SetDefault, SIZE__DEFAULT), + ColumnSize::Is1of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__1_OF_12), + ColumnSize::Is2of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__2_OF_12), + ColumnSize::Is3of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__3_OF_12), + ColumnSize::Is4of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__4_OF_12), + ColumnSize::Is5of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__5_OF_12), + ColumnSize::Is6of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__6_OF_12), + ColumnSize::Is7of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__7_OF_12), + ColumnSize::Is8of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__8_OF_12), + ColumnSize::Is9of12 => self.alter_classes(ClassesOp::SetDefault, SIZE__9_OF_12), ColumnSize::Is10of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_10_OF_12), ColumnSize::Is11of12 => self.alter_classes(ClassesOp::SetDefault, SIZE_11_OF_12), ColumnSize::IsFull => self.alter_classes(ClassesOp::SetDefault, SIZE_12_OF_12), diff --git a/pagetop/src/base/component/grid/row.rs b/pagetop/src/base/component/grid/row.rs index 5653ef4e..2652bbce 100644 --- a/pagetop/src/base/component/grid/row.rs +++ b/pagetop/src/base/component/grid/row.rs @@ -4,6 +4,7 @@ pub_const_handler!(COMPONENT_ROW); hook_before_render_component!(HOOK_BEFORE_RENDER_ROW, Row); +#[rustfmt::skip] pub struct Row { weight : isize, renderable: Renderable, @@ -14,6 +15,7 @@ pub struct Row { } impl ComponentTrait for Row { + #[rustfmt::skip] fn new() -> Self { Row { weight : 0, diff --git a/pagetop/src/base/component/heading.rs b/pagetop/src/base/component/heading.rs index 219a345a..0695bad2 100644 --- a/pagetop/src/base/component/heading.rs +++ b/pagetop/src/base/component/heading.rs @@ -21,6 +21,7 @@ pub enum HeadingDisplay { Subtitle, } +#[rustfmt::skip] pub struct Heading { weight : isize, renderable : Renderable, @@ -33,6 +34,7 @@ pub struct Heading { } impl ComponentTrait for Heading { + #[rustfmt::skip] fn new() -> Self { Heading { weight : 0, @@ -191,6 +193,7 @@ impl Heading { self } + #[rustfmt::skip] pub fn alter_display(&mut self, display: HeadingDisplay) -> &mut Self { self.display = display; self.classes.alter( diff --git a/pagetop/src/base/component/html.rs b/pagetop/src/base/component/html.rs index bd12ccaa..8454960f 100644 --- a/pagetop/src/base/component/html.rs +++ b/pagetop/src/base/component/html.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub_const_handler!(COMPONENT_HTML); +#[rustfmt::skip] pub struct Html { weight : isize, renderable: Renderable, @@ -10,6 +11,7 @@ pub struct Html { } impl ComponentTrait for Html { + #[rustfmt::skip] fn new() -> Self { Html { weight : 0, diff --git a/pagetop/src/base/component/icon.rs b/pagetop/src/base/component/icon.rs index acf0c8e7..4b8eab6a 100644 --- a/pagetop/src/base/component/icon.rs +++ b/pagetop/src/base/component/icon.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub_const_handler!(COMPONENT_ICON); +#[rustfmt::skip] pub struct Icon { weight : isize, renderable: Renderable, @@ -10,6 +11,7 @@ pub struct Icon { } impl ComponentTrait for Icon { + #[rustfmt::skip] fn new() -> Self { Icon { weight : 0, diff --git a/pagetop/src/base/component/image.rs b/pagetop/src/base/component/image.rs index db173e3d..2e0de6d6 100644 --- a/pagetop/src/base/component/image.rs +++ b/pagetop/src/base/component/image.rs @@ -2,6 +2,7 @@ use crate::prelude::*; pub_const_handler!(COMPONENT_IMAGE); +#[rustfmt::skip] pub struct Image { weight : isize, renderable: Renderable, @@ -12,6 +13,7 @@ pub struct Image { } impl ComponentTrait for Image { + #[rustfmt::skip] fn new() -> Self { Image { weight : 0, diff --git a/pagetop/src/base/component/menu.rs b/pagetop/src/base/component/menu.rs index 84a9b8f9..2ee45773 100644 --- a/pagetop/src/base/component/menu.rs +++ b/pagetop/src/base/component/menu.rs @@ -14,6 +14,7 @@ pub enum MenuItemType { // MenuItem. +#[rustfmt::skip] pub struct MenuItem { weight : isize, renderable: Renderable, @@ -21,6 +22,7 @@ pub struct MenuItem { } impl ComponentTrait for MenuItem { + #[rustfmt::skip] fn new() -> Self { MenuItem { weight : 0, @@ -82,6 +84,7 @@ impl ComponentTrait for MenuItem { } impl MenuItem { + #[rustfmt::skip] pub fn label(label: &str) -> Self { MenuItem { weight : 0, @@ -90,6 +93,7 @@ impl MenuItem { } } + #[rustfmt::skip] pub fn link(label: &str, path: &str) -> Self { MenuItem { weight : 0, @@ -98,6 +102,7 @@ impl MenuItem { } } + #[rustfmt::skip] pub fn link_blank(label: &str, path: &str) -> Self { MenuItem { weight : 0, @@ -106,6 +111,7 @@ impl MenuItem { } } + #[rustfmt::skip] pub fn html(html: Markup) -> Self { MenuItem { weight : 0, @@ -114,6 +120,7 @@ impl MenuItem { } } + #[rustfmt::skip] pub fn separator() -> Self { MenuItem { weight : 0, @@ -122,6 +129,7 @@ impl MenuItem { } } + #[rustfmt::skip] pub fn submenu(label: &str, menu: Menu) -> Self { MenuItem { weight : 0, @@ -167,6 +175,7 @@ pub_const_handler!(COMPONENT_MENU); hook_before_render_component!(HOOK_BEFORE_RENDER_MENU, Menu); +#[rustfmt::skip] pub struct Menu { weight : isize, renderable: Renderable, @@ -177,6 +186,7 @@ pub struct Menu { } impl ComponentTrait for Menu { + #[rustfmt::skip] fn new() -> Self { Menu { weight : 0, diff --git a/pagetop/src/base/component/paragraph.rs b/pagetop/src/base/component/paragraph.rs index f469e180..74124be3 100644 --- a/pagetop/src/base/component/paragraph.rs +++ b/pagetop/src/base/component/paragraph.rs @@ -11,6 +11,7 @@ pub enum ParagraphDisplay { Normal, } +#[rustfmt::skip] pub struct Paragraph { weight : isize, renderable: Renderable, @@ -22,6 +23,7 @@ pub struct Paragraph { } impl ComponentTrait for Paragraph { + #[rustfmt::skip] fn new() -> Self { Paragraph { weight : 0, @@ -130,6 +132,7 @@ impl Paragraph { self } + #[rustfmt::skip] pub fn alter_display(&mut self, display: ParagraphDisplay) -> &mut Self { self.display = display; self.classes.alter( diff --git a/pagetop/src/base/module/homepage.rs b/pagetop/src/base/module/homepage.rs index 47f8ffcd..eb8e41dd 100644 --- a/pagetop/src/base/module/homepage.rs +++ b/pagetop/src/base/module/homepage.rs @@ -27,8 +27,8 @@ impl ModuleTrait for DefaultHomePage { async fn demo() -> ResultPage { Page::new() .with_title(l("page_title").as_str()) - .with_context(PageOp::AddStyleSheet( - StyleSheet::located("/theme/module/homepage/styles.css" + .with_context(PageOp::AddStyleSheet(StyleSheet::located( + "/theme/module/homepage/styles.css", ))) .add_to("region-content", hello_world()) .add_to("region-content", welcome()) diff --git a/pagetop/src/base/theme/aliner.rs b/pagetop/src/base/theme/aliner.rs index ca9bd6d1..3c73701f 100644 --- a/pagetop/src/base/theme/aliner.rs +++ b/pagetop/src/base/theme/aliner.rs @@ -16,12 +16,11 @@ impl ThemeTrait for Aliner { } fn before_render_page(&self, page: &mut Page) { - page - .alter_context(PageOp::AddFavicon( - Favicon::new().with_icon("/theme/favicon.png"), - )) - .alter_context(PageOp::AddStyleSheet( - StyleSheet::located("/aliner/css/styles.css").with_weight(-99), - )); + page.alter_context(PageOp::AddFavicon( + Favicon::new().with_icon("/theme/favicon.png"), + )) + .alter_context(PageOp::AddStyleSheet( + StyleSheet::located("/aliner/css/styles.css").with_weight(-99), + )); } } diff --git a/pagetop/src/base/theme/bootsier.rs b/pagetop/src/base/theme/bootsier.rs index 6033742a..ffdad73f 100644 --- a/pagetop/src/base/theme/bootsier.rs +++ b/pagetop/src/base/theme/bootsier.rs @@ -18,50 +18,46 @@ impl ThemeTrait for Bootsier { } fn before_render_page(&self, page: &mut Page) { - page - .alter_context(PageOp::AddFavicon( - Favicon::new().with_icon("/theme/favicon.png"), - )) - .alter_context(PageOp::AddStyleSheet( - StyleSheet::located("/bootsier/css/bootstrap.min.css") - .with_version("5.1.3") - .with_weight(-99), - )) - .alter_context(PageOp::AddJavaScript( - JavaScript::located("/bootsier/js/bootstrap.bundle.min.js") - .with_version("5.1.3") - .with_weight(-99), - )) - .alter_context(PageOp::AddJQuery); + page.alter_context(PageOp::AddFavicon( + Favicon::new().with_icon("/theme/favicon.png"), + )) + .alter_context(PageOp::AddStyleSheet( + StyleSheet::located("/bootsier/css/bootstrap.min.css") + .with_version("5.1.3") + .with_weight(-99), + )) + .alter_context(PageOp::AddJavaScript( + JavaScript::located("/bootsier/js/bootstrap.bundle.min.js") + .with_version("5.1.3") + .with_weight(-99), + )) + .alter_context(PageOp::AddJQuery); } fn error_404_not_found(&self) -> Container { - Container::new() - .with_component( - Html::with(html! { - div class="jumbotron" { - div class="media" { - img - src="/bootsier/images/caution.png" - class="mr-4" - style="width: 20%; max-width: 188px" - alt="Caution!"; - div class="media-body" { - h1 class="display-4" { ("RESOURCE NOT FOUND") } - p class="lead" { (l("e404-description")) } - hr class="my-4"; - p { (l("e404-description")) } - a - class="btn btn-primary btn-lg" - href="/" - role="button" - { - (l("back-homepage")) - } - } + Container::new().with_component(Html::with(html! { + div class="jumbotron" { + div class="media" { + img + src="/bootsier/images/caution.png" + class="mr-4" + style="width: 20%; max-width: 188px" + alt="Caution!"; + div class="media-body" { + h1 class="display-4" { ("RESOURCE NOT FOUND") } + p class="lead" { (l("e404-description")) } + hr class="my-4"; + p { (l("e404-description")) } + a + class="btn btn-primary btn-lg" + href="/" + role="button" + { + (l("back-homepage")) } } - }) - ) + } + } + })) } } diff --git a/pagetop/src/base/theme/bulmix.rs b/pagetop/src/base/theme/bulmix.rs index fae254ed..53b72c28 100644 --- a/pagetop/src/base/theme/bulmix.rs +++ b/pagetop/src/base/theme/bulmix.rs @@ -16,18 +16,18 @@ impl ThemeTrait for Bulmix { } fn before_render_page(&self, page: &mut Page) { - page - .alter_context(PageOp::AddFavicon( - Favicon::new().with_icon("/theme/favicon.png"), - )) - .alter_context(PageOp::AddStyleSheet( - StyleSheet::located("/bulmix/css/bulma.min.css") - .with_version("0.9.4") - .with_weight(-99), - )) - .alter_context(PageOp::AddJQuery); + page.alter_context(PageOp::AddFavicon( + Favicon::new().with_icon("/theme/favicon.png"), + )) + .alter_context(PageOp::AddStyleSheet( + StyleSheet::located("/bulmix/css/bulma.min.css") + .with_version("0.9.4") + .with_weight(-99), + )) + .alter_context(PageOp::AddJQuery); } + #[rustfmt::skip] fn before_render_component( &self, component: &mut dyn ComponentTrait, diff --git a/pagetop/src/config.rs b/pagetop/src/config.rs index 7c8b32d8..76dd5777 100644 --- a/pagetop/src/config.rs +++ b/pagetop/src/config.rs @@ -62,6 +62,7 @@ macro_rules! config_map { }; } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct App { pub name : String, @@ -73,6 +74,7 @@ pub struct App { pub run_mode : String, } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct Log { pub tracing : String, @@ -82,6 +84,7 @@ pub struct Log { pub format : String, } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct Database { pub db_type : String, @@ -93,17 +96,20 @@ pub struct Database { pub max_pool_size : u32, } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct Webserver { pub bind_address : String, pub bind_port : u16, } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct Dev { pub static_files : String, } +#[rustfmt::skip] #[derive(Debug, Deserialize)] pub struct Settings { pub app : App, diff --git a/pagetop/src/core/component/all.rs b/pagetop/src/core/component/all.rs index 74873a46..b307dc40 100644 --- a/pagetop/src/core/component/all.rs +++ b/pagetop/src/core/component/all.rs @@ -4,9 +4,8 @@ use crate::LazyStatic; use std::collections::HashMap; use std::sync::RwLock; -static COMPONENTS: LazyStatic>> = LazyStatic::new(|| - RwLock::new(HashMap::new()) -); +static COMPONENTS: LazyStatic>> = + LazyStatic::new(|| RwLock::new(HashMap::new())); pub fn add_component_to(region: &'static str, component: impl ComponentTrait) { let mut hmap = COMPONENTS.write().unwrap(); diff --git a/pagetop/src/core/hook.rs b/pagetop/src/core/hook.rs index 579c3bbc..2ccd6768 100644 --- a/pagetop/src/core/hook.rs +++ b/pagetop/src/core/hook.rs @@ -2,8 +2,8 @@ mod definition; pub use definition::{action_ref, AnyHookAction, HookActionTrait}; mod holder; -pub use holder::HookAction; use holder::ActionsHolder; +pub use holder::HookAction; mod all; pub(crate) use all::add_action; diff --git a/pagetop/src/core/hook/all.rs b/pagetop/src/core/hook/all.rs index e98d5ca3..a5eeb5a7 100644 --- a/pagetop/src/core/hook/all.rs +++ b/pagetop/src/core/hook/all.rs @@ -1,14 +1,13 @@ -use super::{HookAction, ActionsHolder}; -use crate::LazyStatic; +use super::{ActionsHolder, HookAction}; use crate::util::Handler; +use crate::LazyStatic; use std::collections::HashMap; use std::sync::RwLock; // Registered actions. -static ACTIONS: LazyStatic>> = LazyStatic::new(|| - RwLock::new(HashMap::new()) -); +static ACTIONS: LazyStatic>> = + LazyStatic::new(|| RwLock::new(HashMap::new())); pub fn add_action(action: HookAction) { let mut actions = ACTIONS.write().unwrap(); diff --git a/pagetop/src/core/module/all.rs b/pagetop/src/core/module/all.rs index d0b48655..803d1ac2 100644 --- a/pagetop/src/core/module/all.rs +++ b/pagetop/src/core/module/all.rs @@ -8,9 +8,8 @@ use crate::{db::*, run_now}; use std::sync::RwLock; // Enabled modules. -static ENABLED_MODULES: LazyStatic>> = LazyStatic::new(|| - RwLock::new(Vec::new()) -); +static ENABLED_MODULES: LazyStatic>> = + LazyStatic::new(|| RwLock::new(Vec::new())); /* Disabled modules. static DISABLED_MODULES: Lazy>> = Lazy::new(|| { @@ -35,7 +34,8 @@ fn add_to(list: &mut Vec<&dyn ModuleTrait>, module: &'static dyn ModuleTrait) { .read() .unwrap() .iter() - .any(|m| m.handler() == module.handler()) && !list.iter().any(|m| m.handler() == module.handler()) + .any(|m| m.handler() == module.handler()) + && !list.iter().any(|m| m.handler() == module.handler()) { trace::debug!("Enabling module \"{}\"", module.single_name()); list.push(module); diff --git a/pagetop/src/core/theme/all.rs b/pagetop/src/core/theme/all.rs index 923175fe..256be72a 100644 --- a/pagetop/src/core/theme/all.rs +++ b/pagetop/src/core/theme/all.rs @@ -6,9 +6,8 @@ use std::sync::RwLock; include!(concat!(env!("OUT_DIR"), "/theme.rs")); // Temas registrados. -static THEMES: LazyStatic>> = LazyStatic::new(|| - RwLock::new(Vec::new()) -); +static THEMES: LazyStatic>> = + LazyStatic::new(|| RwLock::new(Vec::new())); pub fn register_themes(themes: Vec<&'static dyn ThemeTrait>) { for t in themes { diff --git a/pagetop/src/core/theme/definition.rs b/pagetop/src/core/theme/definition.rs index f1a65d46..ab996e6c 100644 --- a/pagetop/src/core/theme/definition.rs +++ b/pagetop/src/core/theme/definition.rs @@ -125,25 +125,19 @@ pub trait ThemeTrait: BaseTheme + Send + Sync { } fn error_404_not_found(&self) -> Container { - Container::new() - .with_component( - Html::with(html! { - div { - h1 { ("RESOURCE NOT FOUND") } - } - }) - ) + Container::new().with_component(Html::with(html! { + div { + h1 { ("RESOURCE NOT FOUND") } + } + })) } fn error_403_access_denied(&self) -> Container { - Container::new() - .with_component( - Html::with(html! { - div { - h1 { ("FORBIDDEN ACCESS") } - } - }) - ) + Container::new().with_component(Html::with(html! { + div { + h1 { ("FORBIDDEN ACCESS") } + } + })) } } diff --git a/pagetop/src/html.rs b/pagetop/src/html.rs index 7bbfede9..eb8e1563 100644 --- a/pagetop/src/html.rs +++ b/pagetop/src/html.rs @@ -1,7 +1,7 @@ pub use maud::{html, Markup, PreEscaped, DOCTYPE}; mod assets; -pub use assets::javascript::{JavaScript, JSMode}; +pub use assets::javascript::{JavaScript, ModeJS}; pub use assets::stylesheet::{StyleSheet, TargetMedia}; pub use assets::Assets; diff --git a/pagetop/src/html/assets/javascript.rs b/pagetop/src/html/assets/javascript.rs index 70297e3a..8d72e7fd 100644 --- a/pagetop/src/html/assets/javascript.rs +++ b/pagetop/src/html/assets/javascript.rs @@ -2,18 +2,19 @@ use super::AssetsTrait; use crate::html::{html, Markup}; #[derive(PartialEq)] -pub enum JSMode { +pub enum ModeJS { Async, Defer, Normal, } +#[rustfmt::skip] pub struct JavaScript { source : &'static str, prefix : &'static str, version: &'static str, weight : isize, - mode : JSMode, + mode : ModeJS, } impl AssetsTrait for JavaScript { @@ -29,21 +30,22 @@ impl AssetsTrait for JavaScript { html! { script type="text/javascript" src=(crate::concat_string!(self.source, self.prefix, self.version)) - async[self.mode == JSMode::Async] - defer[self.mode == JSMode::Defer] + async[self.mode == ModeJS::Async] + defer[self.mode == ModeJS::Defer] {}; } } } impl JavaScript { + #[rustfmt::skip] pub fn located(source: &'static str) -> Self { JavaScript { source, prefix : "", version: "", weight : 0, - mode : JSMode::Defer, + mode : ModeJS::Defer, } } @@ -61,7 +63,7 @@ impl JavaScript { self } - pub fn with_mode(mut self, mode: JSMode) -> Self { + pub fn with_mode(mut self, mode: ModeJS) -> Self { self.mode = mode; self } diff --git a/pagetop/src/html/assets/stylesheet.rs b/pagetop/src/html/assets/stylesheet.rs index 481c0f5d..000af232 100644 --- a/pagetop/src/html/assets/stylesheet.rs +++ b/pagetop/src/html/assets/stylesheet.rs @@ -1,8 +1,14 @@ use super::AssetsTrait; use crate::html::{html, Markup}; -pub enum TargetMedia {Default, Print, Screen, Speech} +pub enum TargetMedia { + Default, + Print, + Screen, + Speech, +} +#[rustfmt::skip] pub struct StyleSheet { source : &'static str, prefix : &'static str, @@ -31,6 +37,7 @@ impl AssetsTrait for StyleSheet { } impl StyleSheet { + #[rustfmt::skip] pub fn located(source: &'static str) -> Self { StyleSheet { source, @@ -55,6 +62,7 @@ impl StyleSheet { self } + #[rustfmt::skip] pub fn for_media(mut self, media: TargetMedia) -> Self { self.media = match media { TargetMedia::Print => Some("print"), diff --git a/pagetop/src/html/classes.rs b/pagetop/src/html/classes.rs index dd60f177..3bdca35d 100644 --- a/pagetop/src/html/classes.rs +++ b/pagetop/src/html/classes.rs @@ -14,6 +14,7 @@ pub enum ClassesOp { SetDefaultIfEmpty, } +#[rustfmt::skip] #[derive(Default)] pub struct Classes { default: String, @@ -21,6 +22,7 @@ pub struct Classes { } impl Classes { + #[rustfmt::skip] pub fn new() -> Self { Classes { default: "".to_owned(), diff --git a/pagetop/src/html/favicon.rs b/pagetop/src/html/favicon.rs index d3819cf8..604a7873 100644 --- a/pagetop/src/html/favicon.rs +++ b/pagetop/src/html/favicon.rs @@ -29,10 +29,8 @@ impl Favicon { } pub fn with_theme_color(mut self, color: &str) -> Self { - self.0.push(format!( - "", - color - )); + self.0 + .push(format!("", color)); self } diff --git a/pagetop/src/prelude.rs b/pagetop/src/prelude.rs index 1420f1d6..f0935e37 100644 --- a/pagetop/src/prelude.rs +++ b/pagetop/src/prelude.rs @@ -1,15 +1,9 @@ //! Re-exporta recursos comunes. // Global macros and helpers. -pub use crate::{ - args, - concat_string, - pub_const_handler, - theme_static_files, - LazyStatic -}; pub use crate::util; pub use crate::util::Handler; +pub use crate::{args, concat_string, pub_const_handler, theme_static_files, LazyStatic}; pub use crate::config::SETTINGS; diff --git a/pagetop/src/response/page.rs b/pagetop/src/response/page.rs index cd6688fb..92a8241f 100644 --- a/pagetop/src/response/page.rs +++ b/pagetop/src/response/page.rs @@ -1,4 +1,4 @@ -use crate::html::{Favicon, StyleSheet, JavaScript}; +use crate::html::{Favicon, JavaScript, StyleSheet}; pub use actix_web::Result as ResultPage; diff --git a/pagetop/src/response/page/context.rs b/pagetop/src/response/page/context.rs index c77465e1..9b5ed179 100644 --- a/pagetop/src/response/page/context.rs +++ b/pagetop/src/response/page/context.rs @@ -2,16 +2,16 @@ use super::PageOp; use crate::config::SETTINGS; use crate::core::theme::all::theme_by_single_name; use crate::core::theme::ThemeTrait; -use crate::html::{html, Assets, Favicon, StyleSheet, JavaScript, JSMode, Markup, IdentifierValue}; +use crate::html::{html, Assets, Favicon, IdentifierValue, JavaScript, Markup, ModeJS, StyleSheet}; use crate::{base, concat_string, util, LazyStatic}; -static DEFAULT_THEME: LazyStatic<&dyn ThemeTrait> = LazyStatic::new(|| - match theme_by_single_name(&SETTINGS.app.theme) { +static DEFAULT_THEME: LazyStatic<&dyn ThemeTrait> = + LazyStatic::new(|| match theme_by_single_name(&SETTINGS.app.theme) { Some(theme) => theme, None => &base::theme::bootsier::Bootsier, - } -); + }); +#[rustfmt::skip] pub struct PageContext { theme : &'static dyn ThemeTrait, favicon : Option, @@ -24,6 +24,7 @@ pub struct PageContext { } impl PageContext { + #[rustfmt::skip] pub fn new() -> Self { PageContext { theme : *DEFAULT_THEME, @@ -76,7 +77,7 @@ impl PageContext { JavaScript::located("/theme/js/jquery.min.js") .with_version("3.6.0") .with_weight(isize::MIN) - .with_mode(JSMode::Normal), + .with_mode(ModeJS::Normal), ); self.with_jquery = true; } diff --git a/pagetop/src/response/page/definition.rs b/pagetop/src/response/page/definition.rs index 5543938d..6bbf0cd5 100644 --- a/pagetop/src/response/page/definition.rs +++ b/pagetop/src/response/page/definition.rs @@ -1,10 +1,4 @@ -use super::{ - BeforeRenderPageHook, - PageContext, - PageOp, - ResultPage, - HOOK_BEFORE_RENDER_PAGE, -}; +use super::{BeforeRenderPageHook, PageContext, PageOp, ResultPage, HOOK_BEFORE_RENDER_PAGE}; use crate::app::fatal_error::FatalError; use crate::config::SETTINGS; use crate::core::component::*; @@ -47,6 +41,7 @@ pub enum TextDirection { RightToLeft, } +#[rustfmt::skip] pub struct Page { context : PageContext, language : AttributeValue, @@ -59,6 +54,7 @@ pub struct Page { } impl Page { + #[rustfmt::skip] pub fn new() -> Self { Page { context : PageContext::new(), diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index 28a979d2..06ce3261 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -37,12 +37,8 @@ pub const fn handler( #[macro_export] macro_rules! pub_const_handler { ( $HANDLER:ident ) => { - pub const $HANDLER: $crate::util::Handler = $crate::util::handler( - module_path!(), - file!(), - line!(), - column!(), - ); + pub const $HANDLER: $crate::util::Handler = + $crate::util::handler(module_path!(), file!(), line!(), column!()); }; } @@ -89,10 +85,8 @@ macro_rules! theme_static_files { $cfg.service($crate::app::ResourceFiles::new($dir, generate())); } else { $cfg.service( - $crate::app::ActixFiles::new( - $dir, $crate::concat_string!(static_files, $dir) - ) - .show_files_listing(), + $crate::app::ActixFiles::new($dir, $crate::concat_string!(static_files, $dir)) + .show_files_listing(), ); } }};