♻️ Refactor config initialization by name and type
This commit is contained in:
parent
3ff00ac38f
commit
b599e2f7d4
18 changed files with 193 additions and 192 deletions
|
|
@ -3,11 +3,11 @@ use crate::concat_string;
|
|||
use crate::core::component::AnyOp;
|
||||
use crate::core::theme::all::{theme_by_short_name, THEME_DEFAULT};
|
||||
use crate::core::theme::{ComponentsInRegions, ThemeRef};
|
||||
use crate::global::TypeInfo;
|
||||
use crate::html::{html, Markup};
|
||||
use crate::html::{Assets, Favicon, JavaScript, StyleSheet};
|
||||
use crate::locale::{LanguageIdentifier, LANGID_DEFAULT};
|
||||
use crate::service::HttpRequest;
|
||||
use crate::util::TypeInfo;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::base::action;
|
||||
use crate::core::component::Context;
|
||||
use crate::core::AnyBase;
|
||||
use crate::global::TypeInfo;
|
||||
use crate::html::{html, Markup, PrepareMarkup};
|
||||
use crate::util::TypeInfo;
|
||||
|
||||
pub trait ComponentBase {
|
||||
fn render(&mut self, cx: &mut Context) -> Markup;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::core::action::add_action;
|
||||
use crate::core::package::PackageRef;
|
||||
use crate::core::theme::all::THEMES;
|
||||
use crate::{config, service, service_for_static_files, static_files, trace};
|
||||
use crate::{global, service, static_files, static_files_service, trace};
|
||||
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
|
|
@ -130,10 +130,10 @@ pub fn init_packages() {
|
|||
// CONFIGURE SERVICES ******************************************************************************
|
||||
|
||||
pub fn configure_services(scfg: &mut service::web::ServiceConfig) {
|
||||
service_for_static_files!(
|
||||
static_files_service!(
|
||||
scfg,
|
||||
base => "/base",
|
||||
[&config::SETTINGS.dev.pagetop_project_dir, "static/base"]
|
||||
[&global::SETTINGS.dev.pagetop_project_dir, "static/base"]
|
||||
);
|
||||
for m in ENABLED_PACKAGES.read().unwrap().iter() {
|
||||
m.configure_service(scfg);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::config;
|
||||
use crate::core::theme::ThemeRef;
|
||||
use crate::global;
|
||||
|
||||
use std::sync::{LazyLock, RwLock};
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ pub static THEMES: LazyLock<RwLock<Vec<ThemeRef>>> = LazyLock::new(|| RwLock::ne
|
|||
// DEFAULT THEME ***********************************************************************************
|
||||
|
||||
pub static THEME_DEFAULT: LazyLock<ThemeRef> =
|
||||
LazyLock::new(|| match theme_by_short_name(&config::SETTINGS.app.theme) {
|
||||
LazyLock::new(|| match theme_by_short_name(&global::SETTINGS.app.theme) {
|
||||
Some(theme) => theme,
|
||||
None => &crate::base::theme::Inception,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::core::package::PackageTrait;
|
|||
use crate::html::{html, Favicon, PrepareMarkup};
|
||||
use crate::locale::L10n;
|
||||
use crate::response::page::Page;
|
||||
use crate::{concat_string, config};
|
||||
use crate::{concat_string, global};
|
||||
|
||||
pub type ThemeRef = &'static dyn ThemeTrait;
|
||||
|
||||
|
|
@ -82,9 +82,9 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
|||
meta charset="utf-8";
|
||||
|
||||
@if let Some(title) = page.title() {
|
||||
title { (config::SETTINGS.app.name) (" - ") (title) }
|
||||
title { (global::SETTINGS.app.name) (" - ") (title) }
|
||||
} @else {
|
||||
title { (config::SETTINGS.app.name) }
|
||||
title { (global::SETTINGS.app.name) }
|
||||
}
|
||||
|
||||
@if let Some(description) = page.description() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue