🚚 Rename operations with assets in context
This commit is contained in:
parent
db40ac3321
commit
3d26459843
12 changed files with 67 additions and 56 deletions
|
|
@ -151,7 +151,6 @@ pub async fn summary(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
||||||
.add_item(menu::Item::label(L10n::n("Opción 4")));
|
.add_item(menu::Item::label(L10n::n("Opción 4")));
|
||||||
|
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
//.with_context(ContextOp::Theme("Bootsier"))
|
|
||||||
.with_title(L10n::n("Admin"))
|
.with_title(L10n::n("Admin"))
|
||||||
.with_template("admin")
|
.with_template("admin")
|
||||||
.with_component_in("top-menu", side_menu)
|
.with_component_in("top-menu", side_menu)
|
||||||
|
|
|
||||||
|
|
@ -70,18 +70,18 @@ impl ThemeTrait for Bootsier {
|
||||||
|
|
||||||
fn after_prepare_body(&self, page: &mut Page) {
|
fn after_prepare_body(&self, page: &mut Page) {
|
||||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/bootsier/css/bootstrap.min.css")
|
StyleSheet::at("/bootsier/css/bootstrap.min.css")
|
||||||
.with_version("5.1.3")
|
.with_version("5.1.3")
|
||||||
.with_weight(-99),
|
.with_weight(-99),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddJavaScript(
|
.alter_assets(AssetsOp::AddJavaScript(
|
||||||
JavaScript::at("/bootsier/js/bootstrap.bundle.min.js")
|
JavaScript::at("/bootsier/js/bootstrap.bundle.min.js")
|
||||||
.with_version("5.1.3")
|
.with_version("5.1.3")
|
||||||
.with_weight(-99),
|
.with_weight(-99),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddBaseAssets)
|
.alter_assets(AssetsOp::AddBaseAssets)
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/bootsier/css/styles.css").with_version("0.0.1"),
|
StyleSheet::at("/bootsier/css/styles.css").with_version("0.0.1"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@ impl ThemeTrait for Bulmix {
|
||||||
|
|
||||||
fn after_prepare_body(&self, page: &mut Page) {
|
fn after_prepare_body(&self, page: &mut Page) {
|
||||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/bulmix/css/bulma.min.css")
|
StyleSheet::at("/bulmix/css/bulma.min.css")
|
||||||
.with_version("0.9.4")
|
.with_version("0.9.4")
|
||||||
.with_weight(-99),
|
.with_weight(-99),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddBaseAssets)
|
.alter_assets(AssetsOp::AddBaseAssets)
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/bulmix/css/styles.css").with_version("0.0.1"),
|
StyleSheet::at("/bulmix/css/styles.css").with_version("0.0.1"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::core::component::{Context, ContextOp};
|
use crate::core::component::{AssetsOp, Context};
|
||||||
use crate::html::{JavaScript, StyleSheet};
|
use crate::html::{JavaScript, StyleSheet};
|
||||||
use crate::{AutoDefault, Weight};
|
use crate::{AutoDefault, Weight};
|
||||||
|
|
||||||
|
|
@ -11,23 +11,24 @@ pub const PARAM_BASE_INCLUDE_MENU_ASSETS: &str = "base.include.menu";
|
||||||
pub(crate) fn add_base_assets(cx: &mut Context) {
|
pub(crate) fn add_base_assets(cx: &mut Context) {
|
||||||
let weight = cx.get_param::<Weight>(PARAM_BASE_WEIGHT).unwrap_or(-90);
|
let weight = cx.get_param::<Weight>(PARAM_BASE_WEIGHT).unwrap_or(-90);
|
||||||
|
|
||||||
cx.alter(ContextOp::AddStyleSheet(
|
cx.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/root.css")
|
StyleSheet::at("/base/css/root.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
)).alter(ContextOp::AddStyleSheet(
|
))
|
||||||
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/looks.css")
|
StyleSheet::at("/base/css/looks.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
))
|
))
|
||||||
.alter(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/buttons.css")
|
StyleSheet::at("/base/css/buttons.css")
|
||||||
.with_version("0.0.2")
|
.with_version("0.0.2")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
));
|
));
|
||||||
|
|
||||||
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_ICONS) {
|
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_ICONS) {
|
||||||
cx.alter(ContextOp::AddStyleSheet(
|
cx.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/icons.min.css")
|
StyleSheet::at("/base/css/icons.min.css")
|
||||||
.with_version("1.11.1")
|
.with_version("1.11.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
|
|
@ -35,7 +36,7 @@ pub(crate) fn add_base_assets(cx: &mut Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_FLEX_ASSETS) {
|
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_FLEX_ASSETS) {
|
||||||
cx.alter(ContextOp::AddStyleSheet(
|
cx.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/flex.css")
|
StyleSheet::at("/base/css/flex.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
|
|
@ -43,12 +44,12 @@ pub(crate) fn add_base_assets(cx: &mut Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_MENU_ASSETS) {
|
if let Some(true) = cx.get_param::<bool>(PARAM_BASE_INCLUDE_MENU_ASSETS) {
|
||||||
cx.alter(ContextOp::AddStyleSheet(
|
cx.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/menu.css")
|
StyleSheet::at("/base/css/menu.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
))
|
))
|
||||||
.alter(ContextOp::AddJavaScript(
|
.alter_assets(AssetsOp::AddJavaScript(
|
||||||
JavaScript::at("/base/js/menu.js")
|
JavaScript::at("/base/js/menu.js")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(weight),
|
.with_weight(weight),
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ async fn home_lang(
|
||||||
fn home(request: HttpRequest, lang: &'static LanguageIdentifier) -> ResultPage<Markup, ErrorPage> {
|
fn home(request: HttpRequest, lang: &'static LanguageIdentifier) -> ResultPage<Markup, ErrorPage> {
|
||||||
Page::new(request)
|
Page::new(request)
|
||||||
.with_title(L10n::l("welcome_title"))
|
.with_title(L10n::l("welcome_title"))
|
||||||
.with_context(ContextOp::LangId(lang))
|
.with_assets(AssetsOp::LangId(lang))
|
||||||
.with_context(ContextOp::AddStyleSheet(StyleSheet::at(
|
.with_assets(AssetsOp::AddStyleSheet(StyleSheet::at(
|
||||||
"/base/css/welcome.css",
|
"/base/css/welcome.css",
|
||||||
)))
|
)))
|
||||||
.with_body_id("welcome")
|
.with_body_id("welcome")
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ impl PackageTrait for Basic {
|
||||||
impl ThemeTrait for Basic {
|
impl ThemeTrait for Basic {
|
||||||
fn after_prepare_body(&self, page: &mut Page) {
|
fn after_prepare_body(&self, page: &mut Page) {
|
||||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/normalize.min.css")
|
StyleSheet::at("/base/css/normalize.min.css")
|
||||||
.with_version("8.0.1")
|
.with_version("8.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddBaseAssets)
|
.alter_assets(AssetsOp::AddBaseAssets)
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/basic.css")
|
StyleSheet::at("/base/css/basic.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ impl PackageTrait for Chassis {
|
||||||
impl ThemeTrait for Chassis {
|
impl ThemeTrait for Chassis {
|
||||||
fn after_prepare_body(&self, page: &mut Page) {
|
fn after_prepare_body(&self, page: &mut Page) {
|
||||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/normalize.min.css")
|
StyleSheet::at("/base/css/normalize.min.css")
|
||||||
.with_version("8.0.1")
|
.with_version("8.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddBaseAssets)
|
.alter_assets(AssetsOp::AddBaseAssets)
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/chassis.css")
|
StyleSheet::at("/base/css/chassis.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ impl PackageTrait for Inception {
|
||||||
impl ThemeTrait for Inception {
|
impl ThemeTrait for Inception {
|
||||||
fn after_prepare_body(&self, page: &mut Page) {
|
fn after_prepare_body(&self, page: &mut Page) {
|
||||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/normalize.min.css")
|
StyleSheet::at("/base/css/normalize.min.css")
|
||||||
.with_version("8.0.1")
|
.with_version("8.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
))
|
))
|
||||||
.alter_context(ContextOp::AddBaseAssets)
|
.alter_assets(AssetsOp::AddBaseAssets)
|
||||||
.alter_context(ContextOp::AddStyleSheet(
|
.alter_assets(AssetsOp::AddStyleSheet(
|
||||||
StyleSheet::at("/base/css/inception.css")
|
StyleSheet::at("/base/css/inception.css")
|
||||||
.with_version("0.0.1")
|
.with_version("0.0.1")
|
||||||
.with_weight(-90),
|
.with_weight(-90),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
mod context;
|
mod context;
|
||||||
pub use context::{Context, ContextOp};
|
pub use context::{AssetsOp, Context};
|
||||||
pub type FnContextualPath = fn(cx: &Context) -> &str;
|
pub type FnContextualPath = fn(cx: &Context) -> &str;
|
||||||
|
|
||||||
mod renderable;
|
mod renderable;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::base::component::add_base_assets;
|
use crate::base::component::add_base_assets;
|
||||||
|
use crate::core::component::MixedOp;
|
||||||
use crate::core::theme::all::{theme_by_single_name, THEME_DEFAULT};
|
use crate::core::theme::all::{theme_by_single_name, THEME_DEFAULT};
|
||||||
use crate::core::theme::ThemeRef;
|
use crate::core::theme::{ComponentsInRegions, ThemeRef};
|
||||||
use crate::html::{html, Assets, HeadScript, HeadStyles, JavaScript, Markup, StyleSheet};
|
use crate::html::{html, Assets, HeadScript, HeadStyles, JavaScript, Markup, StyleSheet};
|
||||||
use crate::locale::{LanguageIdentifier, LANGID_DEFAULT};
|
use crate::locale::{LanguageIdentifier, LANGID_DEFAULT};
|
||||||
use crate::service::HttpRequest;
|
use crate::service::HttpRequest;
|
||||||
|
|
@ -9,7 +10,7 @@ use crate::{concat_string, util};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
pub enum ContextOp {
|
pub enum AssetsOp {
|
||||||
LangId(&'static LanguageIdentifier),
|
LangId(&'static LanguageIdentifier),
|
||||||
Theme(&'static str),
|
Theme(&'static str),
|
||||||
// Stylesheets.
|
// Stylesheets.
|
||||||
|
|
@ -37,6 +38,7 @@ pub struct Context {
|
||||||
headstyles: Assets<HeadStyles>, // Styles in head.
|
headstyles: Assets<HeadStyles>, // Styles in head.
|
||||||
javascript: Assets<JavaScript>, // JavaScripts.
|
javascript: Assets<JavaScript>, // JavaScripts.
|
||||||
headscript: Assets<HeadScript>, // Scripts in head.
|
headscript: Assets<HeadScript>, // Scripts in head.
|
||||||
|
regions : ComponentsInRegions,
|
||||||
params : HashMap<&'static str, String>,
|
params : HashMap<&'static str, String>,
|
||||||
id_counter: usize,
|
id_counter: usize,
|
||||||
}
|
}
|
||||||
|
|
@ -52,40 +54,46 @@ impl Context {
|
||||||
headstyles: Assets::<HeadStyles>::new(), // Styles in head.
|
headstyles: Assets::<HeadStyles>::new(), // Styles in head.
|
||||||
javascript: Assets::<JavaScript>::new(), // JavaScripts.
|
javascript: Assets::<JavaScript>::new(), // JavaScripts.
|
||||||
headscript: Assets::<HeadScript>::new(), // Scripts in head.
|
headscript: Assets::<HeadScript>::new(), // Scripts in head.
|
||||||
|
regions : ComponentsInRegions::default(),
|
||||||
params : HashMap::<&str, String>::new(),
|
params : HashMap::<&str, String>::new(),
|
||||||
id_counter: 0,
|
id_counter: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub fn alter(&mut self, op: ContextOp) -> &mut Self {
|
pub fn alter_assets(&mut self, op: AssetsOp) -> &mut Self {
|
||||||
match op {
|
match op {
|
||||||
ContextOp::LangId(langid) => {
|
AssetsOp::LangId(langid) => {
|
||||||
self.langid = langid;
|
self.langid = langid;
|
||||||
}
|
}
|
||||||
ContextOp::Theme(theme_name) => {
|
AssetsOp::Theme(theme_name) => {
|
||||||
self.theme = theme_by_single_name(theme_name).unwrap_or(*THEME_DEFAULT);
|
self.theme = theme_by_single_name(theme_name).unwrap_or(*THEME_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stylesheets.
|
// Stylesheets.
|
||||||
ContextOp::AddStyleSheet(css) => { self.stylesheet.add(css); }
|
AssetsOp::AddStyleSheet(css) => { self.stylesheet.add(css); }
|
||||||
ContextOp::RemoveStyleSheet(path) => { self.stylesheet.remove(path); }
|
AssetsOp::RemoveStyleSheet(path) => { self.stylesheet.remove(path); }
|
||||||
// Styles in head.
|
// Styles in head.
|
||||||
ContextOp::AddHeadStyles(styles) => { self.headstyles.add(styles); }
|
AssetsOp::AddHeadStyles(styles) => { self.headstyles.add(styles); }
|
||||||
ContextOp::RemoveHeadStyles(path) => { self.headstyles.remove(path); }
|
AssetsOp::RemoveHeadStyles(path) => { self.headstyles.remove(path); }
|
||||||
// JavaScripts.
|
// JavaScripts.
|
||||||
ContextOp::AddJavaScript(js) => { self.javascript.add(js); }
|
AssetsOp::AddJavaScript(js) => { self.javascript.add(js); }
|
||||||
ContextOp::RemoveJavaScript(path) => { self.javascript.remove(path); }
|
AssetsOp::RemoveJavaScript(path) => { self.javascript.remove(path); }
|
||||||
// Scripts in head.
|
// Scripts in head.
|
||||||
ContextOp::AddHeadScript(script) => { self.headscript.add(script); }
|
AssetsOp::AddHeadScript(script) => { self.headscript.add(script); }
|
||||||
ContextOp::RemoveHeadScript(path) => { self.headscript.remove(path); }
|
AssetsOp::RemoveHeadScript(path) => { self.headscript.remove(path); }
|
||||||
|
|
||||||
// Add assets to properly use base components.
|
// Add assets to properly use base components.
|
||||||
ContextOp::AddBaseAssets => { add_base_assets(self); }
|
AssetsOp::AddBaseAssets => { add_base_assets(self); }
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn alter_regions(&mut self, region: &'static str, op: MixedOp) -> &mut Self {
|
||||||
|
self.regions.alter_components(region, op);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_param<T: FromStr + ToString>(&mut self, key: &'static str, value: T) -> &mut Self {
|
pub fn set_param<T: FromStr + ToString>(&mut self, key: &'static str, value: T) -> &mut Self {
|
||||||
self.params.insert(key, value.to_string());
|
self.params.insert(key, value.to_string());
|
||||||
self
|
self
|
||||||
|
|
@ -110,6 +118,10 @@ impl Context {
|
||||||
self.theme
|
self.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn regions(&self) -> &ComponentsInRegions {
|
||||||
|
&self.regions
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_param<T: FromStr + ToString>(&mut self, key: &'static str) -> Option<T> {
|
pub fn get_param<T: FromStr + ToString>(&mut self, key: &'static str) -> Option<T> {
|
||||||
if let Some(value) = self.params.get(key) {
|
if let Some(value) = self.params.get(key) {
|
||||||
if let Ok(value) = T::from_str(value) {
|
if let Ok(value) = T::from_str(value) {
|
||||||
|
|
@ -121,7 +133,7 @@ impl Context {
|
||||||
|
|
||||||
/// Context PREPARE.
|
/// Context PREPARE.
|
||||||
|
|
||||||
pub fn prepare(&mut self) -> Markup {
|
pub fn prepare_assets(&mut self) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
(self.stylesheet.prepare()) // Stylesheets.
|
(self.stylesheet.prepare()) // Stylesheets.
|
||||||
(self.headstyles.prepare()) // Styles in head.
|
(self.headstyles.prepare()) // Styles in head.
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ pub trait ThemeTrait: PackageTrait + Send + Sync {
|
||||||
(favicon.prepare())
|
(favicon.prepare())
|
||||||
}
|
}
|
||||||
|
|
||||||
(page.context().prepare())
|
(page.context().prepare_assets())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ pub use actix_web::Result as ResultPage;
|
||||||
|
|
||||||
use crate::base::action;
|
use crate::base::action;
|
||||||
use crate::core::component::{AnyComponent, ComponentTrait, MixedComponents, MixedOp};
|
use crate::core::component::{AnyComponent, ComponentTrait, MixedComponents, MixedOp};
|
||||||
use crate::core::component::{Context, ContextOp};
|
use crate::core::component::{AssetsOp, Context};
|
||||||
use crate::core::theme::ComponentsInRegions;
|
|
||||||
use crate::fn_builder;
|
use crate::fn_builder;
|
||||||
use crate::html::{html, Markup, DOCTYPE};
|
use crate::html::{html, Markup, DOCTYPE};
|
||||||
use crate::html::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
use crate::html::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
||||||
|
|
@ -27,7 +26,6 @@ pub struct Page {
|
||||||
body_classes: OptionClasses,
|
body_classes: OptionClasses,
|
||||||
skip_to : OptionId,
|
skip_to : OptionId,
|
||||||
template : String,
|
template : String,
|
||||||
regions : ComponentsInRegions,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
|
|
@ -43,7 +41,6 @@ impl Page {
|
||||||
body_id : OptionId::default(),
|
body_id : OptionId::default(),
|
||||||
body_classes: OptionClasses::default(),
|
body_classes: OptionClasses::default(),
|
||||||
skip_to : OptionId::default(),
|
skip_to : OptionId::default(),
|
||||||
regions : ComponentsInRegions::default(),
|
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,8 +78,8 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_context(&mut self, op: ContextOp) -> &mut Self {
|
pub fn alter_assets(&mut self, op: AssetsOp) -> &mut Self {
|
||||||
self.context.alter(op);
|
self.context.alter_assets(op);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,13 +109,13 @@ impl Page {
|
||||||
|
|
||||||
#[fn_builder]
|
#[fn_builder]
|
||||||
pub fn alter_regions(&mut self, region: &'static str, op: MixedOp) -> &mut Self {
|
pub fn alter_regions(&mut self, region: &'static str, op: MixedOp) -> &mut Self {
|
||||||
self.regions.alter_components(region, op);
|
self.context.alter_regions(region, op);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
|
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
|
||||||
self.regions
|
self.context
|
||||||
.alter_components("content", MixedOp::Add(AnyComponent::with(component)));
|
.alter_regions("content", MixedOp::Add(AnyComponent::with(component)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,8 +124,8 @@ impl Page {
|
||||||
region: &'static str,
|
region: &'static str,
|
||||||
component: impl ComponentTrait,
|
component: impl ComponentTrait,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.regions
|
self.context
|
||||||
.alter_components(region, MixedOp::Add(AnyComponent::with(component)));
|
.alter_regions(region, MixedOp::Add(AnyComponent::with(component)));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +172,9 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn components_in(&self, region: &str) -> MixedComponents {
|
pub fn components_in(&self, region: &str) -> MixedComponents {
|
||||||
self.regions.all_components(self.context.theme(), region)
|
self.context
|
||||||
|
.regions()
|
||||||
|
.all_components(self.context.theme(), region)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page RENDER.
|
// Page RENDER.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue