Expand description
The PageTop core API provides a comprehensive toolkit for extending its functionalities to specific requirements and application scenarios through actions, components, packages, and themes:
- Actions serve as a mechanism to customize PageTop’s internal behavior by intercepting its execution flow.
- 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
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 implements a package named HelloWorld
with one service that returns a web page
that greets the world whenever it is accessed from the browser at http://localhost:8088
(using
the default configuration settings). You can find this code in the PageTop
examples repository.
§🧩 Dependency Management
Projects leveraging PageTop will use cargo
to resolve dependencies, similar to any other Rust
project.
Nevertheless, it’s crucial that each package explicitly declares its dependencies, if any, to assist PageTop in structuring and initializing the application in a modular fashion.
§🚧 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.
Modules§
- Prepare and run an application created with Pagetop.
- Base actions, components, packages, and themes.
- Retrieve and apply settings values from configuration files.
- Key types and functions for creating actions, components, packages, and themes.
- db
database
Database access. - HTML in code.
- Localization (L10n).
- The PageTop Prelude.
- Web request response variants.
- Essential web framework (actix-web).
- Application tracing and event logging.
- Functions and macro helpers.
Macros§
- Concatenates a series of string slices into an owned string.
- Define un conjunto de ajustes de configuración usando tipos seguros y valores predefinidos.
- Macro para construir grupos de pares clave-valor.
- migrations
database
- Enables flexible identifier concatenation in macros, allowing new items with pasted identifiers.
- Defines a set of localization elements and local translation texts.
Structs§
- A value which is initialized on the first access.
- Static files resource.
- A
TypeId
represents a globally unique identifier for a type.
Type Aliases§
Attribute Macros§
- Marks async main function as the PageTop entry-point.
- Marks async test functions to use the PageTop entry-point.