⬆️ Update for latest SeaORM compatibility
This commit is contained in:
parent
3160a9e8dc
commit
567d0748c7
4 changed files with 41 additions and 186 deletions
|
|
@ -1,67 +0,0 @@
|
||||||
# 🔃 Dependencies
|
|
||||||
|
|
||||||
PageTop is developed in the [Rust programming language](https://www.rust-lang.org/) and stands on
|
|
||||||
the shoulders of true giants, using some of the most stable and renowned libraries (*crates*) from
|
|
||||||
the [Rust ecosystem](https://lib.rs), such as:
|
|
||||||
|
|
||||||
* [Actix Web](https://actix.rs/) for web services and server management.
|
|
||||||
* [Tracing](https://github.com/tokio-rs/tracing) for the diagnostic system and structured logging.
|
|
||||||
* [Fluent templates](https://github.com/XAMPPRocky/fluent-templates) that incorporate
|
|
||||||
[Fluent](https://projectfluent.org/) for project internationalization.
|
|
||||||
* [SeaORM](https://www.sea-ql.org/SeaORM/) which employs [SQLx](https://docs.rs/sqlx/latest/sqlx/)
|
|
||||||
for database access and modeling.
|
|
||||||
* Among others, which you can review in the PageTop
|
|
||||||
[`Cargo.toml`](https://github.com/manuelcillero/pagetop/blob/main/Cargo.toml) file.
|
|
||||||
|
|
||||||
|
|
||||||
# ⌨️ Code
|
|
||||||
|
|
||||||
PageTop integrates code from various renowned crates to enhance functionality:
|
|
||||||
|
|
||||||
* [**Config (v0.11.0)**](https://github.com/mehcode/config-rs/tree/0.11.0): Includes code from
|
|
||||||
[config-rs](https://crates.io/crates/config) by [Ryan Leckey](https://crates.io/users/mehcode),
|
|
||||||
chosen for its advantages in reading configuration settings and delegating assignment to safe
|
|
||||||
types, tailored to the specific needs of each package, theme, or application.
|
|
||||||
|
|
||||||
* [**Maud (v0.25.0)**](https://github.com/lambda-fairy/maud/tree/v0.25.0/maud): An adapted version
|
|
||||||
of the excellent [maud](https://crates.io/crates/maud) crate by
|
|
||||||
[Chris Wong](https://crates.io/users/lambda-fairy) is incorporated to leverage its functionalities without requiring a reference to `maud` in the `Cargo.toml` files.
|
|
||||||
|
|
||||||
* **SmartDefault (v0.7.1)**: Embedded [SmartDefault](https://crates.io/crates/smart_default) by
|
|
||||||
[Jane Doe](https://crates.io/users/jane-doe) as `AutoDefault`to simplify the documentation of
|
|
||||||
Default implementations and also removes the need to explicitly list `smart_default` in the
|
|
||||||
`Cargo.toml` files.
|
|
||||||
|
|
||||||
* **Database Operations**: PageTop employs [SQLx](https://github.com/launchbadge/sqlx) and
|
|
||||||
[SeaQuery](https://github.com/SeaQL/sea-query), complemented by a custom version of
|
|
||||||
[SeaORM Migration](https://github.com/SeaQL/sea-orm/tree/master/sea-orm-migration) (version
|
|
||||||
[0.12.8](https://github.com/SeaQL/sea-orm/tree/0.12.8/sea-orm-migration/src)). This modification
|
|
||||||
ensures migration processes are confined to specific packages, enhancing modularity and
|
|
||||||
maintainability.
|
|
||||||
|
|
||||||
|
|
||||||
# 🗚 FIGfonts
|
|
||||||
|
|
||||||
PageTop uses the [figlet-rs](https://crates.io/crates/figlet-rs) package by *yuanbohan* to display a
|
|
||||||
presentation banner in the terminal with the application's name using
|
|
||||||
[FIGlet](http://www.figlet.org) characters. The fonts included in `src/app` are:
|
|
||||||
|
|
||||||
* [slant.flf](http://www.figlet.org/fontdb_example.cgi?font=slant.flf) by *Glenn Chappell*
|
|
||||||
* [small.flf](http://www.figlet.org/fontdb_example.cgi?font=small.flf) by *Glenn Chappell* (default)
|
|
||||||
* [speed.flf](http://www.figlet.org/fontdb_example.cgi?font=speed.flf) by *Claude Martins*
|
|
||||||
* [starwars.flf](http://www.figlet.org/fontdb_example.cgi?font=starwars.flf) by *Ryan Youck*
|
|
||||||
|
|
||||||
|
|
||||||
# 📰 Templates
|
|
||||||
|
|
||||||
* The default welcome homepage design is based on the
|
|
||||||
[Zinc](https://themewagon.com/themes/free-bootstrap-5-html5-business-website-template-zinc)
|
|
||||||
template created by [inovatik](https://inovatik.com/) and distributed by
|
|
||||||
[ThemeWagon](https://themewagon.com).
|
|
||||||
|
|
||||||
|
|
||||||
# 🎨 Icon
|
|
||||||
|
|
||||||
"The creature" smiling is a fun creation by [Webalys](https://www.iconfinder.com/webalys). It can be
|
|
||||||
found in their [Nasty Icons](https://www.iconfinder.com/iconsets/nasty) collection available on
|
|
||||||
[ICONFINDER](https://www.iconfinder.com).
|
|
||||||
|
|
@ -1,102 +1,26 @@
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<img src="https://raw.githubusercontent.com/manuelcillero/pagetop/main/static/banner.png" />
|
<h1>PageTop SeaORM</h1>
|
||||||
|
|
||||||
<h1>PageTop</h1>
|
<p>Integrate SeaORM as the database framework for PageTop applications.</p>
|
||||||
|
|
||||||
<p>An opinionated web framework to build modular <em>Server-Side Rendering</em> web solutions.</p>
|
|
||||||
|
|
||||||
[](#-license)
|
[](#-license)
|
||||||
[](https://docs.rs/pagetop)
|
[](https://docs.rs/pagetop-seaorm)
|
||||||
[](https://crates.io/crates/pagetop)
|
[](https://crates.io/crates/pagetop-seaorm)
|
||||||
[](https://crates.io/crates/pagetop)
|
[](https://crates.io/crates/pagetop-seaorm)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Overview
|
PageTop SeaORM employs [SQLx](https://crates.io/crates/sqlx) and
|
||||||
|
[SeaQuery](https://crates.io/crates/sea-query), complemented by a custom version of
|
||||||
|
[SeaORM Migration](https://github.com/SeaQL/sea-orm/tree/1.1.1/sea-orm-migration/src) (v1.1.1). The
|
||||||
|
modified SeaORM Migration ensures migrations are scoped per package, providing greater control and
|
||||||
|
reducing coupling between database components.
|
||||||
|
|
||||||
The PageTop core API provides a comprehensive toolkit for extending its functionalities to specific
|
# 📦 About PageTop
|
||||||
requirements and application scenarios through actions, components, packages, and themes:
|
|
||||||
|
|
||||||
* **Actions** serve as a mechanism to customize PageTop's internal behavior by intercepting its
|
[PageTop](https://docs.rs/pagetop) is an opinionated web framework to build modular *Server-Side
|
||||||
execution flow.
|
Rendering* web solutions.
|
||||||
* **Components** encapsulate HTML, CSS, and JavaScript into functional, configurable, and
|
|
||||||
well-defined units.
|
|
||||||
* **Packages** extend or customize existing functionality by interacting with PageTop APIs or
|
|
||||||
third-party package APIs.
|
|
||||||
* **Themes** enable developers to alter the appearance of pages and components without affecting
|
|
||||||
their functionality.
|
|
||||||
|
|
||||||
|
|
||||||
# ⚡️ Quick start
|
|
||||||
|
|
||||||
```rust
|
|
||||||
use pagetop::prelude::*;
|
|
||||||
|
|
||||||
struct HelloWorld;
|
|
||||||
|
|
||||||
impl PackageTrait for HelloWorld {
|
|
||||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
|
||||||
scfg.route("/", service::web::get().to(hello_world));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn hello_world(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
|
|
||||||
Page::new(request)
|
|
||||||
.with_component(Html::with(html! { h1 { "Hello World!" } }))
|
|
||||||
.render()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[pagetop::main]
|
|
||||||
async fn main() -> std::io::Result<()> {
|
|
||||||
Application::prepare(&HelloWorld).run()?.await
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This program features a `HelloWorld` package, providing a service that serves a greeting web page
|
|
||||||
accessible via `http://localhost:8088` under default settings.
|
|
||||||
|
|
||||||
|
|
||||||
# 📂 Repository Structure
|
|
||||||
|
|
||||||
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/latest/drust):
|
|
||||||
A simple Content Management System (CMS) built on PageTop, which enables the creation, editing,
|
|
||||||
and maintenance of dynamic, fast, and modular websites. It uses the following essential packages
|
|
||||||
to provide standard CMS functionalities.
|
|
||||||
|
|
||||||
## Helpers
|
|
||||||
|
|
||||||
* [pagetop-macros](https://github.com/manuelcillero/pagetop/tree/latest/helpers/pagetop-macros):
|
|
||||||
A collection of procedural macros that enhance the development experience within PageTop.
|
|
||||||
|
|
||||||
* [pagetop-build](https://github.com/manuelcillero/pagetop/tree/latest/helpers/pagetop-build):
|
|
||||||
Simplifies the process of embedding resources directly into binary files for PageTop applications.
|
|
||||||
|
|
||||||
## Packages
|
|
||||||
|
|
||||||
* [pagetop-user](https://github.com/manuelcillero/pagetop/tree/latest/packages/pagetop-user):
|
|
||||||
Facilitates user management, including roles, permissions, and session handling, for applications
|
|
||||||
built on PageTop.
|
|
||||||
|
|
||||||
* [pagetop-admin](https://github.com/manuelcillero/pagetop/tree/latest/packages/pagetop-admin):
|
|
||||||
Provides a unified interface for administrators to configure and manage package settings.
|
|
||||||
|
|
||||||
* [pagetop-node](https://github.com/manuelcillero/pagetop/tree/latest/packages/pagetop-node):
|
|
||||||
Enables the creation and customization of content types, enhancing website content management.
|
|
||||||
|
|
||||||
## Themes
|
|
||||||
|
|
||||||
* [pagetop-bootsier](https://github.com/manuelcillero/pagetop/tree/latest/packages/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/latest/packages/pagetop-bulmix):
|
|
||||||
Utilizes the *[Bulma](https://bulma.io/)* framework for sleek, responsive design elements.
|
|
||||||
|
|
||||||
|
|
||||||
# 🚧 Warning
|
# 🚧 Warning
|
||||||
|
|
@ -107,8 +31,7 @@ frequent changes. Production use is not recommended until version **0.1.0**.
|
||||||
|
|
||||||
# 📜 License
|
# 📜 License
|
||||||
|
|
||||||
PageTop is free, open source and permissively licensed! Except where noted (below and/or in
|
All code in this crate is dual-licensed under either:
|
||||||
individual files), all code in this project is dual-licensed under either:
|
|
||||||
|
|
||||||
* MIT License
|
* MIT License
|
||||||
([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
|
||||||
|
|
@ -118,10 +41,3 @@ individual files), all code in this project is dual-licensed under either:
|
||||||
|
|
||||||
at your option. This means you can select the license you prefer! This dual-licensing approach is
|
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.
|
the de-facto standard in the Rust ecosystem.
|
||||||
|
|
||||||
|
|
||||||
# ✨ Contributions
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
//! Configuration settings for SeaORM PageTop package.
|
//! Configuration settings for the SeaORM PageTop package.
|
||||||
//!
|
//!
|
||||||
//! Example:
|
//! Example:
|
||||||
//!
|
//!
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(config::SETTINGS.database.db_host, "localhost");
|
//! assert_eq!(config::SETTINGS.database.db_host, "localhost");
|
||||||
//! ```
|
//! ```
|
||||||
//! See [`pagetop::config`](pagetop::config) to learn how **PageTop** read configuration files and
|
//! See [`pagetop::include_config`] to learn how **PageTop** read configuration files and use
|
||||||
//! use settings.
|
//! settings.
|
||||||
|
|
||||||
use pagetop::prelude::*;
|
use pagetop::prelude::*;
|
||||||
|
|
||||||
|
|
@ -39,32 +39,33 @@ include_config!(SETTINGS: Settings => [
|
||||||
]);
|
]);
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
/// Type for HighlightJS configuration settings, section [`[hljs]`](Hljs) (used by [`SETTINGS`]).
|
/// Represents configuration settings, specifically the [`[database]`](Database) section (used by
|
||||||
|
/// [`SETTINGS`]).
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub database: Database,
|
pub database: Database,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
/// Struct for section `[database]` of [`Settings`] type.
|
/// Represents the `[database]` section in the [`Settings`] type.
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
/// Tipo de base de datos: *"mysql"*, *"postgres"* ó *"sqlite"*.
|
/// Type of database: *"mysql"*, *"postgres"*, or *"sqlite"*.
|
||||||
/// Por defecto: *""*.
|
/// Default: *""*.
|
||||||
pub db_type: String,
|
pub db_type: String,
|
||||||
/// Nombre (para mysql/postgres) o referencia (para sqlite) de la base de datos.
|
/// Name (for MySQL/Postgres) or reference (for SQLite) of the database.
|
||||||
/// Por defecto: *""*.
|
/// Default: *""*.
|
||||||
pub db_name: String,
|
pub db_name: String,
|
||||||
/// Usuario de conexión a la base de datos (para mysql/postgres).
|
/// Username for database connection (for MySQL/Postgres).
|
||||||
/// Por defecto: *""*.
|
/// Default: *""*.
|
||||||
pub db_user: String,
|
pub db_user: String,
|
||||||
/// Contraseña para la conexión a la base de datos (para mysql/postgres).
|
/// Password for database connection (for MySQL/Postgres).
|
||||||
/// Por defecto: *""*.
|
/// Default: *""*.
|
||||||
pub db_pass: String,
|
pub db_pass: String,
|
||||||
/// Servidor de conexión a la base de datos (para mysql/postgres).
|
/// Hostname for database connection (for MySQL/Postgres).
|
||||||
/// Por defecto: *"localhost"*.
|
/// Default: *"localhost"*.
|
||||||
pub db_host: String,
|
pub db_host: String,
|
||||||
/// Puerto de conexión a la base de datos, normalmente 3306 (para mysql) ó 5432 (para postgres).
|
/// Port number for database connection, typically 3306 (MySQL) or 5432 (Postgres).
|
||||||
/// Por defecto: *0*.
|
/// Default: *0*.
|
||||||
pub db_port: u16,
|
pub db_port: u16,
|
||||||
/// Número máximo de conexiones habilitadas.
|
/// Maximum number of allowed connections.
|
||||||
/// Por defecto: *5*.
|
/// Default: *5*.
|
||||||
pub max_pool_size: u32,
|
pub max_pool_size: u32,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ pub fn pk_auto<T: IntoIden>(name: T) -> ColumnDef {
|
||||||
integer(name).auto_increment().primary_key().take()
|
integer(name).auto_increment().primary_key().take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a UUID primary key
|
||||||
|
pub fn pk_uuid<T: IntoIden>(name: T) -> ColumnDef {
|
||||||
|
uuid(name).primary_key().take()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn char_len<T: IntoIden>(col: T, length: u32) -> ColumnDef {
|
pub fn char_len<T: IntoIden>(col: T, length: u32) -> ColumnDef {
|
||||||
ColumnDef::new(col).char_len(length).not_null().take()
|
ColumnDef::new(col).char_len(length).not_null().take()
|
||||||
}
|
}
|
||||||
|
|
@ -538,11 +543,11 @@ pub fn uuid_uniq<T: IntoIden>(col: T) -> ColumnDef {
|
||||||
uuid(col).unique_key().take()
|
uuid(col).unique_key().take()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn custom<T: IntoIden>(col: T, name: T) -> ColumnDef {
|
pub fn custom<T: IntoIden, N: IntoIden>(col: T, name: N) -> ColumnDef {
|
||||||
ColumnDef::new(col).custom(name).not_null().take()
|
ColumnDef::new(col).custom(name).not_null().take()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn custom_null<T: IntoIden>(col: T, name: T) -> ColumnDef {
|
pub fn custom_null<T: IntoIden, N: IntoIden>(col: T, name: N) -> ColumnDef {
|
||||||
ColumnDef::new(col).custom(name).null().take()
|
ColumnDef::new(col).custom(name).null().take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue