Actualiza y revisa código aplicando cargo clippy
This commit is contained in:
parent
e6ea59785e
commit
f3d57eb0aa
23 changed files with 45 additions and 53 deletions
|
|
@ -51,7 +51,7 @@ fn form_login() -> Form {
|
||||||
Form::new()
|
Form::new()
|
||||||
.with_id("user-login")
|
.with_id("user-login")
|
||||||
.with_element(
|
.with_element(
|
||||||
form::Input::textfield()
|
form_element::Input::textfield()
|
||||||
.with_name("name")
|
.with_name("name")
|
||||||
.with_label(l("username").as_str())
|
.with_label(l("username").as_str())
|
||||||
.with_help_text(
|
.with_help_text(
|
||||||
|
|
@ -66,10 +66,10 @@ fn form_login() -> Form {
|
||||||
.with_autofocus(true),
|
.with_autofocus(true),
|
||||||
)
|
)
|
||||||
.with_element(
|
.with_element(
|
||||||
form::Input::password()
|
form_element::Input::password()
|
||||||
.with_name("pass")
|
.with_name("pass")
|
||||||
.with_label(l("password").as_str())
|
.with_label(l("password").as_str())
|
||||||
.with_help_text(l("password_help").as_str()),
|
.with_help_text(l("password_help").as_str()),
|
||||||
)
|
)
|
||||||
.with_element(form::Button::submit(l("login").as_str()))
|
.with_element(form_element::Button::submit(l("login").as_str()))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ pub static FIGFONT: Lazy<FIGfont> = Lazy::new(|| {
|
||||||
"starwars" => starwars,
|
"starwars" => starwars,
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"\n FIGfont \"{}\" not found for banner. {}. {}.",
|
"\n FIGfont \"{}\" not found for banner. Using \"Slant\". Check the settings file.",
|
||||||
SETTINGS.app.startup_banner, "Using \"Slant\"", "Check the settings file",
|
SETTINGS.app.startup_banner,
|
||||||
);
|
);
|
||||||
slant
|
slant
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ pub static DBCONN: Lazy<DbConn> = Lazy::new(|| {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tmp_uri
|
tmp_uri
|
||||||
.set_username(&SETTINGS.database.db_user.as_str())
|
.set_username(SETTINGS.database.db_user.as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// https://github.com/launchbadge/sqlx/issues/1624
|
// https://github.com/launchbadge/sqlx/issues/1624
|
||||||
tmp_uri
|
tmp_uri
|
||||||
.set_password(Some(&SETTINGS.database.db_pass.as_str()))
|
.set_password(Some(SETTINGS.database.db_pass.as_str()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if SETTINGS.database.db_port != 0 {
|
if SETTINGS.database.db_port != 0 {
|
||||||
tmp_uri.set_port(Some(SETTINGS.database.db_port)).unwrap();
|
tmp_uri.set_port(Some(SETTINGS.database.db_port)).unwrap();
|
||||||
|
|
@ -56,7 +56,7 @@ pub static DBCONN: Lazy<DbConn> = Lazy::new(|| {
|
||||||
run_now(Database::connect::<ConnectOptions>({
|
run_now(Database::connect::<ConnectOptions>({
|
||||||
let mut db_opt = ConnectOptions::new(db_uri.to_string());
|
let mut db_opt = ConnectOptions::new(db_uri.to_string());
|
||||||
db_opt.max_connections(SETTINGS.database.max_pool_size);
|
db_opt.max_connections(SETTINGS.database.max_pool_size);
|
||||||
db_opt.into()
|
db_opt
|
||||||
}))
|
}))
|
||||||
.expect_or_log("Failed to connect to database")
|
.expect_or_log("Failed to connect to database")
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use tracing_subscriber::EnvFilter;
|
||||||
/// enviarán antes de terminar la ejecución.
|
/// enviarán antes de terminar la ejecución.
|
||||||
|
|
||||||
pub static TRACING: Lazy<WorkerGuard> = Lazy::new(|| {
|
pub static TRACING: Lazy<WorkerGuard> = Lazy::new(|| {
|
||||||
let env_filter = EnvFilter::try_new(&SETTINGS.log.tracing).unwrap_or(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 rolling = SETTINGS.log.rolling.to_lowercase();
|
||||||
let (non_blocking, guard) = match rolling.as_str() {
|
let (non_blocking, guard) = match rolling.as_str() {
|
||||||
|
|
@ -33,8 +33,8 @@ pub static TRACING: Lazy<WorkerGuard> = Lazy::new(|| {
|
||||||
"endless" => tracing_appender::rolling::never(path, prefix),
|
"endless" => tracing_appender::rolling::never(path, prefix),
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"Rolling value \"{}\" not valid. {}. {}.",
|
"Rolling value \"{}\" not valid. Using \"daily\". Check the settings file.",
|
||||||
SETTINGS.log.rolling, "Using \"daily\"", "Check the settings file",
|
SETTINGS.log.rolling,
|
||||||
);
|
);
|
||||||
tracing_appender::rolling::daily(path, prefix)
|
tracing_appender::rolling::daily(path, prefix)
|
||||||
}
|
}
|
||||||
|
|
@ -52,8 +52,8 @@ pub static TRACING: Lazy<WorkerGuard> = Lazy::new(|| {
|
||||||
"pretty" => subscriber.pretty().init(),
|
"pretty" => subscriber.pretty().init(),
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"Tracing format \"{}\" not valid. {}. {}.",
|
"Tracing format \"{}\" not valid. Using \"Full\". Check the settings file.",
|
||||||
SETTINGS.log.format, "Using \"Full\"", "Check the settings file",
|
SETTINGS.log.format,
|
||||||
);
|
);
|
||||||
subscriber.init();
|
subscriber.init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,5 +20,5 @@ pub use image::{Image, COMPONENT_IMAGE};
|
||||||
mod menu;
|
mod menu;
|
||||||
pub use menu::{Menu, MenuItem, MenuItemType, COMPONENT_MENU, COMPONENT_MENUITEM};
|
pub use menu::{Menu, MenuItem, MenuItemType, COMPONENT_MENU, COMPONENT_MENUITEM};
|
||||||
|
|
||||||
pub mod form;
|
pub mod form_element;
|
||||||
pub use form::{Form, FormMethod, COMPONENT_FORM};
|
pub use form_element::{Form, FormMethod, COMPONENT_FORM};
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,7 @@ impl ComponentTrait for Button {
|
||||||
ButtonType::Reset => "reset",
|
ButtonType::Reset => "reset",
|
||||||
ButtonType::Submit => "submit",
|
ButtonType::Submit => "submit",
|
||||||
};
|
};
|
||||||
let id = match self.name().get() {
|
let id = self.name().get().map(|name| concat_string!("edit-", name));
|
||||||
Some(name) => Some(concat_string!("edit-", name)),
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
html! {
|
html! {
|
||||||
button
|
button
|
||||||
type=(button_type)
|
type=(button_type)
|
||||||
|
|
@ -86,7 +83,7 @@ impl ComponentTrait for Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
pub fn button(value: &str) -> Self {
|
pub fn new_with_value(value: &str) -> Self {
|
||||||
Button::new().with_value(value)
|
Button::new().with_value(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,10 +53,7 @@ impl ComponentTrait for Date {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||||
let id = match self.name().get() {
|
let id = self.name().get().map(|name| concat_string!("edit-", name));
|
||||||
Some(name) => Some(concat_string!("edit-", name)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
html! {
|
html! {
|
||||||
div class=[self.classes().get()] {
|
div class=[self.classes().get()] {
|
||||||
@match self.label().get() {
|
@match self.label().get() {
|
||||||
|
|
@ -26,10 +26,7 @@ impl ComponentTrait for Hidden {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_render(&self, _: &mut InContext) -> Markup {
|
fn default_render(&self, _: &mut InContext) -> Markup {
|
||||||
let id = match self.name().get() {
|
let id = self.name().get().map(|name| concat_string!("value-", name));
|
||||||
Some(name) => Some(concat_string!("value-", name)),
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
html! {
|
html! {
|
||||||
input type="hidden" id=[id] name=[self.name().get()] value=[self.value().get()];
|
input type="hidden" id=[id] name=[self.name().get()] value=[self.value().get()];
|
||||||
}
|
}
|
||||||
|
|
@ -78,10 +78,7 @@ impl ComponentTrait for Input {
|
||||||
InputType::Textfield => "text",
|
InputType::Textfield => "text",
|
||||||
InputType::Url => "url",
|
InputType::Url => "url",
|
||||||
};
|
};
|
||||||
let id = match self.name().get() {
|
let id = self.name().get().map(|name| concat_string!("edit-", name));
|
||||||
Some(name) => Some(concat_string!("edit-", name)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
html! {
|
html! {
|
||||||
div class=[self.classes().get()] {
|
div class=[self.classes().get()] {
|
||||||
@match self.label().get() {
|
@match self.label().get() {
|
||||||
|
|
@ -54,7 +54,7 @@ impl ComponentTrait for Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Image {
|
impl Image {
|
||||||
pub fn image(source: &str) -> Self {
|
pub fn new_with_source(source: &str) -> Self {
|
||||||
Image::new().with_source(source)
|
Image::new().with_source(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ fn hello_world() -> Container {
|
||||||
.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::image("/theme/images/demo-header.svg")),
|
.with_component(Image::new_with_source("/theme/images/demo-header.svg")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +121,7 @@ fn about_pagetop() -> Container {
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "pagetop-col-image")
|
.with_classes(ClassesOp::Add, "pagetop-col-image")
|
||||||
.with_size(grid::ColumnSize::Is5of12)
|
.with_size(grid::ColumnSize::Is5of12)
|
||||||
.with_component(Image::image("/theme/images/demo-about.svg")),
|
.with_component(Image::new_with_source("/theme/images/demo-about.svg")),
|
||||||
)
|
)
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
|
|
@ -152,7 +152,7 @@ fn promo_pagetop() -> Container {
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "promo-col-image")
|
.with_classes(ClassesOp::Add, "promo-col-image")
|
||||||
.with_size(grid::ColumnSize::Is5of12)
|
.with_size(grid::ColumnSize::Is5of12)
|
||||||
.with_component(Image::image("/theme/images/demo-pagetop.svg")),
|
.with_component(Image::new_with_source("/theme/images/demo-pagetop.svg")),
|
||||||
)
|
)
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
|
|
@ -195,7 +195,7 @@ fn reporting_problems() -> Container {
|
||||||
.with_column(
|
.with_column(
|
||||||
grid::Column::new()
|
grid::Column::new()
|
||||||
.with_classes(ClassesOp::Add, "reporting-col-image")
|
.with_classes(ClassesOp::Add, "reporting-col-image")
|
||||||
.with_component(Image::image("/theme/images/demo-pagetop.svg")),
|
.with_component(Image::new_with_source("/theme/images/demo-pagetop.svg")),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use serde::Deserialize;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
/// Nombre del directorio donde se encuentra la configuración.
|
/// Nombre del directorio donde se encuentra la configuración.
|
||||||
const CONFIG_DIR: &'static str = "config";
|
const CONFIG_DIR: &str = "config";
|
||||||
|
|
||||||
/// Al arrancar la aplicación, carga los valores originales "clave = valor" de
|
/// Al arrancar la aplicación, carga los valores originales "clave = valor" de
|
||||||
/// los archivos de configuración. Con [`config_map`] se asignarán los ajustes
|
/// los archivos de configuración. Con [`config_map`] se asignarán los ajustes
|
||||||
|
|
@ -15,7 +15,7 @@ const CONFIG_DIR: &'static str = "config";
|
||||||
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
||||||
// Establece el modo de ejecución según el valor de la variable de entorno
|
// Establece el modo de ejecución según el valor de la variable de entorno
|
||||||
// PAGETOP_RUN_MODE. Asume "default" por defecto.
|
// PAGETOP_RUN_MODE. Asume "default" por defecto.
|
||||||
let run_mode = env::var("PAGETOP_RUN_MODE").unwrap_or("default".into());
|
let run_mode = env::var("PAGETOP_RUN_MODE").unwrap_or_else(|_| "default".into());
|
||||||
|
|
||||||
// Inicializa los ajustes.
|
// Inicializa los ajustes.
|
||||||
let mut settings = Config::default();
|
let mut settings = Config::default();
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::html::{html, Markup};
|
||||||
|
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
pub struct ComponentsBundle(Vec<Arc<RwLock<dyn ComponentTrait>>>);
|
pub struct ComponentsBundle(Vec<Arc<RwLock<dyn ComponentTrait>>>);
|
||||||
|
|
||||||
impl ComponentsBundle {
|
impl ComponentsBundle {
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,11 @@ impl InContext {
|
||||||
|
|
||||||
pub fn required_id<T>(&mut self, id: &IdentifierValue) -> String {
|
pub fn required_id<T>(&mut self, id: &IdentifierValue) -> String {
|
||||||
match id.get() {
|
match id.get() {
|
||||||
Some(id) => id.to_string(),
|
Some(id) => id,
|
||||||
None => {
|
None => {
|
||||||
let prefix = util::single_type_name::<T>()
|
let prefix = util::single_type_name::<T>()
|
||||||
.trim()
|
.trim()
|
||||||
.replace(" ", "_")
|
.replace(' ', "_")
|
||||||
.to_lowercase();
|
.to_lowercase();
|
||||||
let prefix = if prefix.is_empty() {
|
let prefix = if prefix.is_empty() {
|
||||||
"prefix".to_owned()
|
"prefix".to_owned()
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,15 @@ fn add_to(list: &mut Vec<&dyn ModuleTrait>, module: &'static dyn ModuleTrait) {
|
||||||
.read()
|
.read()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|m| m.handler() == module.handler())
|
.any(|m| m.handler() == module.handler()) && !list.iter().any(|m| m.handler() == module.handler())
|
||||||
{
|
{
|
||||||
if !list.iter().any(|m| m.handler() == module.handler()) {
|
trace::debug!("Enabling module \"{}\"", module.single_name());
|
||||||
trace::debug!("Enabling module \"{}\"", module.single_name());
|
list.push(module);
|
||||||
list.push(module);
|
|
||||||
|
|
||||||
let mut dependencies = module.dependencies();
|
let mut dependencies = module.dependencies();
|
||||||
dependencies.reverse();
|
dependencies.reverse();
|
||||||
for d in dependencies.iter() {
|
for d in dependencies.iter() {
|
||||||
add_to(list, *d);
|
add_to(list, *d);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ macro_rules! pub_migration {
|
||||||
|
|
||||||
impl MigrationName for $migration {
|
impl MigrationName for $migration {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
crate::util::partial_type_name(module_path!(), 1)
|
$crate::util::partial_type_name(module_path!(), 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ pub enum AssetsOp<T: AssetsTrait> {
|
||||||
Add(T),
|
Add(T),
|
||||||
Remove(SourceValue),
|
Remove(SourceValue),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Assets<T>(Vec<T>);
|
pub struct Assets<T>(Vec<T>);
|
||||||
|
|
||||||
impl<T: AssetsTrait> Assets<T> {
|
impl<T: AssetsTrait> Assets<T> {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(Default)]
|
||||||
pub struct AttributeValue(String);
|
pub struct AttributeValue(String);
|
||||||
|
|
||||||
impl AttributeValue {
|
impl AttributeValue {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ pub enum ClassesOp {
|
||||||
SetDefaultIfEmpty,
|
SetDefaultIfEmpty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Classes {
|
pub struct Classes {
|
||||||
default: String,
|
default: String,
|
||||||
added : String,
|
added : String,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::html::{html, Markup, PreEscaped};
|
use crate::html::{html, Markup, PreEscaped};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Favicon(Vec<String>);
|
pub struct Favicon(Vec<String>);
|
||||||
|
|
||||||
impl Favicon {
|
impl Favicon {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(Default)]
|
||||||
pub struct IdentifierValue(String);
|
pub struct IdentifierValue(String);
|
||||||
|
|
||||||
impl IdentifierValue {
|
impl IdentifierValue {
|
||||||
|
|
@ -12,7 +13,7 @@ impl IdentifierValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_value(&mut self, value: &str) -> &Self {
|
pub fn with_value(&mut self, value: &str) -> &Self {
|
||||||
self.0 = value.trim().replace(" ", "_");
|
self.0 = value.trim().replace(' ', "_");
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue