This commit is contained in:
JMARyA 2025-01-21 16:39:47 +01:00
parent e02def6bc1
commit f3880d77d2
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
8 changed files with 265 additions and 85 deletions

View file

@ -1,7 +1,7 @@
use based::get_pg;
use based::request::{RequestContext, StringResponse};
use based::ui::components::Shell;
use based::ui::render_page;
use based::ui::prelude::Nothing;
use maud::html;
use rocket::get;
use rocket::routes;
@ -12,13 +12,9 @@ pub async fn index_page(ctx: RequestContext) -> StringResponse {
h1 { "Hello World!" };
);
render_page(
content,
"Hello World",
ctx,
&Shell::new(html! {}, html! {}, Some(String::new())),
)
.await
Shell::new(Nothing(), Nothing(), Nothing())
.render_page(content, "Hello World", ctx)
.await
}
#[rocket::launch]

View file

@ -1,14 +1,15 @@
use based::asset::AssetRoutes;
use based::request::{RequestContext, StringResponse};
use based::ui::components::{AppBar, Shell};
use based::ui::htmx::{Event, HTMXAttributes};
use based::ui::{prelude::*, render_page};
use based::ui::prelude::*;
use maud::Render;
use maud::html;
use rocket::get;
use rocket::routes;
use rocket::{State, get};
#[get("/")]
pub async fn index_page(ctx: RequestContext) -> StringResponse {
pub async fn index_page(ctx: RequestContext, shell: &State<Shell>) -> StringResponse {
let content = AppBar("MyApp", None).render();
let content = html!(
@ -36,19 +37,7 @@ pub async fn index_page(ctx: RequestContext) -> StringResponse {
);
render_page(
content,
"Hello World",
ctx,
&Shell::new(
html! {
script src="https://cdn.tailwindcss.com" {};
},
html! {},
Some(String::new()),
),
)
.await
shell.render_page(content, "Hello World", ctx).await
}
#[rocket::launch]
@ -56,5 +45,10 @@ async fn launch() -> _ {
// Logging
env_logger::init();
rocket::build().mount("/", routes![index_page])
let shell = Shell::new(Nothing(), Nothing(), Nothing()).use_ui();
rocket::build()
.mount("/", routes![index_page])
.mount_assets() // Mount included assets routes
.manage(shell) // Manage global shell reference
}