✨ [minimal] Add PoweredBy component
This commit is contained in:
parent
86311e4aee
commit
5b9a53cbc6
12 changed files with 219 additions and 29 deletions
|
|
@ -1,12 +1,19 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
pub mod component;
|
||||
pub mod module;
|
||||
|
||||
create_handle!(MODULE_MINIMAL);
|
||||
|
||||
static_locales!(LOCALES_MINIMAL);
|
||||
|
||||
static_files!(minimal);
|
||||
|
||||
// Library version.
|
||||
const VERSION_MINIMAL: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
// Context parameter.
|
||||
const PARAM_MINIMAL_ASSETS: &str = "minimal.assets";
|
||||
|
||||
pub struct Minimal;
|
||||
|
||||
impl ModuleTrait for Minimal {
|
||||
|
|
@ -14,7 +21,35 @@ impl ModuleTrait for Minimal {
|
|||
MODULE_MINIMAL
|
||||
}
|
||||
|
||||
fn name(&self) -> L10n {
|
||||
L10n::t("module_name", &LOCALES_MINIMAL)
|
||||
}
|
||||
|
||||
fn description(&self) -> L10n {
|
||||
L10n::t("module_description", &LOCALES_MINIMAL)
|
||||
}
|
||||
|
||||
fn actions(&self) -> Vec<Action> {
|
||||
vec![action!(ActionAfterPrepareBody => after_prepare_body, 99)]
|
||||
}
|
||||
|
||||
fn configure_service(&self, cfg: &mut service::web::ServiceConfig) {
|
||||
serve_static_files!(cfg, "/minimal", minimal);
|
||||
}
|
||||
}
|
||||
|
||||
impl Minimal {
|
||||
pub(crate) fn load_assets(&self, cx: &mut Context) -> &Self {
|
||||
cx.set_param::<bool>(PARAM_MINIMAL_ASSETS, true);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn after_prepare_body(page: &mut Page) {
|
||||
if let Some(true) = page.context().get_param::<bool>(PARAM_MINIMAL_ASSETS) {
|
||||
page.context().alter(ContextOp::AddStyleSheet(
|
||||
StyleSheet::at("/minimal/css/minimal.css")
|
||||
.with_version(VERSION_MINIMAL)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue