Fix url path

This commit is contained in:
Balakrishnan Balasubramanian 2024-08-08 22:10:55 -04:00
parent 1db7b2b4ad
commit 04a5dd62b6
2 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,6 @@ import (
) )
var ( var (
imagesDir string
collageDir string collageDir string
photosDir string photosDir string
devMode bool devMode bool
@ -41,7 +40,6 @@ var (
func main() { func main() {
var ppURL string 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(&collageDir, "collages-dir", "collages", "Sets the collages dir")
flag.StringVar(&photosDir, "photos-dir", "photos", "Cache directory for downloaded photos") flag.StringVar(&photosDir, "photos-dir", "photos", "Cache directory for downloaded photos")
flag.BoolVar(&devMode, "dev", false, "Serve local assets during development") flag.BoolVar(&devMode, "dev", false, "Serve local assets during development")
@ -59,8 +57,7 @@ func main() {
return photoPrismURL return photoPrismURL
}() }()
collageNameGen = NewNameGen() collageNameGen = NewNameGen()
imagesDirFs = os.DirFS(imagesDir) imagesDirFs = os.DirFS(photosDir)
imagesURLPath := "images"
collagesPath := "collages" collagesPath := "collages"
photosPath := "photos" photosPath := "photos"
@ -69,7 +66,6 @@ func main() {
http.Handle("/"+path+"/", http.StripPrefix("/"+path, httpFileServer)) http.Handle("/"+path+"/", http.StripPrefix("/"+path, httpFileServer))
} }
addFileServer(imagesURLPath, imagesDir)
addFileServer(collagesPath, collageDir) addFileServer(collagesPath, collageDir)
addFileServer(photosPath, photosDir) addFileServer(photosPath, photosDir)

View File

@ -148,8 +148,12 @@ function snap() {
const fsx = elem.offsetLeft - col const fsx = elem.offsetLeft - col
const fsy = elem.offsetTop - cot const fsy = elem.offsetTop - cot
const [sx, sy, ex, ey] = cpie.get().points; 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 = { const photo = {
image: elem.dataset.collageImageUrl.slice("images/".length), image: imageFile,
crop: { crop: {
start: { start: {
x: parseInt(sx), x: parseInt(sx),