♻️ El rótulo de inicio pasa a ser una utilidad
La función para la presentación del nombre del proyecto en forma de rótulo ASCII pasa a las utilidades fuera de la API de PageTop.
This commit is contained in:
parent
7ed2d37e52
commit
06276b618c
9 changed files with 35 additions and 38 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::base::banner;
|
|
||||||
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;
|
||||||
use crate::response::page::ResultPage;
|
use crate::response::page::ResultPage;
|
||||||
use crate::response::FatalError;
|
use crate::response::FatalError;
|
||||||
use crate::{config, locale, server, trace, LazyStatic};
|
use crate::{config, locale, server, trace, util, LazyStatic};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
use crate::db;
|
use crate::db;
|
||||||
|
|
@ -20,7 +19,7 @@ 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.
|
||||||
banner::print_on_startup();
|
util::print_on_startup();
|
||||||
|
|
||||||
// Inicia registro de trazas y eventos.
|
// Inicia registro de trazas y eventos.
|
||||||
LazyStatic::force(&trace::TRACING);
|
LazyStatic::force(&trace::TRACING);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
pub(crate) mod banner;
|
|
||||||
|
|
||||||
pub mod component;
|
pub mod component;
|
||||||
pub mod module;
|
pub mod module;
|
||||||
pub mod theme;
|
pub mod theme;
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
mod figfont;
|
|
||||||
use figfont::FIGFONT;
|
|
||||||
|
|
||||||
use crate::config;
|
|
||||||
|
|
||||||
use substring::Substring;
|
|
||||||
|
|
||||||
pub 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.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")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,42 @@
|
||||||
|
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