From fcb261f5d336c4362339e6da5b35a340ec5aa6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 4 Jul 2022 12:22:41 +0200 Subject: [PATCH] =?UTF-8?q?Move=20the=20webapp=20from=20`/app/=E2=80=A6`?= =?UTF-8?q?=20to=20`/app/v3/=E2=80=A6`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help in the future to host multiple (major) versions of Flamenco on the same system, redirecting based on their URL prefix. --- Makefile | 6 +++--- cmd/flamenco-manager/main.go | 18 +++++++++--------- web/app/package.json | 2 +- .../src/components/jobs/LastRenderedImage.vue | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index f7e79d4c..29fbc558 100644 --- a/Makefile +++ b/Makefile @@ -56,10 +56,10 @@ webapp: webapp-static: addon-packer $(MAKE) clean-webapp-static # When changing the base URL, also update the line -# e.GET("/app/*", echo.WrapHandler(webAppHandler)) +# e.GET("/app/v3/*", echo.WrapHandler(webAppHandler)) # in `cmd/flamenco-manager/main.go` - yarn --cwd web/app build --outDir ../static --base=/app/ -# yarn --cwd web/app build --outDir ../static --base=/app/ --minify false + yarn --cwd web/app build --outDir ../static --base=/app/v3/ +# yarn --cwd web/app build --outDir ../static --base=/app/v3/ --minify false ./addon-packer -filename ${WEB_STATIC}/flamenco3-addon.zip @echo "Web app has been installed into ${WEB_STATIC}" diff --git a/cmd/flamenco-manager/main.go b/cmd/flamenco-manager/main.go index 9fd0c843..98d8d2ff 100644 --- a/cmd/flamenco-manager/main.go +++ b/cmd/flamenco-manager/main.go @@ -298,15 +298,12 @@ func buildWebService( }) } - // Serve static files for the webapp on /app/. + // Serve static files for the webapp on /app/v3/. webAppHandler, err := web.WebAppHandler() if err != nil { log.Fatal().Err(err).Msg("unable to set up HTTP server for embedded web app") } - e.GET("/app/*", echo.WrapHandler(http.StripPrefix("/app", webAppHandler))) - e.GET("/app", func(c echo.Context) error { - return c.Redirect(http.StatusTemporaryRedirect, "/app/") - }) + e.GET("/app/v3/*", echo.WrapHandler(http.StripPrefix("/app/v3", webAppHandler))) // Serve the Blender add-on. It's contained in the static files of the webapp. e.GET("/flamenco3-addon.zip", echo.WrapHandler(webAppHandler)) @@ -321,10 +318,13 @@ func buildWebService( Msg("serving job-specific files directly from disk") e.Static(api_impl.JobFilesURLPrefix, localStorage.Root()) - // Redirect / to the webapp. - e.GET("/", func(c echo.Context) error { - return c.Redirect(http.StatusTemporaryRedirect, "/app/") - }) + // Redirect / and subsets of the webapp URL to the actual webapp URL. + redirectToWebapp := func(c echo.Context) error { + return c.Redirect(http.StatusTemporaryRedirect, "/app/v3/") + } + e.GET("/app/v3", redirectToWebapp) + e.GET("/app/", redirectToWebapp) + e.GET("/", redirectToWebapp) // Log available routes routeLogger := log.Level(zerolog.TraceLevel) diff --git a/web/app/package.json b/web/app/package.json index 50286456..a412fb73 100644 --- a/web/app/package.json +++ b/web/app/package.json @@ -12,7 +12,7 @@ } ], "scripts": { - "dev": "vite --port 8081 --base /app/", + "dev": "vite --port 8081 --base /app/v3/", "build": "vite build", "preview": "vite preview --port 5050", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" diff --git a/web/app/src/components/jobs/LastRenderedImage.vue b/web/app/src/components/jobs/LastRenderedImage.vue index c4cc3e98..0e124b92 100644 --- a/web/app/src/components/jobs/LastRenderedImage.vue +++ b/web/app/src/components/jobs/LastRenderedImage.vue @@ -53,7 +53,7 @@ function setImageURL(thumbnailInfo) { if (thumbnailInfo == null) { // This indicates that there is no last-rendered image. // Default to a hard-coded 'nothing to be seen here, move along' image. - imageURL.value = "/app/nothing-rendered-yet.svg"; + imageURL.value = "/app/v3/nothing-rendered-yet.svg"; cssClasses['nothing-rendered-yet'] = true; console.log("LastRenderedImage.vue: setting image URL to:", imageURL.value); return;