diff --git a/pagetop/src/app.rs b/pagetop/src/app.rs index f4f08b3a..7426617c 100644 --- a/pagetop/src/app.rs +++ b/pagetop/src/app.rs @@ -1,8 +1,10 @@ +mod figfont; + use crate::core::{module, module::ModuleStaticRef}; use crate::html::Markup; use crate::response::page::ResultPage; use crate::response::FatalError; -use crate::{config, locale, server, trace, util, LazyStatic}; +use crate::{config, locale, server, trace, LazyStatic}; #[cfg(feature = "database")] use crate::db; @@ -11,6 +13,8 @@ use actix_web::dev::Server; use std::io::Error; +use substring::Substring; + pub struct Application { server: Server, } @@ -18,7 +22,29 @@ pub struct Application { impl Application { pub fn prepare(app: ModuleStaticRef) -> Result { // Rótulo de presentación. - util::print_on_startup(); + if config::SETTINGS.app.startup_banner.to_lowercase() != "off" { + if let Some((term_width, _)) = term_size::dimensions() { + if term_width >= 80 { + let maxlen = (term_width / 10) - 2; + let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned(); + if config::SETTINGS.app.name.len() > maxlen { + app = format!("{}...", app); + } + println!( + "\n{} {}\n\n Powered by PageTop {}\n", + figfont::FIGFONT.convert(&app).unwrap(), + &config::SETTINGS.app.description, + env!("CARGO_PKG_VERSION") + ); + } + } + println!( + "\n{}\n{}\n\nPowered by PageTop {}\n", + &config::SETTINGS.app.name, + &config::SETTINGS.app.description, + env!("CARGO_PKG_VERSION") + ); + } // Inicia registro de trazas y eventos. LazyStatic::force(&trace::TRACING); diff --git a/pagetop/src/util/figfont.rs b/pagetop/src/app/figfont.rs similarity index 100% rename from pagetop/src/util/figfont.rs rename to pagetop/src/app/figfont.rs diff --git a/pagetop/src/util/slant.flf b/pagetop/src/app/slant.flf similarity index 100% rename from pagetop/src/util/slant.flf rename to pagetop/src/app/slant.flf diff --git a/pagetop/src/util/small.flf b/pagetop/src/app/small.flf similarity index 100% rename from pagetop/src/util/small.flf rename to pagetop/src/app/small.flf diff --git a/pagetop/src/util/speed.flf b/pagetop/src/app/speed.flf similarity index 100% rename from pagetop/src/util/speed.flf rename to pagetop/src/app/speed.flf diff --git a/pagetop/src/util/starwars.flf b/pagetop/src/app/starwars.flf similarity index 100% rename from pagetop/src/util/starwars.flf rename to pagetop/src/app/starwars.flf diff --git a/pagetop/src/util.rs b/pagetop/src/util.rs index d355f942..fd0e533a 100644 --- a/pagetop/src/util.rs +++ b/pagetop/src/util.rs @@ -1,42 +1,9 @@ -mod figfont; - -use crate::config; - -use substring::Substring; - pub use static_files::Resource as StaticResource; pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>; pub type Handle = u64; -pub(crate) fn print_on_startup() { - if config::SETTINGS.app.startup_banner.to_lowercase() != "off" { - if let Some((term_width, _)) = term_size::dimensions() { - if term_width >= 80 { - let maxlen = (term_width / 10) - 2; - let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned(); - if config::SETTINGS.app.name.len() > maxlen { - app = format!("{}...", app); - } - println!( - "\n{} {}\n\n Powered by PageTop {}\n", - figfont::FIGFONT.convert(&app).unwrap(), - &config::SETTINGS.app.description, - env!("CARGO_PKG_VERSION") - ); - return; - } - } - println!( - "\n{}\n{}\n\nPowered by PageTop {}\n", - &config::SETTINGS.app.name, - &config::SETTINGS.app.description, - env!("CARGO_PKG_VERSION") - ); - } -} - // https://stackoverflow.com/a/71464396 pub const fn handle( module_path: &'static str,