♻️ Revisa código con cargo fmt y cargo clippy

This commit is contained in:
Manuel Cillero 2022-11-10 23:56:49 +01:00
parent 46d4e19c39
commit f1932d6749
6 changed files with 34 additions and 34 deletions

View file

@ -55,7 +55,8 @@ impl Application {
}) })
.bind(format!( .bind(format!(
"{}:{}", "{}:{}",
&config::SETTINGS.server.bind_address, &config::SETTINGS.server.bind_port &config::SETTINGS.server.bind_address,
&config::SETTINGS.server.bind_port
))? ))?
.run(); .run();

View file

@ -8,19 +8,21 @@ pub static FIGFONT: LazyStatic<FIGfont> = LazyStatic::new(|| {
let speed = include_str!("speed.flf"); let speed = include_str!("speed.flf");
let starwars = include_str!("starwars.flf"); let starwars = include_str!("starwars.flf");
FIGfont::from_content(match config::SETTINGS.app.startup_banner.to_lowercase().as_str() { FIGfont::from_content(
"off" => slant, match config::SETTINGS.app.startup_banner.to_lowercase().as_str() {
"slant" => slant, "off" => slant,
"small" => small, "slant" => slant,
"speed" => speed, "small" => small,
"starwars" => starwars, "speed" => speed,
_ => { "starwars" => starwars,
println!( _ => {
"\n FIGfont \"{}\" not found for banner. Using \"Slant\". Check settings files.", println!(
config::SETTINGS.app.startup_banner, "\n FIGfont \"{}\" not found for banner. Using \"Slant\". Check settings files.",
); config::SETTINGS.app.startup_banner,
slant );
} slant
}) }
},
)
.unwrap() .unwrap()
}); });

View file

@ -1,5 +1,5 @@
use crate::{config, run_now, trace, LazyStatic};
use crate::db::*; use crate::db::*;
use crate::{config, run_now, trace, LazyStatic};
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement}; use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement};
use tracing_unwrap::ResultExt; use tracing_unwrap::ResultExt;
@ -31,14 +31,17 @@ pub static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
.set_password(Some(config::SETTINGS.database.db_pass.as_str())) .set_password(Some(config::SETTINGS.database.db_pass.as_str()))
.unwrap(); .unwrap();
if config::SETTINGS.database.db_port != 0 { if config::SETTINGS.database.db_port != 0 {
tmp_uri.set_port(Some(config::SETTINGS.database.db_port)).unwrap(); tmp_uri
.set_port(Some(config::SETTINGS.database.db_port))
.unwrap();
} }
tmp_uri tmp_uri
} }
"sqlite" => DbUri::parse( "sqlite" => DbUri::parse(
format!( format!(
"{}://{}", "{}://{}",
&config::SETTINGS.database.db_type, &config::SETTINGS.database.db_name &config::SETTINGS.database.db_type,
&config::SETTINGS.database.db_name
) )
.as_str(), .as_str(),
) )
@ -60,9 +63,7 @@ pub static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
.expect_or_log("Failed to connect to database") .expect_or_log("Failed to connect to database")
}); });
static DBBACKEND: LazyStatic<DatabaseBackend> = LazyStatic::new(|| static DBBACKEND: LazyStatic<DatabaseBackend> = LazyStatic::new(|| DBCONN.get_database_backend());
DBCONN.get_database_backend()
);
pub async fn query<Q: QueryStatementWriter>(stmt: &mut Q) -> Result<Vec<QueryResult>, DbErr> { pub async fn query<Q: QueryStatementWriter>(stmt: &mut Q) -> Result<Vec<QueryResult>, DbErr> {
DBCONN DBCONN

View file

@ -82,19 +82,16 @@ fn hello_world() -> Container {
.with_classes(ClassesOp::Add, "code-link"), .with_classes(ClassesOp::Add, "code-link"),
) )
.with_component( .with_component(
Anchor::link( Anchor::link("#welcome", html! { (l("hello_welcome")) })
"#welcome", .with_left_icon(Icon::with("arrow-down-circle-fill"))
html! { (l("hello_welcome")) }, .with_classes(ClassesOp::Add, "welcome-link"),
)
.with_left_icon(Icon::with("arrow-down-circle-fill"))
.with_classes(ClassesOp::Add, "welcome-link"),
), ),
) )
.with_column( .with_column(
grid::Column::new() grid::Column::new()
.with_classes(ClassesOp::Add, "hello-col-image") .with_classes(ClassesOp::Add, "hello-col-image")
.with_component(Image::new_with_source("/theme/images/homepage-header.svg")), .with_component(Image::new_with_source("/theme/images/homepage-header.svg")),
) ),
) )
} }
@ -158,7 +155,7 @@ fn about_pagetop() -> Container {
) )
])) ]))
})), })),
) ),
) )
} }
@ -189,7 +186,7 @@ fn promo_pagetop() -> Container {
.with_classes(ClassesOp::Add, "promo-col-image") .with_classes(ClassesOp::Add, "promo-col-image")
.with_size(grid::ColumnSize::Is6of12) .with_size(grid::ColumnSize::Is6of12)
.with_component(Image::new_with_source("/theme/images/homepage-pagetop.png")), .with_component(Image::new_with_source("/theme/images/homepage-pagetop.png")),
) ),
) )
} }
@ -217,6 +214,6 @@ fn reporting_problems() -> Container {
.with_component(Paragraph::with(html! { .with_component(Paragraph::with(html! {
(l("report_problems_text2")) (l("report_problems_text2"))
})), })),
) ),
) )
} }

