Añade un rótulo opcional al arrancar la aplicación
This commit is contained in:
parent
24e773c17b
commit
5d2901d32a
8 changed files with 4444 additions and 9 deletions
|
|
@ -70,23 +70,24 @@ macro_rules! config_map {
|
|||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct App {
|
||||
pub name : String,
|
||||
pub description : String,
|
||||
pub language : String,
|
||||
pub theme : String,
|
||||
pub run_mode : String,
|
||||
pub name : String,
|
||||
pub description : String,
|
||||
pub language : String,
|
||||
pub theme : String,
|
||||
pub startup_banner: String,
|
||||
pub run_mode : String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Webserver {
|
||||
pub bind_address : String,
|
||||
pub bind_port : u16,
|
||||
pub bind_address : String,
|
||||
pub bind_port : u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Settings {
|
||||
pub app : App,
|
||||
pub webserver : Webserver,
|
||||
pub app : App,
|
||||
pub webserver : Webserver,
|
||||
}
|
||||
|
||||
config_map!(r#"
|
||||
|
|
@ -100,6 +101,7 @@ Ajustes globales y valores predeterminados para las secciones *\[app\]* y
|
|||
"app.description" => "Developed with the amazing PageTop framework.",
|
||||
"app.language" => "en-US",
|
||||
"app.theme" => "Minimal",
|
||||
"app.startup_banner" => "Small",
|
||||
|
||||
// [webserver]
|
||||
"webserver.bind_address" => "localhost",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,24 @@ pub fn run(bootstrap: Option<fn()>) -> Result<Server, std::io::Error> {
|
|||
// Al ser el último, puede sobrecargarse en la función de arranque.
|
||||
register_module(&base::module::homepage::HomepageModule);
|
||||
|
||||
// Si el arranque ha ido bien imprime un rótulo opcional de bienvenida.
|
||||
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||
let figfont = figlet_rs::FIGfont::from_content(
|
||||
match SETTINGS.app.startup_banner.to_lowercase().as_str() {
|
||||
"slant" => include_str!("../../../resources/slant.flf"),
|
||||
"small" => include_str!("../../../resources/small.flf"),
|
||||
"speed" => include_str!("../../../resources/speed.flf"),
|
||||
"starwars" => include_str!("../../../resources/starwars.flf"),
|
||||
_ => include_str!("../../../resources/small.flf")
|
||||
}
|
||||
).unwrap();
|
||||
println!("\n{} {}\n\n Powered by PageTop {}\n",
|
||||
figfont.convert(&SETTINGS.app.name).unwrap(),
|
||||
&SETTINGS.app.description,
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
|
||||
// Inicializa el servidor web.
|
||||
let server = server::HttpServer::new(|| {
|
||||
server::App::new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue