♻️ Major code restructuring

This commit is contained in:
Manuel Cillero 2024-02-09 14:05:38 +01:00
parent a96e203bb3
commit fa66d628a0
221 changed files with 228 additions and 315 deletions

View file

@ -1,24 +1,97 @@
[workspace]
[package]
name = "pagetop"
version = "0.0.49"
edition = "2021"
members = [
"pagetop",
# Utilities.
"pagetop-macros",
"pagetop-build",
# Themes.
"pagetop-bootsier",
"pagetop-bulmix",
# Packages.
"pagetop-homedemo",
"pagetop-admin",
"pagetop-user",
"pagetop-node",
authors = [
"Manuel Cillero <manuel@cillero.es>"
]
description = """\
PageTop is an opinionated Rust web development framework to build secure and modular \
Server-Side Rendering (SSR) web solutions.
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "MIT OR Apache-2.0"
categories = [
"web-programming", "development-tools", "gui"
]
keywords = [
"web", "framework", "frontend", "ssr", "pagetop"
]
exclude = [
"drust",
"examples",
"tests",
"config/", "drust/", "examples/", "helpers/", "packages/", "tests/", "workdir/"
]
rust-version = "1.70.0"
resolver = "2"
[workspace]
members = ["drust", "helpers/*", "packages/*"]
[lib]
name = "pagetop"
[features]
default = []
database = ["futures", "sea-orm", "sea-schema"]
mysql = ["database", "sea-orm/sqlx-mysql"]
postgres = ["database", "sea-orm/sqlx-postgres"]
sqlite = ["database", "sea-orm/sqlx-sqlite"]
[dependencies]
async-trait = "0.1.77"
chrono = "0.4.33"
concat-string = "1.0.1"
figlet-rs = "0.1.5"
itoa = "1.0.10"
nom = "7.1.3"
once_cell = "1.19.0"
paste = "1.0.14"
smart-default = "0.7.1"
substring = "1.4.5"
term_size = "0.3.2"
toml = "0.8.10"
url = "2.5.0"
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] }
tracing-actix-web = "0.7.9"
fluent-templates = "0.8.0"
unic-langid = { version = "0.9.4", features = ["macros"] }
actix-web = "4"
actix-session = { version = "0.9.0", features = ["cookie-session"] }
actix-web-files = { package = "actix-files", version = "0.6.5" }
actix-web-static-files = "4.0.1"
static-files = "0.2.3"
pagetop-macros = { version = "0.0", path = "helpers/pagetop-macros" }
serde = { version = "1.0", features = ["derive"] }
[dependencies.futures]
version = "0.3.30"
optional = true
[dependencies.heck]
version = "0.4.1"
[dependencies.sea-orm]
version = "0.12.9"
features = ["debug-print", "macros", "runtime-async-std-native-tls"]
default-features = false
optional = true
[dependencies.sea-schema]
version = "0.14.1"
optional = true
[build-dependencies]
pagetop-build = { version = "0.0", path = "helpers/pagetop-build" }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

137
README.md
View file

@ -1,89 +1,90 @@
<div align="center">
<img src="https://raw.githubusercontent.com/manuelcillero/pagetop/main/banner-pagetop.png" />
<img src="https://raw.githubusercontent.com/manuelcillero/pagetop/main/static/banner.png" />
<h1>PageTop</h1>
[![crate](https://img.shields.io/crates/v/pagetop.svg)](https://crates.io/crates/pagetop)
[![docs](https://docs.rs/pagetop/badge.svg)](https://docs.rs/pagetop)
[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg?style=for-the-badge)](https://github.com/manuelcillero/pagetop#-license)
[![API Docs](https://img.shields.io/docsrs/pagetop?label=API%20Docs&style=for-the-badge&logo=Docs.rs)](https://docs.rs/pagetop)
[![Crates.io](https://img.shields.io/crates/v/pagetop.svg?style=for-the-badge&logo=ipfs)](https://crates.io/crates/pagetop)
[![Downloads](https://img.shields.io/crates/d/pagetop.svg?style=for-the-badge&logo=transmission)](https://crates.io/crates/pagetop)
</div>
**PageTop** es un entorno de desarrollo basado en [Rust](https://www.rust-lang.org/es/) que reúne
algunos de los crates más estables y populares para crear soluciones web modulares, extensibles y
configurables.
**PageTop** is an opinionated [Rust](https://www.rust-lang.org) web development framework to build
secure and modular Server-Side Rendering (SSR) web solutions.
Incluye **Drust**, un sistema de gestión de contenidos basado en PageTop que permite crear, editar y
mantener sitios web dinámicos, rápidos y seguros.
PageTop stands on the shoulders of giants. It leverages some of the most stable and popular Rust
crates to provide extensible and easily configurable features.
# 🚧 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**.
# 🚧 Advertencia
# 📂 Repository Structure
**PageTop** es un proyecto personal para aprender Rust y conocer su ecosistema. Sólo se liberan
versiones de desarrollo. En este contexto la API no es estable y los cambios son constantes. No
puede considerarse preparado hasta que se libere la versión **0.1.0**.
This repository is organized into a workspace that includes several subprojects, each serving a
distinct role within the PageTop ecosystem:
## Application
* **[drust](https://github.com/manuelcillero/pagetop/tree/main/drust)**, a simple Content Management
System (CMS) built on PageTop, which enables the creation, editing, and maintenance of dynamic,
fast, and secure websites. It uses the following essential packages to provide standard CMS
functionalities.
## Packages
* **[pagetop-homedemo](https://github.com/manuelcillero/pagetop/tree/main/pagetop-homedemo)**:
Showcases a demo homepage, offering a glimpse into PageTop's capabilities.
* **[pagetop-admin](https://github.com/manuelcillero/pagetop/tree/main/pagetop-admin)**: Offers a
unified interface for administrators to configure and manage package settings.
* **[pagetop-user](https://github.com/manuelcillero/pagetop/tree/main/pagetop-user)**: Facilitates
user management, including roles, permissions, and session handling, for PageTop-based
applications.
* **[pagetop-node](https://github.com/manuelcillero/pagetop/tree/main/pagetop-node)**: Enables the
creation and customization of content types, enhancing website content management.
## Themes
* **[pagetop-bootsier](https://github.com/manuelcillero/pagetop/tree/main/pagetop-bootsier)**:
Utilizes the [Bootstrap](https://getbootstrap.com/) framework to offer versatile page layouts and
component stylings.
* **[pagetop-bulmix](https://github.com/manuelcillero/pagetop/tree/main/pagetop-bulmix)**: Employs
the [Bulma](https://bulma.io/) framework for sleek, responsive design elements.
## Helpers
* **[pagetop-macros](https://github.com/manuelcillero/pagetop/tree/main/pagetop-macros)**: A
collection of procedural macros that enhance the development experience within PageTop.
* **[pagetop-build](https://github.com/manuelcillero/pagetop/tree/main/pagetop-build)**: Simplifies
the process of embedding resources directly into binary files for PageTop applications.
# 📂 Estructura del código
# 📜 License
El repositorio se organiza en un *workspace* con los siguientes subproyectos:
PageTop is free, open source and permissively licensed! Except where noted (below and/or in
individual files), all code in this repository is dual-licensed under either:
* **[pagetop](https://github.com/manuelcillero/pagetop/tree/main/pagetop)**, es la librería esencial
construida con *crates* estables y muy conocidos del ecosistema Rust para proporcionar APIs,
patrones de desarrollo y buenas prácticas para la creación avanzada de soluciones web SSR
(*Server-Side Rendering*).
* MIT License
([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
## Auxiliares
* Apache License, Version 2.0,
([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* **[pagetop-macros](https://github.com/manuelcillero/pagetop/tree/main/pagetop-macros)**, agrupa
las principales macros procedurales para usar desde **PageTop**.
* **[pagetop-build](https://github.com/manuelcillero/pagetop/tree/main/pagetop-build)**, permite
incluir fácilmente recursos en los archivos binarios al compilar aplicaciones creadas con
**PageTop**.
## Módulos
* **[pagetop-homedemo](https://github.com/manuelcillero/pagetop/tree/main/pagetop-homedemo)**,
módulo que muestra una página de inicio de demostración para presentar **PageTop**.
* **[pagetop-admin](https://github.com/manuelcillero/pagetop/tree/main/pagetop-admin)**, módulo que
proporciona a otros módulos un lugar común donde presentar a los administradores sus opciones de
configuración.
* **[pagetop-user](https://github.com/manuelcillero/pagetop/tree/main/pagetop-user)**, módulo para
añadir gestión de usuarios, roles, permisos y sesiones en aplicaciones desarrolladas con PageTop.
* **[pagetop-node](https://github.com/manuelcillero/pagetop/tree/main/pagetop-node)**, módulo para
crear, extender o personalizar los tipos de contenido que puede administrar un sitio web.
## Temas
* **[pagetop-bootsier](https://github.com/manuelcillero/pagetop/tree/main/pagetop-bootsier)**, tema
que utiliza el *framework* [Bootstrap](https://getbootstrap.com/) para la composición de páginas y
visualización de componentes.
* **[pagetop-bulmix](https://github.com/manuelcillero/pagetop/tree/main/pagetop-bulmix)**, tema que
utiliza el *framework* [Bulma](https://bulma.io/) para la composición de páginas y visualización
de componentes.
## Aplicación
* **[drust](https://github.com/manuelcillero/pagetop/tree/main/drust)**, es una aplicación
inspirada modestamente en [Drupal](https://www.drupal.org) que utiliza PageTop para crear un CMS
(*Content Management System* o sistema de gestión de contenidos) para construir sitios web
dinámicos, administrados y configurables.
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.
# 📜 Licencia
# ✨ Contributions
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]).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

View file

@ -11,15 +11,15 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop", features = ["mysql"], default-features = false }
pagetop = { version = "0.0", path = "../", features = ["mysql"], default-features = false }
# Packages.
pagetop-homedemo = { version = "0.0", path = "../packages/pagetop-homedemo" }
pagetop-admin = { version = "0.0", path = "../packages/pagetop-admin" }
pagetop-user = { version = "0.0", path = "../packages/pagetop-user" }
pagetop-node = { version = "0.0", path = "../packages/pagetop-node" }
# Themes.
pagetop-bootsier = { version = "0.0", path = "../pagetop-bootsier" }
pagetop-bulmix = { version = "0.0", path = "../pagetop-bulmix" }
# Modules.
pagetop-homedemo = { version = "0.0", path = "../pagetop-homedemo" }
pagetop-admin = { version = "0.0", path = "../pagetop-admin" }
pagetop-user = { version = "0.0", path = "../pagetop-user" }
pagetop-node = { version = "0.0", path = "../pagetop-node" }
pagetop-bootsier = { version = "0.0", path = "../packages/pagetop-bootsier" }
pagetop-bulmix = { version = "0.0", path = "../packages/pagetop-bulmix" }

View file

@ -1,4 +0,0 @@
[workspace]
members = [
"basics/*",
]

View file

@ -1,9 +0,0 @@
[package]
name = "hello_name"
version = "0.0.0"
edition = "2021"
publish = false
[dependencies]
actix-web = "4"
pagetop = { version = "0.0", path = "../../../pagetop" }

View file

@ -1,8 +0,0 @@
[package]
name = "hello_world"
version = "0.0.0"
edition = "2021"
publish = false
[dependencies]
pagetop = { version = "0.0", path = "../../../pagetop" }

View file

@ -11,7 +11,7 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
static-files = "0.2.3"

View file

@ -11,7 +11,7 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[lib]
proc-macro = true

View file

@ -12,7 +12,7 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop" }
pagetop = { version = "0.0", path = "../../" }

View file

@ -11,11 +11,11 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop" }
pagetop = { version = "0.0", path = "../../" }
static-files = "0.2.3"
[build-dependencies]
pagetop-build = { version = "0.0", path = "../pagetop-build" }
pagetop-build = { version = "0.0", path = "../../helpers/pagetop-build" }

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

@ -11,11 +11,11 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop" }
pagetop = { version = "0.0", path = "../../" }
static-files = "0.2.3"
[build-dependencies]
pagetop-build = { version = "0.0", path = "../pagetop-build" }
pagetop-build = { version = "0.0", path = "../../helpers/pagetop-build" }

View file

@ -11,11 +11,11 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop" }
pagetop = { version = "0.0", path = "../../" }
static-files = "0.2.3"
[build-dependencies]
pagetop-build = { version = "0.0", path = "../pagetop-build" }
pagetop-build = { version = "0.0", path = "../../helpers/pagetop-build" }

View file

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before After
Before After

View file

@ -12,7 +12,7 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop", features = ["database"], default-features = false }
pagetop = { version = "0.0", path = "../../", features = ["database"], default-features = false }

View file

@ -12,8 +12,8 @@ description = """\
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
license = "MIT OR Apache-2.0"
[dependencies]
pagetop = { version = "0.0", path = "../pagetop", features = ["database"], default-features = false }
pagetop = { version = "0.0", path = "../../", features = ["database"], default-features = false }
serde = { version = "1.0", features = ["derive"] }

View file

@ -1,90 +0,0 @@
[package]
name = "pagetop"
version = "0.0.48"
edition = "2021"
authors = [
"Manuel Cillero <manuel@cillero.es>"
]
description = """\
PageTop is an opinionated Rust web development framework to build secure and modular \
Server-Side Rendering (SSR) web solutions.
"""
homepage = "https://pagetop.cillero.es"
repository = "https://github.com/manuelcillero/pagetop"
license = "Apache-2.0 OR MIT"
keywords = [
"web", "cms", "framework", "frontend", "ssr"
]
categories = [
"web-programming", "development-tools", "gui"
]
[lib]
name = "pagetop"
[features]
default = []
database = ["futures", "sea-orm", "sea-schema"]
mysql = ["database", "sea-orm/sqlx-mysql"]
postgres = ["database", "sea-orm/sqlx-postgres"]
sqlite = ["database", "sea-orm/sqlx-sqlite"]
[dependencies]
async-trait = "0.1.74"
chrono = "0.4.31"
concat-string = "1.0.1"
figlet-rs = "0.1.5"
itoa = "1.0.10"
nom = "7.1.3"
once_cell = "1.19.0"
paste = "1.0.14"
smart-default = "0.7.1"
substring = "1.4.5"
term_size = "0.3.2"
toml = "0.8.8"
url = "2.5.0"
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["json", "env-filter"] }
tracing-actix-web = "0.7.9"
fluent-templates = "0.8.0"
unic-langid = { version = "0.9.3", features = ["macros"] }
actix-web = "4"
actix-session = { version = "0.8.0", features = ["cookie-session"] }
actix-web-files = { package = "actix-files", version = "0.6.2" }
actix-web-static-files = "4.0.1"
static-files = "0.2.3"
pagetop-macros = { version = "0.0", path = "../pagetop-macros" }
serde = { version = "1.0", features = ["derive"] }
[dependencies.futures]
version = "0.3.29"
optional = true
[dependencies.heck]
version = "0.4.1"
[dependencies.sea-orm]
version = "0.12.9"
features = ["debug-print", "macros", "runtime-async-std-native-tls"]
default-features = false
optional = true
[dependencies.sea-schema]
version = "0.14.1"
optional = true
[build-dependencies]
pagetop-build = { version = "0.0", path = "../pagetop-build" }
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

