Expand description
Library — reusable content (renamed from “snippets”).
Library items are non-page records that pages reference by id —
authors, FAQ entries, hero banners, callout blocks, etc. The
pattern mirrors register_page_type!: each type implements
LibraryTypeHandler, registers via the
crate::register_library_type! macro, gets a row in
cms_library_type, and exposes its own extension table for the
actual content.
ⓘ
#[derive(Default)]
pub struct AuthorEntry;
#[async_trait::async_trait]
impl rustango_cms::library::LibraryTypeHandler for AuthorEntry {
fn app_label(&self) -> &'static str { "blog" }
fn type_name(&self) -> &'static str { "Author" }
fn verbose_name(&self) -> &'static str { "Author" }
fn extension_table(&self) -> Option<&'static str> { Some("blog_author") }
}
rustango_cms::register_library_type!(AuthorEntry);Structs§
- Bulk
Action - One bulk action exposed above the list table — pair the
multi-select checkbox column with a labeled button. Submits
as POST
/cms-admin/library/{type}/bulkwithaction=<name>&ids=<id>&ids=<id>...; the handler routes the selection toLibraryTypeHandler::handle_bulk_action. - Library
Type - Registry row keyed on
type_name. Seeded on boot from the inventory ofregister_library_type!-registered handlers, mirroringPageType. - Library
Type Handler Registration - Handler-registration entry submitted via
inventory::submit!. Thefactoryreconstructs the handler at runtime; mirrorsPageTypeHandlerRegistration. - Menu
Picker Entry - One row contributed by
LibraryTypeHandler::menu_picker_entriesto the WP-style menu builder’s Library tab. Each entry renders as a draggable picker card; dropping one into the tree creates a MenuItem withexternal_url = urlandlabelinherited.
Enums§
- Bulk
Action Style - Visual emphasis for a bulk action button. Maps to the
.btn/.btn-outlined/.btn-dangerCSS variants. - List
Column - One column shown in the snippet list view for a given type.
A column can be a
scalar field on
cms_snippet, adata.<key>JSON lookup, a method-field rendered by the handler, or a computed value derived at render time. - List
Column Kind - How a scalar value should render in the list.
- Order
Dir - Sort direction for
LibraryTypeHandler::default_ordering.
Traits§
- Library
Type Handler - Trait every library type implements. Mirrors
crate::PageTypeHandler— same registration story, same per-tenant seeding pass.
Functions§
- ensure_
library_ type_ row - Seed
cms_library_typerows for every registered handler across every active org. Wire into the sameCli::seedcallback the page-type seeder uses. - find_
handler - Locate a handler by
type_name. ReturnsNonefor unknown types — useful for the admin’s lookup-then-route flow. - registered_
handlers - Walk every
register_library_type!-registered handler. Used by the seeder + admin to enumerate types at runtime.