Actualiza la estructura de los recursos estáticos
Se prepara PageTop para permitir en el futuro compilar los fuentes incluyendo los recursos estáticos dentro del ejecutable (tal y como está ahora), o usando una carpeta externa "static".
This commit is contained in:
parent
7f8b94eafe
commit
eddb397bc7
35 changed files with 48 additions and 125 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
# FIGfonts
|
# FIGfonts
|
||||||
|
|
||||||
PageTop utiliza el paquete [figlet-rs](https://crates.io/crates/figlet-rs) de
|
PageTop utiliza el paquete [figlet-rs](https://crates.io/crates/figlet-rs) de
|
||||||
*yuanbohan* para mostrar al inicio un rótulo con el nombre de la aplicación
|
*yuanbohan*, que muestra al inicio de la ejecución un rótulo con el nombre de
|
||||||
usando [FIGlet](http://www.figlet.org/). Las fuentes incluidas en `resources`
|
la aplicación usando caracteres [FIGlet](http://www.figlet.org/). Las fuentes
|
||||||
son:
|
incluidas en `resources` son:
|
||||||
|
|
||||||
* [slant.flf](http://www.figlet.org/fontdb_example.cgi?font=slant.flf)
|
* [slant.flf](http://www.figlet.org/fontdb_example.cgi?font=slant.flf)
|
||||||
por *Glenn Chappell*.
|
por *Glenn Chappell*.
|
||||||
|
|
|
||||||
10
build.rs
10
build.rs
|
|
@ -4,28 +4,30 @@ use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
resource_dir("./resources/assets")
|
resource_dir("./static/theme")
|
||||||
.with_generated_filename(
|
.with_generated_filename(
|
||||||
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
||||||
.join("assets.rs")
|
.join("theme.rs")
|
||||||
)
|
)
|
||||||
.with_generated_fn("assets")
|
.with_generated_fn("assets")
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
resource_dir("./src/base/theme/aliner/assets")
|
resource_dir("./static/aliner")
|
||||||
.with_generated_filename(
|
.with_generated_filename(
|
||||||
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
||||||
.join("aliner.rs")
|
.join("aliner.rs")
|
||||||
)
|
)
|
||||||
|
.with_generated_fn("assets")
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
resource_dir("./src/base/theme/bootsier/assets")
|
resource_dir("./static/bootsier")
|
||||||
.with_generated_filename(
|
.with_generated_filename(
|
||||||
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
Path::new(env::var("OUT_DIR").unwrap().as_str())
|
||||||
.join("bootsier.rs")
|
.join("bootsier.rs")
|
||||||
)
|
)
|
||||||
|
.with_generated_fn("assets")
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@ include!(concat!(env!("OUT_DIR"), "/aliner.rs"));
|
||||||
pub struct AlinerTheme;
|
pub struct AlinerTheme;
|
||||||
|
|
||||||
impl Theme for AlinerTheme {
|
impl Theme for AlinerTheme {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> String {
|
||||||
"Aliner"
|
"Aliner".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_theme(&self, cfg: &mut server::web::ServiceConfig) {
|
fn configure_theme(&self, cfg: &mut server::web::ServiceConfig) {
|
||||||
cfg.service(actix_web_static_files::ResourceFiles::new(
|
cfg.service(actix_web_static_files::ResourceFiles::new(
|
||||||
"/aliner",
|
"/aliner",
|
||||||
generate()
|
assets()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: url(/pagetop/fonts/nunito/cyrillic_ext_400.woff2) format('woff2');
|
|
||||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: url(/pagetop/fonts/nunito/cyrillic_400.woff2) format('woff2');
|
|
||||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: url(/pagetop/fonts/nunito/vietnamese_400.woff2) format('woff2');
|
|
||||||
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: url(/pagetop/fonts/nunito/latin_ext_400.woff2) format('woff2');
|
|
||||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 400;
|
|
||||||
src: url(/pagetop/fonts/nunito/latin_400.woff2) format('woff2');
|
|
||||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: url(/pagetop/fonts/nunito/cyrillic_ext_700.woff2) format('woff2');
|
|
||||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: url(/pagetop/fonts/nunito/cyrillic_700.woff2) format('woff2');
|
|
||||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: url(/pagetop/fonts/nunito/vietnamese_700.woff2) format('woff2');
|
|
||||||
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: url(/pagetop/fonts/nunito/latin_ext_700.woff2) format('woff2');
|
|
||||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Nunito';
|
|
||||||
font-style: normal;
|
|
||||||
font-weight: 700;
|
|
||||||
src: url(/pagetop/fonts/nunito/latin_700.woff2) format('woff2');
|
|
||||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -7,14 +7,14 @@ localize!("en-US", "src/base/theme/bootsier/locales");
|
||||||
pub struct BootsierTheme;
|
pub struct BootsierTheme;
|
||||||
|
|
||||||
impl Theme for BootsierTheme {
|
impl Theme for BootsierTheme {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> String {
|
||||||
"Bootsier"
|
"Bootsier".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_theme(&self, cfg: &mut server::web::ServiceConfig) {
|
fn configure_theme(&self, cfg: &mut server::web::ServiceConfig) {
|
||||||
cfg.service(actix_web_static_files::ResourceFiles::new(
|
cfg.service(actix_web_static_files::ResourceFiles::new(
|
||||||
"/bootsier",
|
"/bootsier",
|
||||||
generate()
|
assets()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,15 +26,15 @@ impl Theme for BootsierTheme {
|
||||||
)
|
)
|
||||||
.add_stylesheet(
|
.add_stylesheet(
|
||||||
StyleSheet::source(
|
StyleSheet::source(
|
||||||
"/bootsier/css/bootstrap.min.css"
|
"/bootsier/css/bootstrap.min.css?v=5.1.3"
|
||||||
)
|
)
|
||||||
.with_weight(-99)
|
.with_weight(-99)
|
||||||
)
|
)
|
||||||
.add_javascript(
|
.add_javascript(
|
||||||
JavaScript::source(
|
JavaScript::source(
|
||||||
"/bootsier/js/bootstrap.bundle.min.js"
|
"/bootsier/js/bootstrap.bundle.min.js?v=5.1.3"
|
||||||
)
|
)
|
||||||
.with_weight(-98)
|
.with_weight(-99)
|
||||||
)
|
)
|
||||||
.add_jquery();
|
.add_jquery();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
||||||
pub struct MinimalTheme;
|
pub struct MinimalTheme;
|
||||||
|
|
||||||
impl Theme for MinimalTheme {
|
impl Theme for MinimalTheme {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> String {
|
||||||
"Minimal"
|
"Minimal".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
/// Carga los ajustes globales "clave = valor" al arrancar la aplicación.
|
/// Al arrancar la aplicación, carga los valores originales "clave = valor" de
|
||||||
|
/// los archivos de configuración. Con [`config_map`] se asignarán los ajustes
|
||||||
|
/// globales ([`SETTINGS`]); y se podrán asignar los ajustes específicos de la
|
||||||
|
/// aplicación, o también de un tema, módulo o componente.
|
||||||
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
||||||
// Establece el modo de ejecución según el valor de la variable de entorno
|
// Establece el modo de ejecución según el valor de la variable de entorno
|
||||||
// PAGETOP_RUN_MODE. Asume "default" por defecto.
|
// PAGETOP_RUN_MODE. Asume "default" por defecto.
|
||||||
|
|
@ -15,8 +18,7 @@ pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
||||||
// Inicializa los ajustes.
|
// Inicializa los ajustes.
|
||||||
let mut settings = Config::default();
|
let mut settings = Config::default();
|
||||||
|
|
||||||
// Lee los ajustes combinando los archivos de configuración disponibles y
|
// Combina los archivos de configuración y asigna el modo de ejecución.
|
||||||
// asigna el modo de ejecución.
|
|
||||||
settings
|
settings
|
||||||
.merge(
|
.merge(
|
||||||
File::with_name(
|
File::with_name(
|
||||||
|
|
@ -36,23 +38,13 @@ pub static CONFIG: Lazy<Config> = Lazy::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
/// Usar esta macro para obtener el valor de cualquier ajuste global, donde
|
/// Asigna los ajustes específicos de la aplicación, o de un tema, módulo o
|
||||||
/// clave y valor son cadenas de caracteres. Devuelve la cadena vacía si no
|
/// componente, en una estructura similar a [`SETTINGS`] con tipos de variables
|
||||||
/// encuentra un ajuste para la clave.
|
/// seguros. Produce un *panic!* en caso de asignaciones no válidas.
|
||||||
macro_rules! config_get {
|
|
||||||
( $key:expr ) => {
|
|
||||||
$crate::config::CONFIG.get_str($key).unwrap_or("".to_string())
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
/// Carga los ajustes específicos de tu módulo o aplicación en una estructura
|
|
||||||
/// similar a [`SETTINGS`] con tipos de variables seguros. Genera un *panic!*
|
|
||||||
/// en caso de asignaciones no válidas.
|
|
||||||
macro_rules! config_map {
|
macro_rules! config_map {
|
||||||
( $COMMENT:expr, $CONF:ident, $TYPE:tt $(, $key:expr => $value:expr)* ) => {
|
( $COMM:expr, $CONF:ident, $TYPE:tt $(, $key:expr => $value:expr)* ) => {
|
||||||
$crate::doc_comment! {
|
$crate::doc_comment! {
|
||||||
concat!($COMMENT),
|
concat!($COMM),
|
||||||
|
|
||||||
pub static $CONF: $crate::Lazy<$TYPE> = $crate::Lazy::new(|| {
|
pub static $CONF: $crate::Lazy<$TYPE> = $crate::Lazy::new(|| {
|
||||||
let mut settings = $crate::config::CONFIG.clone();
|
let mut settings = $crate::config::CONFIG.clone();
|
||||||
|
|
@ -101,7 +93,7 @@ pub struct Settings {
|
||||||
|
|
||||||
config_map!(r#"
|
config_map!(r#"
|
||||||
Ajustes globales y valores predeterminados para las secciones *\[app\]*,
|
Ajustes globales y valores predeterminados para las secciones *\[app\]*,
|
||||||
*\[log\]* y *\[webserver\]* específicas de PageTop.
|
*\[log\]* y *\[webserver\]* de PageTop.
|
||||||
"#,
|
"#,
|
||||||
SETTINGS, Settings,
|
SETTINGS, Settings,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
use crate::core::{server, state};
|
use crate::core::{server, state};
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/theme.rs"));
|
||||||
|
|
||||||
pub fn themes(cfg: &mut server::web::ServiceConfig) {
|
pub fn themes(cfg: &mut server::web::ServiceConfig) {
|
||||||
|
cfg.service(actix_web_static_files::ResourceFiles::new(
|
||||||
|
"/theme",
|
||||||
|
assets()
|
||||||
|
));
|
||||||
|
|
||||||
for t in state::THEMES.read().unwrap().iter() {
|
for t in state::THEMES.read().unwrap().iter() {
|
||||||
t.configure_theme(cfg);
|
t.configure_theme(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ impl Assets {
|
||||||
if !self.with_jquery {
|
if !self.with_jquery {
|
||||||
self.add_javascript(
|
self.add_javascript(
|
||||||
JavaScript::source(
|
JavaScript::source(
|
||||||
"/assets/js/jquery.min.js?ver=3.6.0"
|
"/theme/js/jquery.min.js?v=3.6.0"
|
||||||
)
|
)
|
||||||
.with_weight(i8::MIN)
|
.with_weight(i8::MIN)
|
||||||
.with_mode(JSMode::Normal)
|
.with_mode(JSMode::Normal)
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,16 @@ pub fn run(bootstrap: Option<fn()>) -> Result<Server, std::io::Error> {
|
||||||
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||||
let figfont = figlet_rs::FIGfont::from_content(
|
let figfont = figlet_rs::FIGfont::from_content(
|
||||||
match SETTINGS.app.startup_banner.to_lowercase().as_str() {
|
match SETTINGS.app.startup_banner.to_lowercase().as_str() {
|
||||||
"slant" => include_str!("../../../resources/slant.flf"),
|
"slant" => include_str!("figfonts/slant.flf"),
|
||||||
"small" => include_str!("../../../resources/small.flf"),
|
"small" => include_str!("figfonts/small.flf"),
|
||||||
"speed" => include_str!("../../../resources/speed.flf"),
|
"speed" => include_str!("figfonts/speed.flf"),
|
||||||
"starwars" => include_str!("../../../resources/starwars.flf"),
|
"starwars" => include_str!("figfonts/starwars.flf"),
|
||||||
_ => {
|
_ => {
|
||||||
trace::warn!(
|
trace::warn!(
|
||||||
"FIGfont \"{}\" not found for banner. Using \"{}\"",
|
"FIGfont \"{}\" not found for banner. Using \"{}\"",
|
||||||
SETTINGS.app.startup_banner, "Small"
|
SETTINGS.app.startup_banner, "Small"
|
||||||
);
|
);
|
||||||
include_str!("../../../resources/small.flf")
|
include_str!("figfonts/small.flf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ use crate::base::component::Chunck;
|
||||||
|
|
||||||
/// Los temas deben implementar este "trait".
|
/// Los temas deben implementar este "trait".
|
||||||
pub trait Theme: Send + Sync {
|
pub trait Theme: Send + Sync {
|
||||||
fn name(&self) -> &str;
|
fn name(&self) -> String;
|
||||||
|
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> String {
|
||||||
""
|
"".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
|
@ -41,7 +41,7 @@ pub trait Theme: Send + Sync {
|
||||||
|
|
||||||
fn render_page_body(&self, page: &mut Page) -> Markup {
|
fn render_page_body(&self, page: &mut Page) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
body id="body" class=(page.body_classes()) {
|
body class=(page.body_classes()) {
|
||||||
@match page.template() {
|
@match page.template() {
|
||||||
"admin" => {
|
"admin" => {
|
||||||
@for region in &["top-menu", "side-menu", "content"] {
|
@for region in &["top-menu", "side-menu", "content"] {
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Loading…
Add table
Add a link
Reference in a new issue