🎨 IImprove the printing of banner on app startup
This commit is contained in:
parent
dd93cfb9c8
commit
117416a429
3 changed files with 19 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[app]
|
||||
name = "PageTop Application"
|
||||
description = "Developed with the amazing PageTop framework."
|
||||
description = "Developed with the awesome PageTop framework."
|
||||
# Tema predeterminado.
|
||||
theme = "Default"
|
||||
# Idioma (localización) predeterminado.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::core::{module, module::ModuleRef};
|
|||
use crate::html::Markup;
|
||||
use crate::response::fatal_error::FatalError;
|
||||
use crate::response::page::ResultPage;
|
||||
use crate::{config, locale, service, trace, LazyStatic};
|
||||
use crate::{concat_string, config, locale, service, trace, LazyStatic};
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use crate::db;
|
||||
|
|
@ -94,26 +94,29 @@ impl Application {
|
|||
|
||||
fn print_on_startup() {
|
||||
if config::SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||
// Application name.
|
||||
let mut app_name = config::SETTINGS.app.name.to_string();
|
||||
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 {
|
||||
let mut app = app_name.substring(0, maxlen).to_owned();
|
||||
if 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;
|
||||
app_name = figfont::FIGFONT.convert(&app).unwrap().to_string();
|
||||
}
|
||||
}
|
||||
// Application description.
|
||||
let app_description = if !config::SETTINGS.app.description.is_empty() {
|
||||
concat_string!("\n", config::SETTINGS.app.description)
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
// Print banner.
|
||||
println!(
|
||||
"\n{}\n{}\n\nPowered by PageTop {}\n",
|
||||
&config::SETTINGS.app.name,
|
||||
&config::SETTINGS.app.description,
|
||||
"\n{}{}\n\nPowered by PageTop {}\n",
|
||||
app_name,
|
||||
app_description,
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ pub struct App {
|
|||
/// Por defecto: *"PageTop App"*.
|
||||
pub name: String,
|
||||
/// Una descripción breve de la aplicación.
|
||||
/// Por defecto: *"Modular web solutions made simple with PageTop."*.
|
||||
/// Por defecto: *"Developed with the awesome PageTop framework."*.
|
||||
pub description: String,
|
||||
/// Tema predeterminado.
|
||||
/// Por defecto: *"Default"*.
|
||||
|
|
@ -283,7 +283,7 @@ pub struct Server {
|
|||
default_settings!(
|
||||
// [app]
|
||||
"app.name" => "PageTop App",
|
||||
"app.description" => "Modular web solutions made simple with PageTop.",
|
||||
"app.description" => "Developed with the awesome PageTop framework.",
|
||||
"app.theme" => "Default",
|
||||
"app.language" => "en-US",
|
||||
"app.direction" => "ltr",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue