Move the webapp from /app/… to /app/v3/…

This will help in the future to host multiple (major) versions of Flamenco
on the same system, redirecting based on their URL prefix.
This commit is contained in:
Sybren A. Stüvel 2022-07-04 12:22:41 +02:00
parent 7d64d1bca4
commit fcb261f5d3
4 changed files with 14 additions and 14 deletions

View File

@ -56,10 +56,10 @@ webapp:
webapp-static: addon-packer webapp-static: addon-packer
$(MAKE) clean-webapp-static $(MAKE) clean-webapp-static
# When changing the base URL, also update the line # 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` # in `cmd/flamenco-manager/main.go`
yarn --cwd web/app build --outDir ../static --base=/app/ yarn --cwd web/app build --outDir ../static --base=/app/v3/
# yarn --cwd web/app build --outDir ../static --base=/app/ --minify false # yarn --cwd web/app build --outDir ../static --base=/app/v3/ --minify false
./addon-packer -filename ${WEB_STATIC}/flamenco3-addon.zip ./addon-packer -filename ${WEB_STATIC}/flamenco3-addon.zip
@echo "Web app has been installed into ${WEB_STATIC}" @echo "Web app has been installed into ${WEB_STATIC}"

View File

@ -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() webAppHandler, err := web.WebAppHandler()
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("unable to set up HTTP server for embedded web app") 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/v3/*", echo.WrapHandler(http.StripPrefix("/app/v3", webAppHandler)))
e.GET("/app", func(c echo.Context) error {
return c.Redirect(http.StatusTemporaryRedirect, "/app/")
})
// Serve the Blender add-on. It's contained in the static files of the webapp. // Serve the Blender add-on. It's contained in the static files of the webapp.
e.GET("/flamenco3-addon.zip", echo.WrapHandler(webAppHandler)) e.GET("/flamenco3-addon.zip", echo.WrapHandler(webAppHandler))
@ -321,10 +318,13 @@ func buildWebService(
Msg("serving job-specific files directly from disk") Msg("serving job-specific files directly from disk")
e.Static(api_impl.JobFilesURLPrefix, localStorage.Root()) e.Static(api_impl.JobFilesURLPrefix, localStorage.Root())
// Redirect / to the webapp. // Redirect / and subsets of the webapp URL to the actual webapp URL.
e.GET("/", func(c echo.Context) error { redirectToWebapp := func(c echo.Context) error {
return c.Redirect(http.StatusTemporaryRedirect, "/app/") return c.Redirect(http.StatusTemporaryRedirect, "/app/v3/")
}) }
e.GET("/app/v3", redirectToWebapp)
e.GET("/app/", redirectToWebapp)
e.GET("/", redirectToWebapp)
// Log available routes // Log available routes
routeLogger := log.Level(zerolog.TraceLevel) routeLogger := log.Level(zerolog.TraceLevel)

View File

@ -12,7 +12,7 @@
} }
], ],
"scripts": { "scripts": {
"dev": "vite --port 8081 --base /app/", "dev": "vite --port 8081 --base /app/v3/",
"build": "vite build", "build": "vite build",
"preview": "vite preview --port 5050", "preview": "vite preview --port 5050",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"

View File

@ -53,7 +53,7 @@ function setImageURL(thumbnailInfo) {
if (thumbnailInfo == null) { if (thumbnailInfo == null) {
// This indicates that there is no last-rendered image. // This indicates that there is no last-rendered image.
// Default to a hard-coded 'nothing to be seen here, move along' 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; cssClasses['nothing-rendered-yet'] = true;
console.log("LastRenderedImage.vue: setting image URL to:", imageURL.value); console.log("LastRenderedImage.vue: setting image URL to:", imageURL.value);
return; return;