💄 Prepare themes and set default for Drust
This commit is contained in:
parent
cafa1d53a2
commit
046d5605e9
132 changed files with 16514 additions and 170 deletions
22
packages/pagetop-aliner/Cargo.toml
Normal file
22
packages/pagetop-aliner/Cargo.toml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[package]
|
||||
name = "pagetop-aliner"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
description = """\
|
||||
PageTop default theme.\
|
||||
"""
|
||||
categories = ["web-programming", "gui"]
|
||||
keywords = ["pagetop", "theme", "css", "js"]
|
||||
|
||||
homepage = { workspace = true }
|
||||
repository = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
pagetop = { workspace = true }
|
||||
static-files = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
pagetop-build = { workspace = true }
|
||||
37
packages/pagetop-aliner/README.md
Normal file
37
packages/pagetop-aliner/README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<div align="center">
|
||||
|
||||
<h1>PageTop Bootsier</h1>
|
||||
|
||||
<p>PageTop theme that uses Bootstrap framework for versatile styles and components.</p>
|
||||
|
||||
[](#-license)
|
||||
[](https://docs.rs/pagetop-bootsier)
|
||||
[](https://crates.io/crates/pagetop-bootsier)
|
||||
[](https://crates.io/crates/pagetop-bootsier)
|
||||
|
||||
</div>
|
||||
|
||||
# 📦 About PageTop
|
||||
|
||||
[PageTop](https://docs.rs/pagetop) is an opinionated web framework to build modular *Server-Side
|
||||
Rendering* web solutions.
|
||||
|
||||
|
||||
# 🚧 Warning
|
||||
|
||||
**PageTop** framework is currently in active development. The API is unstable and subject to
|
||||
frequent changes. Production use is not recommended until version **0.1.0**.
|
||||
|
||||
|
||||
# 📜 License
|
||||
|
||||
All code in this crate is dual-licensed under either:
|
||||
|
||||
* MIT License
|
||||
([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
||||
|
||||
* Apache License, Version 2.0,
|
||||
([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
at your option. This means you can select the license you prefer! This dual-licensing approach is
|
||||
the de-facto standard in the Rust ecosystem.
|
||||
19
packages/pagetop-aliner/_build.rs
Normal file
19
packages/pagetop-aliner/_build.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use pagetop_build::StaticFilesBundle;
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
StaticFilesBundle::from_scss("./static/bootstrap-5.3.3/bootstrap.scss", "bootstrap.css")
|
||||
.with_name("bootsier")
|
||||
.build()?;
|
||||
StaticFilesBundle::from_dir("./static/js", Some(bootstrap_js_files))
|
||||
.with_name("bootsier-js")
|
||||
.build()
|
||||
}
|
||||
|
||||
fn bootstrap_js_files(path: &Path) -> bool {
|
||||
// No filtering during development, only on "release" compilation.
|
||||
env::var("PROFILE").unwrap_or_else(|_| "release".to_string()) != "release"
|
||||
|| path.file_name().map_or(false, |n| n == "bootstrap.min.js")
|
||||
}
|
||||
193
packages/pagetop-aliner/src/lib.rs
Normal file
193
packages/pagetop-aliner/src/lib.rs
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
static_locales!(LOCALES_ALINER);
|
||||
|
||||
//static_files!(bootsier);
|
||||
|
||||
pub struct Aliner;
|
||||
|
||||
impl PackageTrait for Aliner {
|
||||
fn theme(&self) -> Option<ThemeRef> {
|
||||
Some(&Aliner)
|
||||
}
|
||||
/*
|
||||
fn actions(&self) -> Vec<ActionBox> {
|
||||
actions![
|
||||
action::theme::BeforePrepare::<Icon>::new(&Self, before_prepare_icon),
|
||||
action::theme::BeforePrepare::<Button>::new(&Self, before_prepare_button),
|
||||
action::theme::BeforePrepare::<Heading>::new(&Self, before_prepare_heading),
|
||||
action::theme::BeforePrepare::<Paragraph>::new(&Self, before_prepare_paragraph),
|
||||
action::theme::RenderComponent::<Error404>::new(&Self, render_error404),
|
||||
]
|
||||
}
|
||||
|
||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||
static_files_service!(scfg, bootsier => "/bootsier");
|
||||
} */
|
||||
}
|
||||
|
||||
impl ThemeTrait for Aliner { /*
|
||||
#[rustfmt::skip]
|
||||
fn regions(&self) -> Vec<(&'static str, L10n)> {
|
||||
vec![
|
||||
("header", L10n::t("header", &LOCALES_BOOTSIER)),
|
||||
("nav_branding", L10n::t("nav_branding", &LOCALES_BOOTSIER)),
|
||||
("nav_main", L10n::t("nav_main", &LOCALES_BOOTSIER)),
|
||||
("nav_additional", L10n::t("nav_additional", &LOCALES_BOOTSIER)),
|
||||
("breadcrumb", L10n::t("breadcrumb", &LOCALES_BOOTSIER)),
|
||||
("content", L10n::t("breadcrumb", &LOCALES_BOOTSIER)),
|
||||
("sidebar_first", L10n::t("sidebar_first", &LOCALES_BOOTSIER)),
|
||||
("sidebar_second", L10n::t("sidebar_second", &LOCALES_BOOTSIER)),
|
||||
("footer", L10n::t("footer", &LOCALES_BOOTSIER)),
|
||||
]
|
||||
}
|
||||
|
||||
fn prepare_body(&self, page: &mut Page) -> PrepareMarkup {
|
||||
let skip_to_id = page.body_skip_to().get().unwrap_or("content".to_owned());
|
||||
|
||||
PrepareMarkup::With(html! {
|
||||
body id=[page.body_id().get()] class=[page.body_classes().get()] {
|
||||
@if let Some(skip) = L10n::l("skip_to_content").using(page.context().langid()) {
|
||||
div class="skip__to_content" {
|
||||
a href=(concat_string!("#", skip_to_id)) { (skip) }
|
||||
}
|
||||
}
|
||||
(match page.context().layout() {
|
||||
"admin" => flex::Container::new()
|
||||
.add_item(flex::Item::region().with_id("top-menu"))
|
||||
.add_item(flex::Item::region().with_id("side-menu"))
|
||||
.add_item(flex::Item::region().with_id("content")),
|
||||
_ => flex::Container::new()
|
||||
.add_item(flex::Item::region().with_id("header"))
|
||||
.add_item(flex::Item::region().with_id("nav_branding"))
|
||||
.add_item(flex::Item::region().with_id("nav_main"))
|
||||
.add_item(flex::Item::region().with_id("nav_additional"))
|
||||
.add_item(flex::Item::region().with_id("breadcrumb"))
|
||||
.add_item(flex::Item::region().with_id("content"))
|
||||
.add_item(flex::Item::region().with_id("sidebar_first"))
|
||||
.add_item(flex::Item::region().with_id("sidebar_second"))
|
||||
.add_item(flex::Item::region().with_id("footer")),
|
||||
}.render(page.context()))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn after_prepare_body(&self, page: &mut Page) {
|
||||
page.set_assets(AssetsOp::SetFaviconIfNone(
|
||||
Favicon::new().with_icon("/base/favicon.ico"),
|
||||
))
|
||||
.set_assets(AssetsOp::AddStyleSheet(
|
||||
StyleSheet::from("/bootsier/css/bootstrap.min.css")
|
||||
.with_version("5.1.3")
|
||||
.with_weight(-99),
|
||||
))
|
||||
.set_assets(AssetsOp::AddJavaScript(
|
||||
JavaScript::defer("/bootsier/js/bootstrap.bundle.min.js")
|
||||
.with_version("5.1.3")
|
||||
.with_weight(-99),
|
||||
))
|
||||
.set_assets(AssetsOp::AddBaseAssets)
|
||||
.set_assets(AssetsOp::AddStyleSheet(
|
||||
StyleSheet::from("/bootsier/css/styles.css").with_version("0.0.1"),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn before_prepare_icon(i: &mut Icon, _cx: &mut Context) {
|
||||
i.set_classes(
|
||||
ClassesOp::Replace(i.font_size().to_string()),
|
||||
with_font(i.font_size()),
|
||||
);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn before_prepare_button(b: &mut Button, _cx: &mut Context) {
|
||||
b.set_classes(ClassesOp::Replace("button__tap".to_owned()), "btn");
|
||||
b.set_classes(
|
||||
ClassesOp::Replace(b.style().to_string()),
|
||||
match b.style() {
|
||||
StyleBase::Default => "btn-primary",
|
||||
StyleBase::Info => "btn-info",
|
||||
StyleBase::Success => "btn-success",
|
||||
StyleBase::Warning => "btn-warning",
|
||||
StyleBase::Danger => "btn-danger",
|
||||
StyleBase::Light => "btn-light",
|
||||
StyleBase::Dark => "btn-dark",
|
||||
StyleBase::Link => "btn-link",
|
||||
},
|
||||
);
|
||||
b.set_classes(
|
||||
ClassesOp::Replace(b.font_size().to_string()),
|
||||
with_font(b.font_size()),
|
||||
);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn before_prepare_heading(h: &mut Heading, _cx: &mut Context) {
|
||||
h.set_classes(
|
||||
ClassesOp::Replace(h.size().to_string()),
|
||||
match h.size() {
|
||||
HeadingSize::ExtraLarge => "display-1",
|
||||
HeadingSize::XxLarge => "display-2",
|
||||
HeadingSize::XLarge => "display-3",
|
||||
HeadingSize::Large => "display-4",
|
||||
HeadingSize::Medium => "display-5",
|
||||
_ => "",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn before_prepare_paragraph(p: &mut Paragraph, _cx: &mut Context) {
|
||||
p.set_classes(
|
||||
ClassesOp::Replace(p.font_size().to_string()),
|
||||
with_font(p.font_size()),
|
||||
);
|
||||
}
|
||||
|
||||
fn render_error404(_: &Error404, cx: &mut Context) -> Option<Markup> {
|
||||
Some(html! {
|
||||
div class="jumbotron" {
|
||||
div class="media" {
|
||||
img
|
||||
src="/bootsier/images/caution.png"
|
||||
class="mr-4"
|
||||
style="width: 20%; max-width: 188px"
|
||||
alt="Caution!";
|
||||
div class="media-body" {
|
||||
h1 class="display-4" { ("RESOURCE NOT FOUND") }
|
||||
p class="lead" {
|
||||
(L10n::t("e404-description", &LOCALES_BOOTSIER)
|
||||
.escaped(cx.langid()))
|
||||
}
|
||||
hr class="my-4";
|
||||
p {
|
||||
(L10n::t("e404-description", &LOCALES_BOOTSIER)
|
||||
.escaped(cx.langid()))
|
||||
}
|
||||
a
|
||||
class="btn btn-primary btn-lg"
|
||||
href="/"
|
||||
role="button"
|
||||
{
|
||||
(L10n::t("back-homepage", &LOCALES_BOOTSIER)
|
||||
.escaped(cx.langid()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
*/
|
||||
}
|
||||
/*
|
||||
#[rustfmt::skip]
|
||||
fn with_font(font_size: &FontSize) -> String {
|
||||
String::from(match font_size {
|
||||
FontSize::ExtraLarge => "fs-1",
|
||||
FontSize::XxLarge => "fs-2",
|
||||
FontSize::XLarge => "fs-3",
|
||||
FontSize::Large => "fs-4",
|
||||
FontSize::Medium => "fs-5",
|
||||
_ => "",
|
||||
})
|
||||
}
|
||||
*/
|
||||
6
packages/pagetop-aliner/src/locale/en-US/inception.ftl
Normal file
6
packages/pagetop-aliner/src/locale/en-US/inception.ftl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
e404-description = Oops! Page Not Found
|
||||
e404-message = The page you are looking for may have been removed, had its name changed, or is temporarily unavailable.
|
||||
e500-description = Oops! Unexpected Error
|
||||
e500-message = We're having an issue. Please report this error to an administrator.
|
||||
back-homepage = Back to homepage
|
||||
|
||||
9
packages/pagetop-aliner/src/locale/en-US/regions.ftl
Normal file
9
packages/pagetop-aliner/src/locale/en-US/regions.ftl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
header = Header
|
||||
nav_branding = Navigation branding region
|
||||
nav_main = Main navigation region
|
||||
nav_additional = Additional navigation region (eg search form, social icons, etc)
|
||||
breadcrumb = Breadcrumb
|
||||
content = Main content
|
||||
sidebar_first = Sidebar first
|
||||
sidebar_second = Sidebar second
|
||||
footer = Footer
|
||||
5
packages/pagetop-aliner/src/locale/es-ES/inception.ftl
Normal file
5
packages/pagetop-aliner/src/locale/es-ES/inception.ftl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
e404-description = ¡Vaya! Página No Encontrada
|
||||
e404-message = La página que está buscando puede haber sido eliminada, cambiada de nombre o no está disponible temporalmente.
|
||||
e500-description = ¡Vaya! Error Inesperado
|
||||
e500-message = Está ocurriendo una incidencia. Por favor, informe de este error a un administrador.
|
||||
back-homepage = Volver al inicio
|
||||
9
packages/pagetop-aliner/src/locale/es-ES/regions.ftl
Normal file
9
packages/pagetop-aliner/src/locale/es-ES/regions.ftl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
header = Cabecera
|
||||
nav_branding = Navegación y marca
|
||||
nav_main = Navegación principal
|
||||
nav_additional = Navegación adicional (p.e. formulario de búsqueda, iconos sociales, etc.)
|
||||
breadcrumb = Ruta de posicionamiento
|
||||
content = Contenido principal
|
||||
sidebar_first = Barra lateral primera
|
||||
sidebar_second = Barra lateral segunda
|
||||
footer = Pie
|
||||
Loading…
Add table
Add a link
Reference in a new issue