Migrate to servable
Some checks failed
CI / Check typos (push) Successful in 15s
CI / Check links (push) Failing after 1m37s
CI / Clippy (push) Successful in 3m44s
CI / Build and test (push) Successful in 12m33s
CI / Build container (push) Successful in 10m24s
CI / Deploy on waypoint (push) Successful in 49s
Some checks failed
CI / Check typos (push) Successful in 15s
CI / Check links (push) Failing after 1m37s
CI / Clippy (push) Successful in 3m44s
CI / Build and test (push) Successful in 12m33s
CI / Build container (push) Successful in 10m24s
CI / Deploy on waypoint (push) Successful in 49s
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
use axum::Router;
|
||||
use macro_sass::sass;
|
||||
use page::{
|
||||
ServableRoute,
|
||||
servable::{Redirect, StaticAsset},
|
||||
use servable::{
|
||||
CACHE_BUST_STR, Redirect, ServableRouter, ServableWithRoute, StaticAsset, mime::MimeType,
|
||||
};
|
||||
use toolbox::mime::MimeType;
|
||||
use tower_http::compression::{CompressionLayer, DefaultPredicate};
|
||||
|
||||
use crate::pages;
|
||||
@@ -20,184 +17,270 @@ pub(super) fn router() -> Router<()> {
|
||||
build_server().into_router().layer(compression)
|
||||
}
|
||||
|
||||
fn build_server() -> ServableRoute {
|
||||
ServableRoute::new()
|
||||
.with_404(pages::notfound())
|
||||
.add_page("/", pages::index())
|
||||
.add_page("/links", pages::links())
|
||||
.add_page("/whats-a-betalupi", pages::betalupi())
|
||||
.add_page("/handouts", pages::handouts())
|
||||
pub static HTMX: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htmx-2.0.8.js".into(),
|
||||
servable::HTMX_2_0_8.with_ttl(None),
|
||||
);
|
||||
|
||||
pub static HTMX_JSON: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htmx-json-1.19.12.js".into(),
|
||||
servable::EXT_JSON_1_19_12,
|
||||
);
|
||||
|
||||
pub static MAIN_CSS: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| format!("/assets/{}/css/main.css", *CACHE_BUST_STR),
|
||||
StaticAsset {
|
||||
bytes: grass::include!("css/main.scss").as_bytes(),
|
||||
mime: MimeType::Css,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static IMG_COVER_SMALL: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/img/cover-small.jpg".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/cover-small.jpg"),
|
||||
mime: MimeType::Jpg,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static IMG_BETALUPI: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/img/betalupi.png".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/betalupi-map.png"),
|
||||
mime: MimeType::Png,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static IMG_ICON: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/img/icon.png".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/icon.png"),
|
||||
mime: MimeType::Png,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
// MARK: fonts
|
||||
//
|
||||
|
||||
pub static FONT_FIRACODE_BOLD: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-Bold.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Bold.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FIRACODE_LIGHT: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-Light.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Light.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FIRACODE_MEDIUM: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-Medium.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Medium.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FIRACODE_REGULAR: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-Regular.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Regular.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FIRACODE_SEMIBOLD: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-SemiBold.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-SemiBold.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FIRACODE_VF: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/FiraCode-VF.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-VF.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
// MARK: icons
|
||||
//
|
||||
pub static FONT_FA_BRANDS_WOFF2: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-brands-400.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-brands-400.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FA_REGULAR_WOFF2: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-regular-400.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-regular-400.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FA_SOLID_WOFF2: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-solid-900.woff2".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-solid-900.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FA_BRANDS_TTF: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-brands-400.ttf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-brands-400.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FA_REGULAR_TTF: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-regular-400.ttf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-regular-400.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static FONT_FA_SOLID_TTF: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/fonts/fa/fa-solid-900.ttf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-solid-900.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
// MARK: htwah
|
||||
//
|
||||
pub static HTWAH_DEFINITIONS: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/definitions.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/definitions.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static HTWAH_NUMBERING: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/numbering.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/numbering.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static HTWAH_SOLS_A: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/sols-a.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/sols-a.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static HTWAH_SOLS_B: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/sols-b.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/sols-b.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static HTWAH_SPACING_A: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/spacing-a.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/spacing-a.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
pub static HTWAH_SPACING_B: ServableWithRoute<StaticAsset> = ServableWithRoute::new(
|
||||
|| "/assets/htwah/spacing-b.pdf".into(),
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/spacing-b.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
ttl: StaticAsset::DEFAULT_TTL,
|
||||
},
|
||||
);
|
||||
|
||||
fn build_server() -> ServableRouter {
|
||||
ServableRouter::new()
|
||||
.with_404(&pages::NOT_FOUND)
|
||||
.add_page("/", &pages::INDEX)
|
||||
.add_page("/links", pages::LINKS)
|
||||
.add_page("/whats-a-betalupi", pages::BETALUPI)
|
||||
.add_page("/handouts", &pages::HANDOUTS)
|
||||
.add_page("/htwah", {
|
||||
#[expect(clippy::unwrap_used)]
|
||||
Redirect::new("/handouts").unwrap()
|
||||
})
|
||||
.add_page("/htwah/typesetting", pages::htwah_typesetting())
|
||||
.add_page("/assets/htmx.js", page::HTMX_2_0_8)
|
||||
.add_page("/assets/htmx-json.js", page::EXT_JSON_1_19_12)
|
||||
.add_page("/htwah/typesetting", pages::HTWAH_TYPESETTING)
|
||||
.add_page_with_route(&HTMX)
|
||||
.add_page_with_route(&HTMX_JSON)
|
||||
//
|
||||
.add_page(
|
||||
"/assets/css/main.css",
|
||||
StaticAsset {
|
||||
bytes: sass!("css/main.scss").as_bytes(),
|
||||
mime: MimeType::Css,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/img/cover-small.jpg",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/cover-small.jpg"),
|
||||
mime: MimeType::Jpg,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/img/betalupi.png",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/betalupi-map.png"),
|
||||
mime: MimeType::Png,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/img/icon.png",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/icon.png"),
|
||||
mime: MimeType::Png,
|
||||
},
|
||||
)
|
||||
.add_page_with_route(&MAIN_CSS)
|
||||
.add_page_with_route(&IMG_COVER_SMALL)
|
||||
.add_page_with_route(&IMG_BETALUPI)
|
||||
.add_page_with_route(&IMG_ICON)
|
||||
//
|
||||
// MARK: fonts
|
||||
//
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-Bold.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Bold.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-Light.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Light.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-Medium.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Medium.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-Regular.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-Regular.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-SemiBold.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-SemiBold.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/FiraCode-VF.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fira/FiraCode-VF.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page_with_route(&FONT_FIRACODE_BOLD)
|
||||
.add_page_with_route(&FONT_FIRACODE_LIGHT)
|
||||
.add_page_with_route(&FONT_FIRACODE_MEDIUM)
|
||||
.add_page_with_route(&FONT_FIRACODE_REGULAR)
|
||||
.add_page_with_route(&FONT_FIRACODE_SEMIBOLD)
|
||||
.add_page_with_route(&FONT_FIRACODE_VF)
|
||||
//
|
||||
// MARK: icons
|
||||
//
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-brands-400.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-brands-400.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-regular-400.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-regular-400.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-solid-900.woff2",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-solid-900.woff2"),
|
||||
mime: MimeType::Woff2,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-brands-400.ttf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-brands-400.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-regular-400.ttf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-regular-400.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/fonts/fa/fa-solid-900.ttf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/fonts/fa/fa-solid-900.ttf"),
|
||||
mime: MimeType::Ttf,
|
||||
},
|
||||
)
|
||||
.add_page_with_route(&FONT_FA_BRANDS_WOFF2)
|
||||
.add_page_with_route(&FONT_FA_REGULAR_WOFF2)
|
||||
.add_page_with_route(&FONT_FA_SOLID_WOFF2)
|
||||
.add_page_with_route(&FONT_FA_BRANDS_TTF)
|
||||
.add_page_with_route(&FONT_FA_REGULAR_TTF)
|
||||
.add_page_with_route(&FONT_FA_SOLID_TTF)
|
||||
//
|
||||
// MARK: htwah
|
||||
//
|
||||
.add_page(
|
||||
"/assets/htwah/definitions.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/definitions.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/htwah/numbering.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/numbering.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/htwah/sols-a.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/sols-a.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/htwah/sols-b.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/sols-b.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/htwah/spacing-a.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/spacing-a.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/htwah/spacing-b.pdf",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/htwah/spacing-b.pdf"),
|
||||
mime: MimeType::Pdf,
|
||||
},
|
||||
)
|
||||
.add_page_with_route(&HTWAH_DEFINITIONS)
|
||||
.add_page_with_route(&HTWAH_NUMBERING)
|
||||
.add_page_with_route(&HTWAH_SOLS_A)
|
||||
.add_page_with_route(&HTWAH_SOLS_B)
|
||||
.add_page_with_route(&HTWAH_SPACING_A)
|
||||
.add_page_with_route(&HTWAH_SPACING_B)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user