♻️ Revisa la impresión del banner de inicio
This commit is contained in:
parent
199a5defe2
commit
99b08fa201
7 changed files with 28 additions and 35 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
|
mod figfont;
|
||||||
|
|
||||||
use crate::core::{module, module::ModuleStaticRef};
|
use crate::core::{module, module::ModuleStaticRef};
|
||||||
use crate::html::Markup;
|
use crate::html::Markup;
|
||||||
use crate::response::page::ResultPage;
|
use crate::response::page::ResultPage;
|
||||||
use crate::response::FatalError;
|
use crate::response::FatalError;
|
||||||
use crate::{config, locale, server, trace, util, LazyStatic};
|
use crate::{config, locale, server, trace, LazyStatic};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::db;
|
use crate::db;
|
||||||
|
|
@ -11,6 +13,8 @@ use actix_web::dev::Server;
|
||||||
|
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
|
||||||
|
use substring::Substring;
|
||||||
|
|
||||||
pub struct Application {
|
pub struct Application {
|
||||||
server: Server,
|
server: Server,
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +22,29 @@ pub struct Application {
|
||||||
impl Application {
|
impl Application {
|
||||||
pub fn prepare(app: ModuleStaticRef) -> Result<Self, Error> {
|
pub fn prepare(app: ModuleStaticRef) -> Result<Self, Error> {
|
||||||
// Rótulo de presentación.
|
// 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.
|
// Inicia registro de trazas y eventos.
|
||||||
LazyStatic::force(&trace::TRACING);
|
LazyStatic::force(&trace::TRACING);
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,9 @@
|
||||||
mod figfont;
|
|
||||||
|
|
||||||
use crate::config;
|
|
||||||
|
|
||||||
use substring::Substring;
|
|
||||||
|
|
||||||
pub use static_files::Resource as StaticResource;
|
pub use static_files::Resource as StaticResource;
|
||||||
|
|
||||||
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
pub type HashMapResources = std::collections::HashMap<&'static str, StaticResource>;
|
||||||
|
|
||||||
pub type Handle = u64;
|
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
|
// https://stackoverflow.com/a/71464396
|
||||||
pub const fn handle(
|
pub const fn handle(
|
||||||
module_path: &'static str,
|
module_path: &'static str,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue