🚚 Rename static_files to include_files
This commit is contained in:
parent
4a4dd26cf5
commit
ddd27fd2a6
4 changed files with 19 additions and 15 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::core::action::add_action;
|
use crate::core::action::add_action;
|
||||||
use crate::core::package::PackageRef;
|
use crate::core::package::PackageRef;
|
||||||
use crate::core::theme::all::THEMES;
|
use crate::core::theme::all::THEMES;
|
||||||
use crate::{global, service, static_files, static_files_service, trace};
|
use crate::{global, include_files, include_files_service, service, trace};
|
||||||
|
|
||||||
use std::sync::{LazyLock, RwLock};
|
use std::sync::{LazyLock, RwLock};
|
||||||
|
|
||||||
static_files!(assets);
|
include_files!(assets);
|
||||||
|
|
||||||
// PACKAGES ****************************************************************************************
|
// PACKAGES ****************************************************************************************
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ pub fn configure_services(scfg: &mut service::web::ServiceConfig) {
|
||||||
for m in ENABLED_PACKAGES.read().unwrap().iter() {
|
for m in ENABLED_PACKAGES.read().unwrap().iter() {
|
||||||
m.configure_service(scfg);
|
m.configure_service(scfg);
|
||||||
}
|
}
|
||||||
static_files_service!(
|
include_files_service!(
|
||||||
scfg,
|
scfg,
|
||||||
assets => "/",
|
assets => "/",
|
||||||
[&global::SETTINGS.dev.pagetop_project_dir, "static/assets"]
|
[&global::SETTINGS.dev.pagetop_project_dir, "static/assets"]
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,14 @@ pub use opt_component::OptionComponent;
|
||||||
|
|
||||||
pub mod unit;
|
pub mod unit;
|
||||||
|
|
||||||
|
use crate::AutoDefault;
|
||||||
|
|
||||||
|
#[derive(AutoDefault)]
|
||||||
pub enum PrepareMarkup {
|
pub enum PrepareMarkup {
|
||||||
|
#[default]
|
||||||
None,
|
None,
|
||||||
Text(&'static str),
|
Text(&'static str),
|
||||||
|
Escaped(String),
|
||||||
With(Markup),
|
With(Markup),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,6 +45,7 @@ impl PrepareMarkup {
|
||||||
match self {
|
match self {
|
||||||
PrepareMarkup::None => html! {},
|
PrepareMarkup::None => html! {},
|
||||||
PrepareMarkup::Text(text) => html! { (text) },
|
PrepareMarkup::Text(text) => html! { (text) },
|
||||||
|
PrepareMarkup::Escaped(string) => html! { (PreEscaped(string)) },
|
||||||
PrepareMarkup::With(markup) => html! { (markup) },
|
PrepareMarkup::With(markup) => html! { (markup) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,21 @@
|
||||||
//! The `PageTop` Prelude.
|
//! The `PageTop` Prelude.
|
||||||
|
|
||||||
// RE-EXPORTED MACROS AND DERIVES.
|
// RE-EXPORTED.
|
||||||
pub use crate::{concat_string, fn_builder, main, paste, test};
|
|
||||||
pub use crate::{AutoDefault, ComponentClasses};
|
|
||||||
|
|
||||||
// GLOBAL.
|
pub use crate::{concat_string, fn_builder, html, main, paste, test};
|
||||||
pub use crate::{HashMapResources, TypeId, Weight};
|
|
||||||
|
pub use crate::{AutoDefault, ComponentClasses, HashMapResources, TypeId, Weight};
|
||||||
|
|
||||||
// MACROS.
|
// MACROS.
|
||||||
|
|
||||||
// crate::global
|
// crate::util
|
||||||
pub use crate::kv;
|
pub use crate::kv;
|
||||||
// crate::config
|
// crate::config
|
||||||
pub use crate::include_config;
|
pub use crate::include_config;
|
||||||
// crate::html
|
|
||||||
pub use crate::html;
|
|
||||||
// crate::locale
|
// crate::locale
|
||||||
pub use crate::include_locales;
|
pub use crate::include_locales;
|
||||||
// crate::service
|
// crate::service
|
||||||
pub use crate::{static_files, static_files_service};
|
pub use crate::{include_files, include_files_service};
|
||||||
// crate::core::action
|
// crate::core::action
|
||||||
pub use crate::actions;
|
pub use crate::actions;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ pub use actix_web_files::Files as ActixFiles;
|
||||||
pub use actix_web_static_files::ResourceFiles;
|
pub use actix_web_static_files::ResourceFiles;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! static_files {
|
macro_rules! include_files {
|
||||||
( $bundle:ident ) => {
|
( $bundle:ident ) => {
|
||||||
$crate::paste! {
|
$crate::paste! {
|
||||||
mod [<static_files_ $bundle>] {
|
mod [<static_files_ $bundle>] {
|
||||||
|
|
@ -26,7 +26,7 @@ macro_rules! static_files {
|
||||||
mod [<static_files_ $bundle>] {
|
mod [<static_files_ $bundle>] {
|
||||||
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
|
include!(concat!(env!("OUT_DIR"), "/", stringify!($bundle), ".rs"));
|
||||||
}
|
}
|
||||||
static $STATIC: std::sync::LazyLock<HashMapResources> = std::sync::LazyLock::new(
|
static $STATIC: std::sync::LazyLock<StaticResources> = std::sync::LazyLock::new(
|
||||||
[<static_files_ $bundle>]::$bundle
|
[<static_files_ $bundle>]::$bundle
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -34,11 +34,12 @@ macro_rules! static_files {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! static_files_service {
|
macro_rules! include_files_service {
|
||||||
( $scfg:ident, $bundle:ident => $path:expr $(, [$root:expr, $relative:expr])? ) => {{
|
( $scfg:ident, $bundle:ident => $path:expr $(, [$root:expr, $relative:expr])? ) => {{
|
||||||
$crate::paste! {
|
$crate::paste! {
|
||||||
let span = $crate::trace::debug_span!("Configuring static files ", path = $path);
|
let span = $crate::trace::debug_span!("Configuring static files ", path = $path);
|
||||||
let _ = span.in_scope(|| {
|
let _ = span.in_scope(|| {
|
||||||
|
#[allow(unused_mut)]
|
||||||
let mut serve_embedded:bool = true;
|
let mut serve_embedded:bool = true;
|
||||||
$(
|
$(
|
||||||
if !$root.is_empty() && !$relative.is_empty() {
|
if !$root.is_empty() && !$relative.is_empty() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue