Generic servable
Some checks failed
CI / Check typos (push) Successful in 8s
CI / Check links (push) Failing after 11s
CI / Clippy (push) Successful in 53s
CI / Build and test (push) Successful in 1m10s
CI / Build container (push) Successful in 54s
CI / Deploy on waypoint (push) Successful in 43s

This commit is contained in:
2025-11-07 10:31:48 -08:00
parent a3ff195de9
commit 6cb54c2300
10 changed files with 263 additions and 161 deletions

View File

@@ -1,12 +1,9 @@
use std::{pin::Pin, sync::Arc};
use assetserver::Asset;
use axum::Router;
use maud::{DOCTYPE, Markup, PreEscaped, html};
use page::{Page, PageServer, RequestContext};
use page::{PageServer, redirect::Redirect};
use std::sync::Arc;
use tracing::info;
use crate::{components::misc::FarLink, pages, routes::assets::Styles_Main};
use crate::pages;
pub mod assets;
@@ -20,63 +17,20 @@ pub(super) fn router() -> Router<()> {
}
fn build_server() -> Arc<PageServer> {
let server = PageServer::new(Box::new(page_wrapper));
let server = PageServer::new();
#[expect(clippy::unwrap_used)]
server
.add_page("/", pages::index())
.add_page("/links", pages::links())
.add_page("/whats-a-betalupi", pages::betalupi())
.add_page("/handouts", pages::handouts())
.add_page("/htwah", Redirect::new("/handouts").unwrap())
.add_page("/htwah/typesetting", pages::htwah_typesetting());
server
}
fn page_wrapper<'a>(
page: &'a Page,
req_ctx: &'a RequestContext,
) -> Pin<Box<dyn Future<Output = Markup> + 'a + Send + Sync>> {
Box::pin(async move {
html! {
(DOCTYPE)
html {
head {
meta charset="UTF" {}
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
meta property="og:type" content="website" {}
link rel="stylesheet" href=(Styles_Main::URL) {}
(&page.meta)
title { (PreEscaped(page.meta.title.clone())) }
}
body {
div class="wrapper" {
main { ( page.generate_html(req_ctx).await ) }
footer {
hr class = "footline" {}
div class = "footContainer" {
p {
"This site was built by hand using "
(FarLink("https://rust-lang.org", "Rust"))
", "
(FarLink("https://maud.lambda.xyz", "Maud"))
", "
(FarLink("https://github.com/connorskees/grass", "Grass"))
", and "
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
"."
}
}
}
}
}
}
}
})
}
#[test]
fn server_builds_without_panic() {
tokio::runtime::Builder::new_current_thread()