diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/assets.rs | 27 | ||||
-rw-r--r-- | server/src/main.rs | 4 |
2 files changed, 27 insertions, 4 deletions
diff --git a/server/src/assets.rs b/server/src/assets.rs index 51b0025..6047164 100644 --- a/server/src/assets.rs +++ b/server/src/assets.rs @@ -1,4 +1,9 @@ -#[cfg(not(feature = "standalone"))] +use std::fs::read_to_string; + +use grass::StdFs; +use log::error; + +#[cfg(debug_assertions)] #[macro_export] macro_rules! s_file { ($path: literal, $content_type: literal) => { @@ -6,7 +11,7 @@ macro_rules! s_file { }; } -#[cfg(not(feature = "standalone"))] +#[cfg(debug_assertions)] #[macro_export] macro_rules! s_asset_dir { () => { @@ -14,7 +19,7 @@ macro_rules! s_asset_dir { }; } -#[cfg(feature = "standalone")] +#[cfg(not(debug_assertions))] #[macro_export] macro_rules! s_file { ($path: literal, $content_type: literal) => { @@ -28,7 +33,7 @@ macro_rules! s_file { }; } -#[cfg(feature = "standalone")] +#[cfg(not(debug_assertions))] #[macro_export] macro_rules! s_asset_dir { () => {{ @@ -49,3 +54,17 @@ macro_rules! s_asset_dir { }) }}; } + +pub fn css_bundle() -> String { + grass::from_string( + read_to_string("../client-web/style/master.sass").unwrap(), + &grass::Options::default() + .input_syntax(grass::InputSyntax::Sass) + .load_path("../client-web/style") + .fs(&StdFs), + ) + .unwrap_or_else(|err| { + error!("sass compile failed: {err}"); + String::from("/* sass compile failed */") + }) +} diff --git a/server/src/main.rs b/server/src/main.rs index 26d22ee..431d668 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -8,6 +8,7 @@ pub mod config; pub mod protocol; pub mod room; +use assets::css_bundle; use config::{ClientAppearanceConfig, ClientConfig}; use hyper::{header, StatusCode}; use listenfd::ListenFd; @@ -68,6 +69,8 @@ async fn run() { let client_config_css: _ = warp::path!("overrides.css").map(move || { warp::reply::with_header(client_config_css.clone(), "content-type", "text/css") }); + let css: _ = warp::path!("style.css") + .map(move || warp::reply::with_header(css_bundle(), "content-type", "text/css")); let favicon: _ = warp::path!("favicon.ico").map(|| ""); let old_format_redirect: _ = warp::path!("room" / String).map(|rsecret| { reply::with_header( @@ -85,6 +88,7 @@ async fn run() { .or(signaling) .or(client_config) .or(version) + .or(css) .or(favicon) .or(sw_script) .or(old_format_redirect) |