View file

@ -164,7 +164,7 @@ pub static CONFIG: LazyStatic<ConfigData> = LazyStatic::new(|| {
/// ///
/// Ver [`Cómo añadir ajustes de configuración`](config/index.html#cómo-añadir-ajustes-de-configuración). /// Ver [`Cómo añadir ajustes de configuración`](config/index.html#cómo-añadir-ajustes-de-configuración).
macro_rules! pub_config { macro_rules! pub_config {
( $S:ident: $t:ty $(, $k:literal => $v:literal)*$(,)* ) => { crate::doc_comment! { ( $S:ident: $t:ty $(, $k:literal => $v:literal)*$(,)* ) => { $crate::doc_comment! {
concat!( concat!(
"Declara y asigna los valores predefinidos para los ajustes de configuración ", "Declara y asigna los valores predefinidos para los ajustes de configuración ",
"asociados a la estructura [`", stringify!($t), "`]." "asociados a la estructura [`", stringify!($t), "`]."
@ -182,7 +182,6 @@ macro_rules! pub_config {
}}; }};
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
/// Ajustes globales para las secciones reservadas [`[app]`](App), [`[database]`](Database), /// Ajustes globales para las secciones reservadas [`[app]`](App), [`[database]`](Database),
/// [`[dev]`](Dev), [`[log]`](Log) y [`[server]`](Server) (ver [`SETTINGS`]). /// [`[dev]`](Dev), [`[log]`](Log) y [`[server]`](Server) (ver [`SETTINGS`]).

View file

@ -1,9 +1,9 @@
use crate::{app, concat_string, config};
use crate::base::component::{Container, Html}; use crate::base::component::{Container, Html};
use crate::core::component::ComponentTrait; use crate::core::component::ComponentTrait;
use crate::html::{html, Favicon, Markup}; use crate::html::{html, Favicon, Markup};
use crate::response::page::{Page, PageContext, PageOp}; use crate::response::page::{Page, PageContext, PageOp};
use crate::util::{single_type_name, Handle}; use crate::util::{single_type_name, Handle};
use crate::{app, concat_string, config};
pub type ThemeStaticRef = &'static dyn ThemeTrait; pub type ThemeStaticRef = &'static dyn ThemeTrait;