Merge asset and page server
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
use axum::Router;
|
||||
use page::{PageServer, redirect::Redirect};
|
||||
use macro_sass::sass;
|
||||
use page::{PageServer, asset::StaticAsset, redirect::Redirect};
|
||||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
use toolbox::mime::MimeType;
|
||||
|
||||
use crate::pages;
|
||||
|
||||
pub mod assets;
|
||||
|
||||
pub(super) fn router() -> Router<()> {
|
||||
let (asset_prefix, asset_router) = assets::asset_router();
|
||||
info!("Serving assets at {asset_prefix}");
|
||||
|
||||
let router = build_server().into_router();
|
||||
|
||||
Router::new().merge(router).nest(asset_prefix, asset_router)
|
||||
build_server().into_router()
|
||||
}
|
||||
|
||||
fn build_server() -> Arc<PageServer> {
|
||||
@@ -26,7 +20,171 @@ fn build_server() -> Arc<PageServer> {
|
||||
.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());
|
||||
.add_page("/htwah/typesetting", pages::htwah_typesetting())
|
||||
//
|
||||
.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::Css,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/img/betalupi.png",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/betalupi-map.png"),
|
||||
mime: MimeType::Css,
|
||||
},
|
||||
)
|
||||
.add_page(
|
||||
"/assets/img/icon.png",
|
||||
StaticAsset {
|
||||
bytes: include_bytes!("../../assets/images/icon.png"),
|
||||
mime: MimeType::Css,
|
||||
},
|
||||
)
|
||||
//
|
||||
// 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,
|
||||
},
|
||||
)
|
||||
//
|
||||
// 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,
|
||||
},
|
||||
)
|
||||
//
|
||||
// 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,
|
||||
},
|
||||
);
|
||||
|
||||
server
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user