⏪ Revierte lectura de los ajustes de configuración
This commit is contained in:
parent
104efd116f
commit
a11a24ceee
16 changed files with 65 additions and 62 deletions
|
|
@ -58,7 +58,7 @@ fn form_login() -> Form {
|
||||||
t(
|
t(
|
||||||
"username_help",
|
"username_help",
|
||||||
&args![
|
&args![
|
||||||
"app" => config::get("app.name").to_owned()
|
"app" => SETTINGS.app.name.to_owned()
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use super::fatal_error::FatalError;
|
use super::fatal_error::FatalError;
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
use crate::core::module::ModuleStaticRef;
|
use crate::core::module::ModuleStaticRef;
|
||||||
use crate::core::{module, theme};
|
use crate::core::{module, theme};
|
||||||
use crate::html::Markup;
|
use crate::html::Markup;
|
||||||
|
|
@ -39,7 +39,7 @@ impl Application {
|
||||||
module::all::register_actions();
|
module::all::register_actions();
|
||||||
|
|
||||||
// Inicializa valores predefinidos de configuración.
|
// Inicializa valores predefinidos de configuración.
|
||||||
module::all::init_settings();
|
// module::all::init_settings();
|
||||||
|
|
||||||
// Inicializa los módulos.
|
// Inicializa los módulos.
|
||||||
module::all::init_modules();
|
module::all::init_modules();
|
||||||
|
|
@ -58,8 +58,8 @@ impl Application {
|
||||||
})
|
})
|
||||||
.bind(format!(
|
.bind(format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
config::get("webserver.bind_address"),
|
&SETTINGS.webserver.bind_address,
|
||||||
config::get("webserver.bind_port")
|
&SETTINGS.webserver.bind_port
|
||||||
))?
|
))?
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
mod figfont;
|
mod figfont;
|
||||||
use figfont::FIGFONT;
|
use figfont::FIGFONT;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
|
|
||||||
use substring::Substring;
|
use substring::Substring;
|
||||||
|
|
||||||
pub fn print_on_startup() {
|
pub fn print_on_startup() {
|
||||||
if config::get("app.startup_banner").to_lowercase() != "off" {
|
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||||
if let Some((term_width, _)) = term_size::dimensions() {
|
if let Some((term_width, _)) = term_size::dimensions() {
|
||||||
if term_width >= 80 {
|
if term_width >= 80 {
|
||||||
let maxlen = (term_width / 10) - 2;
|
let maxlen = (term_width / 10) - 2;
|
||||||
let mut app = config::get("app.name").substring(0, maxlen).to_owned();
|
let mut app = SETTINGS.app.name.substring(0, maxlen).to_owned();
|
||||||
if config::get("app.name").len() > maxlen {
|
if SETTINGS.app.name.len() > maxlen {
|
||||||
app = format!("{}...", app);
|
app = format!("{}...", app);
|
||||||
}
|
}
|
||||||
println!(
|
println!(
|
||||||
"\n{} {}\n\n Powered by PageTop {}\n",
|
"\n{} {}\n\n Powered by PageTop {}\n",
|
||||||
FIGFONT.convert(&app).unwrap(),
|
FIGFONT.convert(&app).unwrap(),
|
||||||
config::get("app.description"),
|
&SETTINGS.app.description,
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -25,8 +25,8 @@ pub fn print_on_startup() {
|
||||||
}
|
}
|
||||||
println!(
|
println!(
|
||||||
"\n{}\n{}\n\nPowered by PageTop {}\n",
|
"\n{}\n{}\n\nPowered by PageTop {}\n",
|
||||||
config::get("app.name"),
|
&SETTINGS.app.name,
|
||||||
config::get("app.description"),
|
&SETTINGS.app.description,
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{config, LazyStatic};
|
use crate::config::SETTINGS;
|
||||||
|
use crate::LazyStatic;
|
||||||
|
|
||||||
use figlet_rs::FIGfont;
|
use figlet_rs::FIGfont;
|
||||||
|
|
||||||
|
|
@ -8,7 +9,7 @@ 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::get("app.startup_banner").to_lowercase().as_str() {
|
FIGfont::from_content(match SETTINGS.app.startup_banner.to_lowercase().as_str() {
|
||||||
"off" => slant,
|
"off" => slant,
|
||||||
"slant" => slant,
|
"slant" => slant,
|
||||||
"small" => small,
|
"small" => small,
|
||||||
|
|
@ -17,7 +18,7 @@ pub static FIGFONT: LazyStatic<FIGfont> = LazyStatic::new(|| {
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"\n FIGfont \"{}\" not found for banner. Using \"Slant\". Check the settings file.",
|
"\n FIGfont \"{}\" not found for banner. Using \"Slant\". Check the settings file.",
|
||||||
config::get("app.startup_banner"),
|
SETTINGS.app.startup_banner,
|
||||||
);
|
);
|
||||||
slant
|
slant
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
use crate::db::*;
|
use crate::db::*;
|
||||||
use crate::{run_now, trace, LazyStatic};
|
use crate::{run_now, trace, LazyStatic};
|
||||||
|
|
||||||
|
|
@ -8,38 +8,39 @@ use tracing_unwrap::ResultExt;
|
||||||
pub static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
|
pub static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
|
||||||
trace::info!(
|
trace::info!(
|
||||||
"Connecting to database \"{}\" using a pool of {} connections",
|
"Connecting to database \"{}\" using a pool of {} connections",
|
||||||
config::get("database.db_name"),
|
&SETTINGS.database.db_name,
|
||||||
config::get("database.max_pool_size")
|
&SETTINGS.database.max_pool_size
|
||||||
);
|
);
|
||||||
|
|
||||||
let db_uri = match config::get("database.db_type").as_str() {
|
let db_uri = match SETTINGS.database.db_type.as_str() {
|
||||||
"mysql" | "postgres" => {
|
"mysql" | "postgres" => {
|
||||||
let mut tmp_uri = DbUri::parse(
|
let mut tmp_uri = DbUri::parse(
|
||||||
format!(
|
format!(
|
||||||
"{}://{}/{}",
|
"{}://{}/{}",
|
||||||
config::get("database.db_type"),
|
&SETTINGS.database.db_type,
|
||||||
config::get("database.db_host"),
|
&SETTINGS.database.db_host,
|
||||||
config::get("database.db_name")
|
&SETTINGS.database.db_name
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tmp_uri
|
tmp_uri
|
||||||
.set_username(config::get("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(config::get("database.db_pass").as_str()))
|
.set_password(Some(SETTINGS.database.db_pass.as_str()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if config::get_value::<u16>("database.db_port") != 0 {
|
if SETTINGS.database.db_port != 0 {
|
||||||
tmp_uri.set_port(Some(config::get_value::<u16>("database.db_port"))).unwrap();
|
tmp_uri.set_port(Some(SETTINGS.database.db_port)).unwrap();
|
||||||
}
|
}
|
||||||
tmp_uri
|
tmp_uri
|
||||||
}
|
}
|
||||||
"sqlite" => DbUri::parse(
|
"sqlite" => DbUri::parse(
|
||||||
format!(
|
format!(
|
||||||
"{}://{}",
|
"{}://{}",
|
||||||
config::get("database.db_type"), &config::get("database.db_name")
|
&SETTINGS.database.db_type,
|
||||||
|
&SETTINGS.database.db_name
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
)
|
)
|
||||||
|
|
@ -47,7 +48,7 @@ pub static DBCONN: LazyStatic<DbConn> = LazyStatic::new(|| {
|
||||||
_ => {
|
_ => {
|
||||||
trace::error!(
|
trace::error!(
|
||||||
"Unrecognized database type \"{}\"",
|
"Unrecognized database type \"{}\"",
|
||||||
config::get("database.db_type")
|
&SETTINGS.database.db_type
|
||||||
);
|
);
|
||||||
DbUri::parse("").unwrap()
|
DbUri::parse("").unwrap()
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +56,7 @@ pub static DBCONN: LazyStatic<DbConn> = LazyStatic::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(config::get_value::<u32>("database.max_pool_size"));
|
db_opt.max_connections(SETTINGS.database.max_pool_size);
|
||||||
db_opt
|
db_opt
|
||||||
}))
|
}))
|
||||||
.expect_or_log("Failed to connect to database")
|
.expect_or_log("Failed to connect to database")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{config, trace, LazyStatic};
|
use crate::config::SETTINGS;
|
||||||
|
use crate::{trace, LazyStatic};
|
||||||
|
|
||||||
use unic_langid::LanguageIdentifier;
|
use unic_langid::LanguageIdentifier;
|
||||||
|
|
||||||
|
|
@ -6,14 +7,14 @@ use unic_langid::LanguageIdentifier;
|
||||||
/// (https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier)) de
|
/// (https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier)) de
|
||||||
/// la aplicación, obtenido de `SETTINGS.app.language`.
|
/// la aplicación, obtenido de `SETTINGS.app.language`.
|
||||||
pub static LANGID: LazyStatic<LanguageIdentifier> =
|
pub static LANGID: LazyStatic<LanguageIdentifier> =
|
||||||
LazyStatic::new(|| match config::get("app.language").parse() {
|
LazyStatic::new(|| match SETTINGS.app.language.parse() {
|
||||||
Ok(language) => language,
|
Ok(language) => language,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
trace::warn!(
|
trace::warn!(
|
||||||
"{}, {} \"{}\"! {}, {}",
|
"{}, {} \"{}\"! {}, {}",
|
||||||
"Failed to parse language",
|
"Failed to parse language",
|
||||||
"unrecognized Unicode Language Identifier",
|
"unrecognized Unicode Language Identifier",
|
||||||
config::get("app.language"),
|
SETTINGS.app.language,
|
||||||
"Using \"en-US\"",
|
"Using \"en-US\"",
|
||||||
"check the settings file",
|
"check the settings file",
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{config, LazyStatic};
|
use crate::config::SETTINGS;
|
||||||
|
use crate::LazyStatic;
|
||||||
|
|
||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
@ -19,14 +20,14 @@ use tracing_subscriber::EnvFilter;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
pub static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
let env_filter =
|
let env_filter =
|
||||||
EnvFilter::try_new(config::get("log.tracing")).unwrap_or_else(|_| EnvFilter::new("Info"));
|
EnvFilter::try_new(&SETTINGS.log.tracing).unwrap_or_else(|_| EnvFilter::new("Info"));
|
||||||
|
|
||||||
let rolling = config::get("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() {
|
||||||
"stdout" => tracing_appender::non_blocking(std::io::stdout()),
|
"stdout" => tracing_appender::non_blocking(std::io::stdout()),
|
||||||
_ => tracing_appender::non_blocking({
|
_ => tracing_appender::non_blocking({
|
||||||
let path = config::get("log.path");
|
let path = &SETTINGS.log.path;
|
||||||
let prefix = config::get("log.prefix");
|
let prefix = &SETTINGS.log.prefix;
|
||||||
match rolling.as_str() {
|
match rolling.as_str() {
|
||||||
"daily" => tracing_appender::rolling::daily(path, prefix),
|
"daily" => tracing_appender::rolling::daily(path, prefix),
|
||||||
"hourly" => tracing_appender::rolling::hourly(path, prefix),
|
"hourly" => tracing_appender::rolling::hourly(path, prefix),
|
||||||
|
|
@ -35,7 +36,7 @@ pub static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"Rolling value \"{}\" not valid. Using \"daily\". Check the settings file.",
|
"Rolling value \"{}\" not valid. Using \"daily\". Check the settings file.",
|
||||||
config::get("log.rolling"),
|
SETTINGS.log.rolling,
|
||||||
);
|
);
|
||||||
tracing_appender::rolling::daily(path, prefix)
|
tracing_appender::rolling::daily(path, prefix)
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +47,7 @@ pub static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
.with_env_filter(env_filter)
|
.with_env_filter(env_filter)
|
||||||
.with_writer(non_blocking)
|
.with_writer(non_blocking)
|
||||||
.with_ansi(rolling.as_str() == "stdout");
|
.with_ansi(rolling.as_str() == "stdout");
|
||||||
match config::get("log.format").to_lowercase().as_str() {
|
match SETTINGS.log.format.to_lowercase().as_str() {
|
||||||
"json" => subscriber.json().init(),
|
"json" => subscriber.json().init(),
|
||||||
"full" => subscriber.init(),
|
"full" => subscriber.init(),
|
||||||
"compact" => subscriber.compact().init(),
|
"compact" => subscriber.compact().init(),
|
||||||
|
|
@ -54,7 +55,7 @@ pub static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"Tracing format \"{}\" not valid. Using \"Full\". Check the settings file.",
|
"Tracing format \"{}\" not valid. Using \"Full\". Check the settings file.",
|
||||||
config::get("log.format"),
|
SETTINGS.log.format,
|
||||||
);
|
);
|
||||||
subscriber.init();
|
subscriber.init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ fn hello_world() -> Container {
|
||||||
.with_component(
|
.with_component(
|
||||||
Paragraph::with(html! {
|
Paragraph::with(html! {
|
||||||
(e("hello_intro", &args![
|
(e("hello_intro", &args![
|
||||||
"app" => format!("<span class=\"app-name\">{}</span>", config::get("app.name"))
|
"app" => format!("<span class=\"app-name\">{}</span>", &SETTINGS.app.name)
|
||||||
]))
|
]))
|
||||||
})
|
})
|
||||||
.with_display(ParagraphDisplay::Small),
|
.with_display(ParagraphDisplay::Small),
|
||||||
|
|
@ -101,7 +101,7 @@ fn welcome() -> Container {
|
||||||
.with_component(
|
.with_component(
|
||||||
Heading::h3(html! {
|
Heading::h3(html! {
|
||||||
(e("welcome_subtitle", &args![
|
(e("welcome_subtitle", &args![
|
||||||
"app" => format!("<span class=\"app-name\">{}</span>", config::get("app.name"))
|
"app" => format!("<span class=\"app-name\">{}</span>", &SETTINGS.app.name)
|
||||||
]))
|
]))
|
||||||
})
|
})
|
||||||
.with_display(HeadingDisplay::Subtitle),
|
.with_display(HeadingDisplay::Subtitle),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use super::ModuleStaticRef;
|
use super::ModuleStaticRef;
|
||||||
use crate::config;
|
|
||||||
use crate::core::hook::add_action;
|
use crate::core::hook::add_action;
|
||||||
use crate::core::theme;
|
use crate::core::theme;
|
||||||
use crate::{app, trace, LazyStatic};
|
use crate::{app, trace, LazyStatic};
|
||||||
|
|
@ -87,14 +86,14 @@ pub fn register_actions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// INIT SETTINGS ***********************************************************************************
|
// INIT SETTINGS ***********************************************************************************
|
||||||
|
/*
|
||||||
pub fn init_settings() {
|
pub fn init_settings() {
|
||||||
trace::info!("initializing custom predefined settings");
|
trace::info!("initializing custom predefined settings");
|
||||||
for m in ENABLED_MODULES.read().unwrap().iter() {
|
for m in ENABLED_MODULES.read().unwrap().iter() {
|
||||||
config::add_predefined_settings(m.settings());
|
settings::add_predefined_settings(m.settings());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// INIT MODULES ************************************************************************************
|
// INIT MODULES ************************************************************************************
|
||||||
|
|
||||||
pub fn init_modules() {
|
pub fn init_modules() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::app;
|
use crate::app;
|
||||||
use crate::predefined_settings;
|
//use crate::predefined_settings;
|
||||||
use crate::config::PredefinedSettings;
|
//use crate::settings::PredefinedSettings;
|
||||||
use crate::core::hook::HookAction;
|
use crate::core::hook::HookAction;
|
||||||
use crate::core::theme::ThemeStaticRef;
|
use crate::core::theme::ThemeStaticRef;
|
||||||
use crate::util::{single_type_name, Handler};
|
use crate::util::{single_type_name, Handler};
|
||||||
|
|
@ -41,11 +41,11 @@ pub trait ModuleTrait: BaseModule + Send + Sync {
|
||||||
fn actions(&self) -> Vec<HookAction> {
|
fn actions(&self) -> Vec<HookAction> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
fn settings(&self) -> PredefinedSettings {
|
fn settings(&self) -> PredefinedSettings {
|
||||||
predefined_settings![]
|
predefined_settings![]
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fn init(&self) {}
|
fn init(&self) {}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::app;
|
use crate::app;
|
||||||
use crate::base::component::{Container, Html};
|
use crate::base::component::{Container, Html};
|
||||||
use crate::concat_string;
|
use crate::concat_string;
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
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};
|
||||||
|
|
@ -43,9 +43,9 @@ pub trait ThemeTrait: BaseTheme + Send + Sync {
|
||||||
|
|
||||||
@match page.title().get() {
|
@match page.title().get() {
|
||||||
Some(t) => title {
|
Some(t) => title {
|
||||||
(concat_string!(config::get("app.name"), " | ", t))
|
(concat_string!(SETTINGS.app.name, " | ", t))
|
||||||
},
|
},
|
||||||
None => title { (config::get("app.name")) }
|
None => title { (SETTINGS.app.name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@match page.description().get() {
|
@match page.description().get() {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
// GLOBAL.
|
// GLOBAL.
|
||||||
|
|
||||||
pub use concat_string::concat_string;
|
pub use concat_string::concat_string;
|
||||||
|
pub use doc_comment::doc_comment;
|
||||||
pub use once_cell::sync::Lazy as LazyStatic;
|
pub use once_cell::sync::Lazy as LazyStatic;
|
||||||
|
|
||||||
// LOCAL.
|
// LOCAL.
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ pub use crate::{
|
||||||
args, concat_string, configure_service_for_static_files, pub_const_handler, LazyStatic,
|
args, concat_string, configure_service_for_static_files, pub_const_handler, LazyStatic,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use crate::config;
|
pub use crate::config::SETTINGS;
|
||||||
pub use crate::config::PredefinedSettings;
|
|
||||||
|
|
||||||
pub use crate::trace;
|
pub use crate::trace;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use super::PageOp;
|
use super::PageOp;
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
use crate::core::theme::{all::theme_by_single_name, ThemeStaticRef};
|
use crate::core::theme::{all::theme_by_single_name, ThemeStaticRef};
|
||||||
use crate::html::{html, Assets, Favicon, IdentifierValue, JavaScript, Markup, ModeJS, StyleSheet};
|
use crate::html::{html, Assets, Favicon, IdentifierValue, JavaScript, Markup, ModeJS, StyleSheet};
|
||||||
use crate::{base, concat_string, util, LazyStatic};
|
use crate::{base, concat_string, util, LazyStatic};
|
||||||
|
|
||||||
static DEFAULT_THEME: LazyStatic<ThemeStaticRef> =
|
static DEFAULT_THEME: LazyStatic<ThemeStaticRef> =
|
||||||
LazyStatic::new(|| match theme_by_single_name(&config::get("app.theme")) {
|
LazyStatic::new(|| match theme_by_single_name(&SETTINGS.app.theme) {
|
||||||
Some(theme) => theme,
|
Some(theme) => theme,
|
||||||
None => &base::theme::bootsier::Bootsier,
|
None => &base::theme::bootsier::Bootsier,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
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::app::fatal_error::FatalError;
|
||||||
use crate::config;
|
use crate::config::SETTINGS;
|
||||||
use crate::core::component::*;
|
use crate::core::component::*;
|
||||||
use crate::core::hook::{action_ref, run_actions};
|
use crate::core::hook::{action_ref, run_actions};
|
||||||
use crate::html::{html, AttributeValue, Classes, ClassesOp, Markup, DOCTYPE};
|
use crate::html::{html, AttributeValue, Classes, ClassesOp, Markup, DOCTYPE};
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::{trace, LazyStatic};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
static DEFAULT_LANGUAGE: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
static DEFAULT_LANGUAGE: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
||||||
let language = config::get("app.language")[..2].to_lowercase();
|
let language = SETTINGS.app.language[..2].to_lowercase();
|
||||||
if !language.is_empty() {
|
if !language.is_empty() {
|
||||||
Some(language)
|
Some(language)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -18,7 +18,7 @@ static DEFAULT_LANGUAGE: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
static DEFAULT_DIRECTION: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
static DEFAULT_DIRECTION: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
||||||
let direction = config::get("app.direction").to_lowercase();
|
let direction = SETTINGS.app.direction.to_lowercase();
|
||||||
match direction.as_str() {
|
match direction.as_str() {
|
||||||
"auto" => Some("auto".to_owned()),
|
"auto" => Some("auto".to_owned()),
|
||||||
"ltr" => Some("ltr".to_owned()),
|
"ltr" => Some("ltr".to_owned()),
|
||||||
|
|
@ -27,7 +27,7 @@ static DEFAULT_DIRECTION: LazyStatic<Option<String>> = LazyStatic::new(|| {
|
||||||
_ => {
|
_ => {
|
||||||
trace::warn!(
|
trace::warn!(
|
||||||
"Text direction \"{}\" not valid, {}",
|
"Text direction \"{}\" not valid, {}",
|
||||||
config::get("app.direction"),
|
SETTINGS.app.direction,
|
||||||
"check the settings file"
|
"check the settings file"
|
||||||
);
|
);
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ macro_rules! args {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! configure_service_for_static_files {
|
macro_rules! configure_service_for_static_files {
|
||||||
( $cfg:ident, $dir:expr, $embed:ident ) => {{
|
( $cfg:ident, $dir:expr, $embed:ident ) => {{
|
||||||
let static_files = $crate::config::get("dev.static_files");
|
let static_files = &$crate::config::SETTINGS.dev.static_files;
|
||||||
if static_files.is_empty() {
|
if static_files.is_empty() {
|
||||||
$cfg.service($crate::app::ResourceFiles::new($dir, $embed()));
|
$cfg.service($crate::app::ResourceFiles::new($dir, $embed()));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue