Skip to main content

reinhardt_admin/
lib.rs

1//! # reinhardt-admin
2//!
3//! Admin functionality for Reinhardt framework.
4//!
5//! This crate contains admin-related functionality:
6//! - **adapters**: Unified server/client imports for admin types
7//! - **core**: Admin site registration, model admin configuration, and database helpers
8//! - **pages**: Admin page rendering
9//! - **server**: Server functions and HTTP handlers
10//! - **settings**: Server-side admin settings
11//! - **types**: Shared request/response DTOs
12//!
13//! ## Features
14//!
15//! - `default`: No features enabled by default
16//! - `all`: All admin functionality
17//!
18//! ## Examples
19//!
20//! ## Available Modules
21//!
22//! - [`adapters`] - Admin adapter implementations
23//! - [`core`] - Admin core functionality
24//! - [`pages`] - Admin page rendering
25//! - [`server`] - Admin HTTP server
26//! - [`types`] - Shared type definitions
27
28#![warn(missing_docs)]
29#![cfg_attr(docsrs, feature(doc_cfg))]
30
31pub mod adapters;
32#[cfg(server)]
33pub mod core;
34#[cfg(client)]
35pub mod core {
36	//! Client-side admin core type stubs.
37	//!
38	//! The server target exposes the real admin core module. The client target
39	//! keeps the same import path available for shared code that names admin
40	//! core types in signatures erased by server functions or native-only macros.
41
42	pub use crate::types::{
43		AdminDatabase, AdminRecord, AdminSite, AdminUser, ExportFormat, ImportBuilder, ImportError,
44		ImportFormat, ImportResult, ModelAdmin, ModelAdminConfig, ModelAdminConfigBuilder,
45	};
46}
47pub mod pages;
48pub mod server;
49#[cfg(server)]
50pub mod settings;
51pub mod types;
52
53// Register admin static files for auto-discovery by collectstatic
54#[cfg(server)]
55const _: () = {
56	/// Path to admin static assets directory (embedded CSS/JS placeholder)
57	const ADMIN_STATIC_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets");
58
59	// Register at compile time using inventory
60	reinhardt_apps::register_app_static_files!("admin", ADMIN_STATIC_DIR, "/static/admin/");
61};
62
63// Register WASM build output for auto-discovery by collectstatic.
64// The dist-admin/ directory may not exist if the WASM SPA has not been built;
65// collectstatic gracefully skips non-existent directories.
66#[cfg(server)]
67const _: () = {
68	/// Path to admin WASM build output directory
69	const ADMIN_WASM_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/dist-admin");
70
71	reinhardt_apps::register_app_static_files!("admin-wasm", ADMIN_WASM_DIR, "/static/admin/");
72};
73
74// Register vendor assets (CSS, JS, fonts) for download via the generic
75// `reinhardt-utils::staticfiles::vendor` subsystem. Each entry is collected via
76// the `inventory` crate and downloaded lazily on first admin request.
77#[cfg(server)]
78const _: () = {
79	use reinhardt_apps::AppVendorAsset;
80
81	// Open Props v1.7.23 — CSS custom property design tokens
82	reinhardt_apps::inventory::submit! {
83		AppVendorAsset {
84			app_label: "admin",
85			url: "https://cdn.jsdelivr.net/npm/open-props@1.7.23/open-props.min.css",
86			target: "vendor/open-props.min.css",
87			sha256: "",
88		}
89	}
90
91	// Animate.css v4.1.1 — CSS animation library
92	reinhardt_apps::inventory::submit! {
93		AppVendorAsset {
94			app_label: "admin",
95			url: "https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css",
96			target: "vendor/animate.min.css",
97			sha256: "",
98		}
99	}
100
101	// DM Sans — Latin subset, weight 400 (regular)
102	reinhardt_apps::inventory::submit! {
103		AppVendorAsset {
104			app_label: "admin",
105			url: "https://cdn.jsdelivr.net/npm/@fontsource/dm-sans@5.1.1/files/dm-sans-latin-400-normal.woff2",
106			target: "vendor/fonts/dm-sans-latin-400-normal.woff2",
107			sha256: "",
108		}
109	}
110
111	// DM Sans — Latin subset, weight 400 italic
112	reinhardt_apps::inventory::submit! {
113		AppVendorAsset {
114			app_label: "admin",
115			url: "https://cdn.jsdelivr.net/npm/@fontsource/dm-sans@5.1.1/files/dm-sans-latin-400-italic.woff2",
116			target: "vendor/fonts/dm-sans-latin-400-italic.woff2",
117			sha256: "",
118		}
119	}
120
121	// DM Sans — Latin subset, weight 500 (medium)
122	reinhardt_apps::inventory::submit! {
123		AppVendorAsset {
124			app_label: "admin",
125			url: "https://cdn.jsdelivr.net/npm/@fontsource/dm-sans@5.1.1/files/dm-sans-latin-500-normal.woff2",
126			target: "vendor/fonts/dm-sans-latin-500-normal.woff2",
127			sha256: "",
128		}
129	}
130
131	// DM Sans — Latin subset, weight 600 (semi-bold)
132	reinhardt_apps::inventory::submit! {
133		AppVendorAsset {
134			app_label: "admin",
135			url: "https://cdn.jsdelivr.net/npm/@fontsource/dm-sans@5.1.1/files/dm-sans-latin-600-normal.woff2",
136			target: "vendor/fonts/dm-sans-latin-600-normal.woff2",
137			sha256: "",
138		}
139	}
140
141	// DM Sans — Latin subset, weight 700 (bold)
142	reinhardt_apps::inventory::submit! {
143		AppVendorAsset {
144			app_label: "admin",
145			url: "https://cdn.jsdelivr.net/npm/@fontsource/dm-sans@5.1.1/files/dm-sans-latin-700-normal.woff2",
146			target: "vendor/fonts/dm-sans-latin-700-normal.woff2",
147			sha256: "",
148		}
149	}
150
151	// Inter — Latin subset, weight 600 (semi-bold)
152	reinhardt_apps::inventory::submit! {
153		AppVendorAsset {
154			app_label: "admin",
155			url: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-600-normal.woff2",
156			target: "vendor/fonts/inter-latin-600-normal.woff2",
157			sha256: "",
158		}
159	}
160
161	// Inter — Latin subset, weight 700 (bold)
162	reinhardt_apps::inventory::submit! {
163		AppVendorAsset {
164			app_label: "admin",
165			url: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-700-normal.woff2",
166			target: "vendor/fonts/inter-latin-700-normal.woff2",
167			sha256: "",
168		}
169	}
170
171	// Inter — Latin subset, weight 800 (extra-bold)
172	reinhardt_apps::inventory::submit! {
173		AppVendorAsset {
174			app_label: "admin",
175			url: "https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-800-normal.woff2",
176			target: "vendor/fonts/inter-latin-800-normal.woff2",
177			sha256: "",
178		}
179	}
180
181	// UnoCSS Runtime v66.6.7 — browser-based utility CSS generation engine.
182	// Generates Tailwind-compatible utility CSS by observing DOM class names
183	// at runtime, eliminating the need for a build-time CLI step.
184	reinhardt_apps::inventory::submit! {
185		AppVendorAsset {
186			app_label: "admin",
187			url: "https://cdn.jsdelivr.net/npm/@unocss/runtime@66.6.7/uno.global.js",
188			target: "vendor/unocss-runtime.js",
189			sha256: "",
190		}
191	}
192};