Serve CSS as a static file instead of templating it
Moved _css.html to static/style.css and added a /style.css route that
serves it via include_str! with the correct content-type. HTML templates
now link to it with <link rel=stylesheet> instead of inlining via
include. CSS no longer passes through any templating engine.

Assisted-by: GLM-5.1 via pi
change vnmlqxkwyurlowpzszwqtnunqzrrwuyp
commit d6bdf4bb848da7359251ba62b48039f55861d522
author Alpha Chen <alpha@kejadlen.dev>
date
parent tkvnotqp
diff --git a/src/quire/web/handlers.rs b/src/quire/web/handlers.rs
index 3672049..9a580a9 100644
--- a/src/quire/web/handlers.rs
+++ b/src/quire/web/handlers.rs
@@ -2,7 +2,7 @@
 
 use askama::Template;
 use axum::extract::{Path as AxumPath, State};
-use axum::http::StatusCode;
+use axum::http::{StatusCode, header};
 use axum::response::{Html, IntoResponse, Redirect, Response};
 
 use super::db;
@@ -25,6 +25,15 @@ fn render<T: Template>(tmpl: &T) -> Response {
     }
 }
 
+/// Serve the compiled-in stylesheet.
+pub async fn stylesheet() -> Response {
+    (
+        [(header::CONTENT_TYPE, "text/css; charset=utf-8")],
+        include_str!("../../../static/style.css"),
+    )
+        .into_response()
+}
+
 /// Read a CRI log file, returning empty on NotFound and on any other
 /// error after logging it.
 async fn read_log(path: &std::path::Path) -> String {
diff --git a/src/quire/web/mod.rs b/src/quire/web/mod.rs
index 46f147c..8b501fb 100644
--- a/src/quire/web/mod.rs
+++ b/src/quire/web/mod.rs
@@ -20,6 +20,7 @@ use crate::Quire;
 /// `.layer(middleware::from_fn(auth::require_auth))`).
 pub fn router(quire: Quire) -> axum::Router {
     axum::Router::new()
+        .route("/style.css", axum::routing::get(handlers::stylesheet))
         .route("/{repo}", axum::routing::get(handlers::repo_redirect))
         .route("/{repo}/ci", axum::routing::get(handlers::run_list))
         .route(
diff --git a/templates/_css.html b/static/style.css
similarity index 100%
rename from templates/_css.html
rename to static/style.css
diff --git a/templates/_base.html b/templates/_base.html
index cc980c9..678ae3b 100644
--- a/templates/_base.html
+++ b/templates/_base.html
@@ -4,7 +4,7 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <title>{% block title %}quire{% endblock %}</title>
-    <style>{% include "_css.html" %}</style>
+    <link rel="stylesheet" href="/style.css">
   </head>
   <body>
     {% block nav %}{% endblock %}