aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-13 14:57:30 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-13 14:57:30 +0200
commit8341ed16bac8aebc83db0e8fae4eb14a6dec9422 (patch)
treefbe66d666ca7b10e6b48fcc50feb4b4b35cf9d7b
parent71c58d99549a66da05b9221d9f0dbf1119255def (diff)
downloadkeks-meet-8341ed16bac8aebc83db0e8fae4eb14a6dec9422.tar
keks-meet-8341ed16bac8aebc83db0e8fae4eb14a6dec9422.tar.bz2
keks-meet-8341ed16bac8aebc83db0e8fae4eb14a6dec9422.tar.zst
fix include_dir problems
-rw-r--r--server/src/assets.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/src/assets.rs b/server/src/assets.rs
index 7195fbf..a80b6aa 100644
--- a/server/src/assets.rs
+++ b/server/src/assets.rs
@@ -26,7 +26,7 @@ macro_rules! s_file {
($path: literal, $content_type: literal) => {
warp::any().map(|| {
warp::reply::with_header(
- include_bytes!(concat!("../../", $path)).to_vec(),
+ include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../", $path)).to_vec(),
"content-type",
$content_type,
)
@@ -37,9 +37,19 @@ macro_rules! s_file {
#[cfg(not(debug_assertions))]
#[macro_export]
macro_rules! s_asset_dir {
- ($path:literal) => {{
+ ("client-web/locale") => {{
use include_dir::{include_dir, Dir};
- const DIR: Dir = include_dir!(concat!("$CARGO_MANIFEST_DIR/../", $path));
+ const DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../client-web/locale");
+ warp::path::tail().and_then(|t: warp::path::Tail| async move {
+ let path = t.as_str();
+ DIR.get_file(path)
+ .map(|f| warp::reply::with_header(f.contents(), "content-type", "text/plain"))
+ .ok_or(warp::reject::not_found())
+ })
+ }};
+ ("client-web/public/assets") => {{
+ use include_dir::{include_dir, Dir};
+ const DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../client-web/public/assets");
warp::path::tail().and_then(|t: warp::path::Tail| async move {
let path = t.as_str();
let content_type = match &path {
@@ -47,7 +57,6 @@ macro_rules! s_asset_dir {
_ if path.ends_with(".js") => "application/javascript",
_ if path.ends_with(".css") => "text/css",
_ if path.ends_with(".svg") => "image/svg+xml",
- _ if path.ends_with(".ini") => "text/plain",
_ => "application/octet-stream",
};
DIR.get_file(path)