Expand description
Extension point for custom admin pages.
Authors building on top of rustango-cms register a unit-struct
handler via crate::register_admin_page! and it appears as a
sidebar entry under its declared SidebarSection. All registered
handlers route through a single dispatcher mounted at
/cms-admin/x/{slug}; no per-page router scaffolding to maintain.
Custom pages inherit the bundled admin chrome — they extend
rcms_admin/_base.html and get the
sidebar, topbar, action-bar slot, flash banners, theme tokens,
and every class from cms.css for free.
§Example
ⓘ
use axum::response::Response;
use async_trait::async_trait;
use rustango_cms::admin::admin_page::{AdminPageCtx, AdminPageHandler, SidebarSection};
#[derive(Default)]
pub struct ReportsDashboard;
#[async_trait]
impl AdminPageHandler for ReportsDashboard {
fn slug(&self) -> &'static str { "reports" } // → /cms-admin/x/reports
fn label(&self) -> &'static str { "Reports" }
fn icon(&self) -> Option<&'static str> { Some("insights") }
fn section(&self) -> SidebarSection { SidebarSection::Site }
async fn render(&self, ctx: AdminPageCtx<'_>) -> Response {
// Build a Tera context, render `reports.html` (host-registered),
// return the response.
todo!()
}
}
rustango_cms::register_admin_page!(ReportsDashboard);Structs§
- Admin
Form - A posted
application/x-www-form-urlencodedbody, in field order. Repeated names (checkbox lists, multi-selects) keep every value. - Admin
Page Ctx - Request-scoped context handed to every custom admin page. References rather than owns so the handler doesn’t have to clone the Tera instance / per-tenant pool.
- Admin
Page Handler Registration - Registration entry submitted via
inventory::submit!by theregister_admin_page!macro. MirrorsPageTypeHandlerRegistration.
Enums§
- Message
Level - Message severity, in five levels.
- Sidebar
Section - Where the custom page’s sidebar entry lands. Built-ins:
Content,Site,Settings. UseCustom(&'static str)to spin up a new section heading on demand (e.g.Custom("Tools")).
Traits§
- Admin
Page Handler - Trait every custom admin page implements. Compiled-in via the
inventoryregistry — seecrate::register_admin_page!.
Functions§
- find_
admin_ page - Find a registered handler by
slug. ReturnsNonefor unknown slugs — the dispatch route maps that to a 404. - registered_
admin_ pages - Iterator over every registered handler. Used by the sidebar
enumeration in
add_chrome()and by the route dispatcher. - required_
codename - The codename a request to admin page
slugneeds, orNonewhen the page declares noAdminPageHandler::permission_resource(or no page has that slug: the dispatcher answers 404).