diff --git a/pkg6depotd/src/http/handlers/ui.rs b/pkg6depotd/src/http/handlers/ui.rs index 72c9b2a..7200bed 100644 --- a/pkg6depotd/src/http/handlers/ui.rs +++ b/pkg6depotd/src/http/handlers/ui.rs @@ -524,3 +524,34 @@ pub async fn ui_p5i_generate( ) .into_response()) } + +// =========================================================================== +// Embedded static assets +// =========================================================================== + +static CSS_CONTENT: &str = include_str!("../../../static/css/style.css"); +static HTMX_JS_CONTENT: &str = include_str!("../../../static/js/htmx.min.js"); + +/// GET /ui/static/css/style.css +pub async fn static_css() -> Response { + ( + [ + (header::CONTENT_TYPE, "text/css; charset=utf-8"), + (header::CACHE_CONTROL, "public, max-age=3600"), + ], + CSS_CONTENT, + ) + .into_response() +} + +/// GET /ui/static/js/htmx.min.js +pub async fn static_htmx_js() -> Response { + ( + [ + (header::CONTENT_TYPE, "application/javascript; charset=utf-8"), + (header::CACHE_CONTROL, "public, max-age=86400"), + ], + HTMX_JS_CONTENT, + ) + .into_response() +} diff --git a/pkg6depotd/src/http/routes.rs b/pkg6depotd/src/http/routes.rs index 2b7ed04..d34921d 100644 --- a/pkg6depotd/src/http/routes.rs +++ b/pkg6depotd/src/http/routes.rs @@ -7,15 +7,9 @@ use axum::{ routing::{get, post}, }; use std::sync::Arc; -use tower_http::services::ServeDir; use tower_http::trace::TraceLayer; pub fn app_router(state: Arc) -> Router { - // Static file serving for the web UI - let static_dir = ServeDir::new( - std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("static"), - ); - Router::new() .route("/", get(|| async { Redirect::permanent("/ui/") })) .route("/versions/0", get(versions::get_versions)) @@ -79,7 +73,9 @@ pub fn app_router(state: Arc) -> Router { .route("/ui/search/results", get(ui::ui_search_results)) .route("/ui/package/{publisher}/{*fmri}", get(ui::ui_package_detail)) .route("/ui/p5i", get(ui::ui_p5i_generate)) - .nest_service("/ui/static", static_dir) + // Embedded static assets + .route("/ui/static/css/style.css", get(ui::static_css)) + .route("/ui/static/js/htmx.min.js", get(ui::static_htmx_js)) .layer(TraceLayer::new_for_http()) .with_state(state) } diff --git a/pkg6depotd/static/css/style.css b/pkg6depotd/static/css/style.css index 8442d30..b519307 100644 --- a/pkg6depotd/static/css/style.css +++ b/pkg6depotd/static/css/style.css @@ -3,8 +3,7 @@ Full custom stylesheet — no framework dependencies ========================================================================== */ -/* --- Fonts --- */ -@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap'); +/* Fonts loaded via in base.html for non-blocking load */ /* --- Design tokens --- */ :root { diff --git a/pkg6depotd/templates/base.html b/pkg6depotd/templates/base.html index cb7607a..30bc191 100644 --- a/pkg6depotd/templates/base.html +++ b/pkg6depotd/templates/base.html @@ -4,6 +4,9 @@ {% block title %}Package Repository{% endblock %} + + +