View file

@ -1,22 +0,0 @@
**PageTop** is an opinionated [Rust](https://www.rust-lang.org) web development framework to build
secure and modular Server-Side Rendering (SSR) web solutions.
PageTop uses some of the most stable and popular Rust *crates* to provide modular, extensible, and
configurable features.
# 🚧 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
This project is licensed under either of the following licenses, at your option:
* Apache License, Version 2.0,
([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT License
([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)

View file

@ -5,7 +5,7 @@ mod figfont;
use crate::core::{package, package::PackageRef};
use crate::html::Markup;
use crate::response::page::{ErrorPage, ResultPage};
use crate::{concat_string, config, locale, service, trace, LazyStatic};
use crate::{config, locale, service, trace, LazyStatic};
#[cfg(feature = "database")]
use crate::db;
@ -129,18 +129,14 @@ fn show_banner() {
app_name = figfont::FIGFONT.convert(&app).unwrap().to_string();
}
}
println!("\n{}", app_name);
// Application description.
let app_description = if !config::SETTINGS.app.description.is_empty() {
concat_string!("\n", config::SETTINGS.app.description)
} else {
"".to_owned()
if !config::SETTINGS.app.description.is_empty() {
println!("{}\n", config::SETTINGS.app.description);
};
// Print banner.
println!(
"\n{}{}\n\nPowered by PageTop {}\n",
app_name,
app_description,
env!("CARGO_PKG_VERSION")
);
// PageTop version.
println!("Powered by PageTop {}\n", env!("CARGO_PKG_VERSION"));
}
}

View file

@ -1,6 +1,6 @@
use crate::prelude::*;
pub type FnAction<C> = fn(component: &mut C, cx: &mut Context);
pub type FnActionComponent<C> = fn(component: &mut C, cx: &mut Context);
mod before_prepare_component;
pub use before_prepare_component::*;

View file

@ -1,11 +1,11 @@
use crate::prelude::*;
use crate::BaseHandle;
use super::FnAction;
use super::FnActionComponent;
#[derive(BaseHandle)]
pub struct AfterPrepareComponent<C: ComponentTrait> {
f: FnAction<C>,
f: FnActionComponent<C>,
referer_handle: Option<Handle>,
referer_id: OptionId,
weight: Weight,
@ -26,7 +26,7 @@ impl<C: ComponentTrait> ActionTrait for AfterPrepareComponent<C> {
}
impl<C: ComponentTrait> AfterPrepareComponent<C> {
pub fn new(f: FnAction<C>) -> Self {
pub fn new(f: FnActionComponent<C>) -> Self {
AfterPrepareComponent {
f,
referer_handle: Some(C::static_handle()),

View file

@ -1,11 +1,11 @@
use crate::prelude::*;
use crate::BaseHandle;
use super::FnAction;
use super::FnActionComponent;
#[derive(BaseHandle)]
pub struct BeforePrepareComponent<C: ComponentTrait> {
f: FnAction<C>,
f: FnActionComponent<C>,
referer_handle: Option<Handle>,
referer_id: OptionId,
weight: Weight,
@ -26,7 +26,7 @@ impl<C: ComponentTrait> ActionTrait for BeforePrepareComponent<C> {
}
impl<C: ComponentTrait> BeforePrepareComponent<C> {
pub fn new(f: FnAction<C>) -> Self {
pub fn new(f: FnActionComponent<C>) -> Self {
BeforePrepareComponent {
f,
referer_handle: Some(C::static_handle()),

Some files were not shown because too many files have changed in this diff Show more