don't
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

build(knot): feature gate ui bits

Signed-off-by: tjh <x@tjh.dev>

tjh 2fe4465e 8a4feb1c

+30 -13
+2 -1
crates/gordian-knot/Cargo.toml
··· 37 37 clap_complete = "4.5.66" 38 38 futures-util = "0.3.32" 39 39 hyper-util = { version = "0.1.17", features = ["client"] } 40 - maud = { version = "0.27.0", features = ["axum"] } 40 + maud = { version = "0.27.0", features = ["axum"], optional = true } 41 41 metrics-exporter-prometheus = { version = "0.18.1" } 42 42 mimetype-detector = "0.3.4" 43 43 moka = { version = "0.12.12", features = ["future"] } ··· 68 68 [features] 69 69 default = ["jemalloc"] 70 70 jemalloc = ["dep:tikv-jemallocator"] 71 + frontend = ["dep:maud"]
+10 -5
crates/gordian-knot/build.rs
··· 1 - use std::env; 2 1 use std::error::Error; 3 - use std::path::Path; 4 - use std::process; 5 - 6 - use anyhow::Context as _; 7 2 8 3 fn main() -> Result<(), Box<dyn Error>> { 9 4 println!("cargo::rerun-if-changed=build.rs"); 5 + 6 + #[cfg(feature = "frontend")] 10 7 build_tailwind()?; 8 + 11 9 Ok(()) 12 10 } 13 11 12 + #[cfg(feature = "frontend")] 14 13 fn build_tailwind() -> Result<(), Box<dyn Error>> { 14 + use std::env; 15 + use std::path::Path; 16 + use std::process; 17 + 18 + use anyhow::Context as _; 19 + 15 20 println!("cargo::rerun-if-changed=src/public"); 16 21 println!("cargo::rerun-if-changed=tailwind.css"); 17 22
+2
crates/gordian-knot/src/lib.rs
··· 7 7 pub mod services; 8 8 pub mod sync; 9 9 pub mod types; 10 + 11 + #[cfg(feature = "frontend")] 10 12 pub mod ui; 11 13 12 14 #[cfg(test)]
+16 -7
crates/gordian-knot/src/public.rs
··· 1 1 //! Public API for the knot server. 2 2 3 - use axum::extract::State; 4 - 3 + #[cfg(feature = "frontend")] 5 4 pub mod authorize; 6 5 pub mod events; 7 6 pub mod git; ··· 9 10 pub fn router() -> axum::Router<crate::Knot> { 10 11 use axum::routing::get; 11 12 12 - axum::Router::new() 13 + let router = axum::Router::new() 13 14 .without_v07_checks() 14 15 .nest("/xrpc", xrpc::router()) 15 16 .nest("/{owner}/{name}", git::router()) 16 - .route("/", get(index)) 17 + .route("/events", get(events::handler)); 18 + 19 + #[cfg(feature = "frontend")] 20 + return router 17 21 .route("/gordian.css", get(stylesheet)) 18 - .route("/events", get(events::handler)) 19 - .merge(authorize::router()) 22 + .route("/", get(index)) 23 + .merge(authorize::router()); 24 + 25 + #[cfg(not(feature = "frontend"))] 26 + router 20 27 } 21 28 22 - async fn index(State(knot): State<crate::Knot>) -> maud::Markup { 29 + #[cfg(feature = "frontend")] 30 + async fn index(axum::extract::State(knot): axum::extract::State<crate::Knot>) -> maud::Markup { 23 31 layout( 24 32 maud::html! { title { "The Gordian Knot (server)" } }, 25 33 maud::html! { ··· 38 32 ) 39 33 } 40 34 35 + #[cfg(feature = "frontend")] 41 36 async fn stylesheet() -> impl axum::response::IntoResponse { 42 37 use axum::http::header::CONTENT_TYPE; 43 38 ··· 48 41 ) 49 42 } 50 43 44 + #[cfg(feature = "frontend")] 51 45 fn layout(head: maud::Markup, body: maud::Markup, foot: maud::Markup) -> maud::Markup { 52 46 maud::html! { 53 47 (maud::DOCTYPE) ··· 80 72 } 81 73 } 82 74 75 + #[cfg(feature = "frontend")] 83 76 fn foot(knot: &crate::Knot) -> maud::Markup { 84 77 maud::html! { 85 78 div class="flex" {