feat: package server ui

This commit is contained in:
Ashhhleyyy 2024-04-01 01:30:28 +01:00
parent ae487a9a40
commit 26ba37b3eb
Signed by: ash
GPG key ID: 83B789081A0878FB
3 changed files with 39 additions and 4 deletions

View file

@ -17,6 +17,24 @@
webstudio = import ./webstudio.nix { webstudio = import ./webstudio.nix {
inherit pkgs; inherit pkgs;
}; };
ui-templates = pkgs.stdenv.mkDerivation {
name = "baps-ui-templates";
src = ./ui-templates;
phases = "installPhase";
installPhase = ''
mkdir -p $out
cp -R $src/. $out
'';
};
ui-static = pkgs.stdenv.mkDerivation {
name = "baps-ui-static";
src = ./ui-static;
phases = "installPhase";
installPhase = ''
mkdir -p $out
cp -R $src/. $out
'';
};
dependencies = ps: with ps; [ dependencies = ps: with ps; [
setuptools setuptools
wheel wheel
@ -51,6 +69,8 @@
(pkgs.substituteAll { (pkgs.substituteAll {
src = ./patches/1-presenter-build-path.patch; src = ./patches/1-presenter-build-path.patch;
baps_presenter = "${webstudio}"; baps_presenter = "${webstudio}";
ui_static = "${ui-static}";
ui_templates = "${ui-templates}";
}) })
]; ];
}; };

View file

@ -1,9 +1,25 @@
diff --git a/web_server.py b/web_server.py diff --git a/web_server.py b/web_server.py
index ccc3979..dc36db3 100644 index ccc3979..2909ff8 100644
--- a/web_server.py --- a/web_server.py
+++ b/web_server.py +++ b/web_server.py
@@ -449,11 +449,11 @@ app.static( @@ -32,7 +32,7 @@ import package
app.static("/static", resolve_local_file_path("ui-static"), name="ui-static") from baps_types.happytime import happytime
env = Environment(
- loader=FileSystemLoader("%s/ui-templates/" % os.path.dirname(__file__)),
+ loader=FileSystemLoader("@ui_templates@"),
autoescape=select_autoescape(),
)
@@ -444,16 +444,16 @@ async def audio_file(request, type: str, id: int):
# Static Files
app.static(
- "/favicon.ico", resolve_local_file_path("ui-static/favicon.ico"), name="ui-favicon"
+ "/favicon.ico", "@ui_static@/favicon.ico", name="ui-favicon"
)
-app.static("/static", resolve_local_file_path("ui-static"), name="ui-static")
+app.static("/static", "@ui_static@", name="ui-static")
-dist_directory = resolve_local_file_path("presenter-build") -dist_directory = resolve_local_file_path("presenter-build")

View file

@ -12,7 +12,6 @@ let
}; };
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
pname = "baps-presenter";
name = "baps-presenter"; name = "baps-presenter";
inherit src; inherit src;