Actualiza formato del código aplicando cargo fmt
This commit is contained in:
parent
31daf11faa
commit
592cd9ccda
42 changed files with 210 additions and 167 deletions
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<LanguageIdentifier> = LazyStatic::new(||
|
||||
match SETTINGS.app.language.parse() {
|
||||
pub static LANGID: LazyStatic<LanguageIdentifier> =
|
||||
LazyStatic::new(|| match SETTINGS.app.language.parse() {
|
||||
Ok(language) => language,
|
||||
Err(_) => {
|
||||
trace::warn!(
|
||||
|
|
@ -20,5 +20,4 @@ pub static LANGID: LazyStatic<LanguageIdentifier> = LazyStatic::new(||
|
|||
);
|
||||
"en-US".parse().unwrap()
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@ use tracing_subscriber::EnvFilter;
|
|||
/// `Lazy<WorkerGuard>` se garantiza que todos los registros almacenados se
|
||||
/// enviarán antes de terminar la ejecución.
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub static TRACING: LazyStatic<WorkerGuard> = 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() {
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ impl ModuleTrait for DefaultHomePage {
|
|||
async fn demo() -> ResultPage<Markup, FatalError> {
|
||||
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())
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ impl ThemeTrait for Aliner {
|
|||
}
|
||||
|
||||
fn before_render_page(&self, page: &mut Page) {
|
||||
page
|
||||
.alter_context(PageOp::AddFavicon(
|
||||
page.alter_context(PageOp::AddFavicon(
|
||||
Favicon::new().with_icon("/theme/favicon.png"),
|
||||
))
|
||||
.alter_context(PageOp::AddStyleSheet(
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ impl ThemeTrait for Bootsier {
|
|||
}
|
||||
|
||||
fn before_render_page(&self, page: &mut Page) {
|
||||
page
|
||||
.alter_context(PageOp::AddFavicon(
|
||||
page.alter_context(PageOp::AddFavicon(
|
||||
Favicon::new().with_icon("/theme/favicon.png"),
|
||||
))
|
||||
.alter_context(PageOp::AddStyleSheet(
|
||||
|
|
@ -36,9 +35,7 @@ impl ThemeTrait for Bootsier {
|
|||
}
|
||||
|
||||
fn error_404_not_found(&self) -> Container {
|
||||
Container::new()
|
||||
.with_component(
|
||||
Html::with(html! {
|
||||
Container::new().with_component(Html::with(html! {
|
||||
div class="jumbotron" {
|
||||
div class="media" {
|
||||
img
|
||||
|
|
@ -61,7 +58,6 @@ impl ThemeTrait for Bootsier {
|
|||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ impl ThemeTrait for Bulmix {
|
|||
}
|
||||
|
||||
fn before_render_page(&self, page: &mut Page) {
|
||||
page
|
||||
.alter_context(PageOp::AddFavicon(
|
||||
page.alter_context(PageOp::AddFavicon(
|
||||
Favicon::new().with_icon("/theme/favicon.png"),
|
||||
))
|
||||
.alter_context(PageOp::AddStyleSheet(
|
||||
|
|
@ -28,6 +27,7 @@ impl ThemeTrait for Bulmix {
|
|||
.alter_context(PageOp::AddJQuery);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn before_render_component(
|
||||
&self,
|
||||
component: &mut dyn ComponentTrait,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ use crate::LazyStatic;
|
|||
use std::collections::HashMap;
|
||||
use std::sync::RwLock;
|
||||
|
||||
static COMPONENTS: LazyStatic<RwLock<HashMap<&str, ComponentsBundle>>> = LazyStatic::new(||
|
||||
RwLock::new(HashMap::new())
|
||||
);
|
||||
static COMPONENTS: LazyStatic<RwLock<HashMap<&str, ComponentsBundle>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
pub fn add_component_to(region: &'static str, component: impl ComponentTrait) {
|
||||
let mut hmap = COMPONENTS.write().unwrap();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<RwLock<HashMap<Handler, ActionsHolder>>> = LazyStatic::new(||
|
||||
RwLock::new(HashMap::new())
|
||||
);
|
||||
static ACTIONS: LazyStatic<RwLock<HashMap<Handler, ActionsHolder>>> =
|
||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
pub fn add_action(action: HookAction) {
|
||||
let mut actions = ACTIONS.write().unwrap();
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ use crate::{db::*, run_now};
|
|||
use std::sync::RwLock;
|
||||
|
||||
// Enabled modules.
|
||||
static ENABLED_MODULES: LazyStatic<RwLock<Vec<&dyn ModuleTrait>>> = LazyStatic::new(||
|
||||
RwLock::new(Vec::new())
|
||||
);
|
||||
static ENABLED_MODULES: LazyStatic<RwLock<Vec<&dyn ModuleTrait>>> =
|
||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||
|
||||
/* Disabled modules.
|
||||
static DISABLED_MODULES: Lazy<RwLock<Vec<&dyn ModuleTrait>>> = 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);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@ use std::sync::RwLock;
|
|||
include!(concat!(env!("OUT_DIR"), "/theme.rs"));
|
||||
|
||||
// Temas registrados.
|
||||
static THEMES: LazyStatic<RwLock<Vec<&dyn ThemeTrait>>> = LazyStatic::new(||
|
||||
RwLock::new(Vec::new())
|
||||
);
|
||||
static THEMES: LazyStatic<RwLock<Vec<&dyn ThemeTrait>>> =
|
||||
LazyStatic::new(|| RwLock::new(Vec::new()));
|
||||
|
||||
pub fn register_themes(themes: Vec<&'static dyn ThemeTrait>) {
|
||||
for t in themes {
|
||||
|
|
|
|||
|
|
@ -125,25 +125,19 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
|||
}
|
||||
|
||||
fn error_404_not_found(&self) -> Container {
|
||||
Container::new()
|
||||
.with_component(
|
||||
Html::with(html! {
|
||||
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! {
|
||||
Container::new().with_component(Html::with(html! {
|
||||
div {
|
||||
h1 { ("FORBIDDEN ACCESS") }
|
||||
}
|
||||
})
|
||||
)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -29,10 +29,8 @@ impl Favicon {
|
|||
}
|
||||
|
||||
pub fn with_theme_color(mut self, color: &str) -> Self {
|
||||
self.0.push(format!(
|
||||
"<meta name=\"theme-color\" content=\"{}\">",
|
||||
color
|
||||
));
|
||||
self.0
|
||||
.push(format!("<meta name=\"theme-color\" content=\"{}\">", color));
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::html::{Favicon, StyleSheet, JavaScript};
|
||||
use crate::html::{Favicon, JavaScript, StyleSheet};
|
||||
|
||||
pub use actix_web::Result as ResultPage;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Favicon>,
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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,9 +85,7 @@ 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)
|
||||
)
|
||||
$crate::app::ActixFiles::new($dir, $crate::concat_string!(static_files, $dir))
|
||||
.show_files_listing(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue