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