From 04a5dd62b626c13035613bb5ad925dc2edcb80ff Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Thu, 8 Aug 2024 22:10:55 -0400 Subject: [PATCH] Fix url path --- main.go | 6 +----- web/index.js | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 24b2bdb..7ce8e04 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,6 @@ import ( ) var ( - imagesDir string collageDir string photosDir string devMode bool @@ -41,7 +40,6 @@ var ( func main() { var ppURL string - flag.StringVar(&imagesDir, "images-dir", "images", "Sets the images dir") flag.StringVar(&collageDir, "collages-dir", "collages", "Sets the collages dir") flag.StringVar(&photosDir, "photos-dir", "photos", "Cache directory for downloaded photos") flag.BoolVar(&devMode, "dev", false, "Serve local assets during development") @@ -59,8 +57,7 @@ func main() { return photoPrismURL }() collageNameGen = NewNameGen() - imagesDirFs = os.DirFS(imagesDir) - imagesURLPath := "images" + imagesDirFs = os.DirFS(photosDir) collagesPath := "collages" photosPath := "photos" @@ -69,7 +66,6 @@ func main() { http.Handle("/"+path+"/", http.StripPrefix("/"+path, httpFileServer)) } - addFileServer(imagesURLPath, imagesDir) addFileServer(collagesPath, collageDir) addFileServer(photosPath, photosDir) diff --git a/web/index.js b/web/index.js index 9292913..d5578be 100644 --- a/web/index.js +++ b/web/index.js @@ -148,8 +148,12 @@ function snap() { const fsx = elem.offsetLeft - col const fsy = elem.offsetTop - cot const [sx, sy, ex, ey] = cpie.get().points; + const imageFile = (() => { + const u = new URL(elem.dataset.collageImageUrl) + return u.pathname.slice("/photos/".length) + })(); const photo = { - image: elem.dataset.collageImageUrl.slice("images/".length), + image: imageFile, crop: { start: { x: parseInt(sx),