♻️ Major code restructuring
This commit is contained in:
parent
a96e203bb3
commit
fa66d628a0
221 changed files with 228 additions and 315 deletions
21
packages/pagetop-bootsier/Cargo.toml
Normal file
21
packages/pagetop-bootsier/Cargo.toml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[package]
|
||||
name = "pagetop-bootsier"
|
||||
version = "0.0.13"
|
||||
edition = "2021"
|
||||
|
||||
authors = [
|
||||
"Manuel Cillero <manuel@cillero.es>"
|
||||
]
|
||||
description = """\
|
||||
Theme for PageTop that uses the Bootstrap framework for page layout and components display.\
|
||||
"""
|
||||
homepage = "https://pagetop.cillero.es"
|
||||
repository = "https://github.com/manuelcillero/pagetop"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
pagetop = { version = "0.0", path = "../../" }
|
||||
static-files = "0.2.3"
|
||||
|
||||
[build-dependencies]
|
||||
pagetop-build = { version = "0.0", path = "../../helpers/pagetop-build" }
|
||||
27
packages/pagetop-bootsier/README.md
Normal file
27
packages/pagetop-bootsier/README.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
Tema para **PageTop** que utiliza el *framework* [Bootstrap](https://getbootstrap.com/) para la
|
||||
composición de páginas y visualización de componentes.
|
||||
|
||||
[PageTop](https://github.com/manuelcillero/pagetop/tree/main/pagetop), es un entorno de desarrollo
|
||||
basado en algunos de los *crates* más estables y populares del ecosistema Rust para proporcionar
|
||||
APIs, patrones de desarrollo y buenas prácticas para la creación de soluciones web SSR (*Server-Side
|
||||
Rendering*).
|
||||
|
||||
|
||||
# 🚧 Advertencia
|
||||
|
||||
**PageTop** sólo libera actualmente versiones de desarrollo. La API no es estable y los cambios son
|
||||
constantes. No puede considerarse preparado hasta que se libere la versión **0.1.0**.
|
||||
|
||||
|
||||
# 📜 Licencia
|
||||
|
||||
Este proyecto tiene licencia, de hecho tiene dos, puedes aplicar cualquiera de las siguientes a tu
|
||||
elección:
|
||||
|
||||
* Licencia Apache versión 2.0
|
||||
([LICENSE-APACHE](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-APACHE) o
|
||||
[http://www.apache.org/licenses/LICENSE-2.0]).
|
||||
|
||||
* Licencia MIT
|
||||
([LICENSE-MIT](https://github.com/manuelcillero/pagetop/blob/main/LICENSE-MIT) o
|
||||
[http://opensource.org/licenses/MIT]).
|
||||
7
packages/pagetop-bootsier/build.rs
Normal file
7
packages/pagetop-bootsier/build.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use pagetop_build::StaticFilesBundle;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
StaticFilesBundle::from_dir("./static")
|
||||
.with_name("bootsier")
|
||||
.build()
|
||||
}
|
||||
239
packages/pagetop-bootsier/src/lib.rs
Normal file
239
packages/pagetop-bootsier/src/lib.rs
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
static_locales!(LOCALES_BOOTSIER);
|
||||
|
||||
static_files!(bootsier);
|
||||
|
||||
#[derive(AssignHandle)]
|
||||
pub struct Bootsier;
|
||||
|
||||
impl PackageTrait for Bootsier {
|
||||
fn theme(&self) -> Option<ThemeRef> {
|
||||
Some(&Bootsier)
|
||||
}
|
||||
|
||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||
service_for_static_files!(scfg, bootsier => "/bootsier");
|
||||
}
|
||||
}
|
||||
|
||||
impl ThemeTrait for Bootsier {
|
||||
#[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) -> Markup {
|
||||
match page.template() {
|
||||
"admin" => html! {
|
||||
body class=[page.body_classes().get()] {
|
||||
@for region in &[
|
||||
"top-menu",
|
||||
"side-menu",
|
||||
"content"
|
||||
] {
|
||||
(self.prepare_region(page, region))
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => html! {
|
||||
body class=[page.body_classes().get()] {
|
||||
(self.prepare_region(page, "header"))
|
||||
(self.prepare_region(page, "nav_branding"))
|
||||
(self.prepare_region(page, "nav_main"))
|
||||
(self.prepare_region(page, "nav_additional"))
|
||||
(self.prepare_region(page, "breadcrumb"))
|
||||
(self.prepare_region(page, "content"))
|
||||
(self.prepare_region(page, "sidebar_first"))
|
||||
(self.prepare_region(page, "sidebar_second"))
|
||||
(self.prepare_region(page, "footer"))
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn after_prepare_body(&self, page: &mut Page) {
|
||||
page.alter_favicon(Some(Favicon::new().with_icon("/base/favicon.ico")))
|
||||
.alter_context(ContextOp::AddStyleSheet(
|
||||
StyleSheet::at("/bootsier/css/bootstrap.min.css")
|
||||
.with_version("5.1.3")
|
||||
.with_weight(-99),
|
||||
))
|
||||
.alter_context(ContextOp::AddJavaScript(
|
||||
JavaScript::at("/bootsier/js/bootstrap.bundle.min.js")
|
||||
.with_version("5.1.3")
|
||||
.with_weight(-99),
|
||||
))
|
||||
.alter_context(ContextOp::AddBaseAssets)
|
||||
.alter_context(ContextOp::AddStyleSheet(
|
||||
StyleSheet::at("/bootsier/css/styles.css").with_version("0.0.1"),
|
||||
));
|
||||
}
|
||||
|
||||
fn before_prepare_component(&self, component: &mut dyn ComponentTrait, _cx: &mut Context) {
|
||||
match component.handle() {
|
||||
h if Icon::matches_handle(h) => {
|
||||
if let Some(i) = component_as_mut::<Icon>(component) {
|
||||
match i.font_size() {
|
||||
FontSize::ExtraLarge => {
|
||||
i.replace_classes(i.font_size().to_string(), "fs-1");
|
||||
}
|
||||
FontSize::XxLarge => {
|
||||
i.replace_classes(i.font_size().to_string(), "fs-2");
|
||||
}
|
||||
FontSize::XLarge => {
|
||||
i.replace_classes(i.font_size().to_string(), "fs-3");
|
||||
}
|
||||
FontSize::Large => {
|
||||
i.replace_classes(i.font_size().to_string(), "fs-4");
|
||||
}
|
||||
FontSize::Medium => {
|
||||
i.replace_classes(i.font_size().to_string(), "fs-5");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
h if Button::matches_handle(h) => {
|
||||
if let Some(b) = component_as_mut::<Button>(component) {
|
||||
match b.style() {
|
||||
ButtonStyle::Default => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-primary");
|
||||
}
|
||||
ButtonStyle::Info => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-info");
|
||||
}
|
||||
ButtonStyle::Success => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-success");
|
||||
}
|
||||
ButtonStyle::Warning => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-warning");
|
||||
}
|
||||
ButtonStyle::Danger => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-danger");
|
||||
}
|
||||
ButtonStyle::Light => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-light");
|
||||
}
|
||||
ButtonStyle::Dark => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-dark");
|
||||
}
|
||||
ButtonStyle::Link => {
|
||||
b.replace_classes(b.style().to_string(), "btn btn-link");
|
||||
}
|
||||
};
|
||||
match b.font_size() {
|
||||
FontSize::ExtraLarge => {
|
||||
b.replace_classes(b.font_size().to_string(), "fs-1");
|
||||
}
|
||||
FontSize::XxLarge => {
|
||||
b.replace_classes(b.font_size().to_string(), "fs-2");
|
||||
}
|
||||
FontSize::XLarge => {
|
||||
b.replace_classes(b.font_size().to_string(), "fs-3");
|
||||
}
|
||||
FontSize::Large => {
|
||||
b.replace_classes(b.font_size().to_string(), "fs-4");
|
||||
}
|
||||
FontSize::Medium => {
|
||||
b.replace_classes(b.font_size().to_string(), "fs-5");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
h if Heading::matches_handle(h) => {
|
||||
if let Some(h) = component_as_mut::<Heading>(component) {
|
||||
match h.size() {
|
||||
HeadingSize::ExtraLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-1");
|
||||
}
|
||||
HeadingSize::XxLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-2");
|
||||
}
|
||||
HeadingSize::XLarge => {
|
||||
h.replace_classes(h.size().to_string(), "display-3");
|
||||
}
|
||||
HeadingSize::Large => {
|
||||
h.replace_classes(h.size().to_string(), "display-4");
|
||||
}
|
||||
HeadingSize::Medium => {
|
||||
h.replace_classes(h.size().to_string(), "display-5");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
h if Paragraph::matches_handle(h) => {
|
||||
if let Some(p) = component_as_mut::<Paragraph>(component) {
|
||||
match p.font_size() {
|
||||
FontSize::ExtraLarge => {
|
||||
p.replace_classes(p.font_size().to_string(), "fs-1");
|
||||
}
|
||||
FontSize::XxLarge => {
|
||||
p.replace_classes(p.font_size().to_string(), "fs-2");
|
||||
}
|
||||
FontSize::XLarge => {
|
||||
p.replace_classes(p.font_size().to_string(), "fs-3");
|
||||
}
|
||||
FontSize::Large => {
|
||||
p.replace_classes(p.font_size().to_string(), "fs-4");
|
||||
}
|
||||
FontSize::Medium => {
|
||||
p.replace_classes(p.font_size().to_string(), "fs-5");
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_component(&self, component: &dyn ComponentTrait, cx: &mut Context) -> Option<Markup> {
|
||||
match component.handle() {
|
||||
h if Error404::matches_handle(h) => 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()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
6
packages/pagetop-bootsier/src/locale/en-US/bootsier.ftl
Normal file
6
packages/pagetop-bootsier/src/locale/en-US/bootsier.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-bootsier/src/locale/en-US/regions.ftl
Normal file
9
packages/pagetop-bootsier/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-bootsier/src/locale/es-ES/bootsier.ftl
Normal file
5
packages/pagetop-bootsier/src/locale/es-ES/bootsier.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-bootsier/src/locale/es-ES/regions.ftl
Normal file
9
packages/pagetop-bootsier/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
|
||||
7
packages/pagetop-bootsier/static/css/bootstrap.min.css
vendored
Normal file
7
packages/pagetop-bootsier/static/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
13
packages/pagetop-bootsier/static/css/styles.css
Normal file
13
packages/pagetop-bootsier/static/css/styles.css
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* OVERRIDE COMPONENT STYLES */
|
||||
|
||||
/* Heading component */
|
||||
|
||||
.pt-heading__subtitle {
|
||||
margin-top: calc(-1 * var(--pt-gap-0-35));
|
||||
}
|
||||
|
||||
/* Button component */
|
||||
|
||||
.btn-link {
|
||||
text-decoration: none;
|
||||
}
|
||||
BIN
packages/pagetop-bootsier/static/images/caution.png
Normal file
BIN
packages/pagetop-bootsier/static/images/caution.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
7
packages/pagetop-bootsier/static/js/bootstrap.bundle.min.js
vendored
Normal file
7
packages/pagetop-bootsier/static/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue