From 45710bef37834f8ad75b3c55b6cab8dc0e04bb68 Mon Sep 17 00:00:00 2001 From: Toni Melisma Date: Sun, 6 Dec 2020 01:09:13 +0200 Subject: [PATCH] URI coding for JS and last TODOs for templates --- cmd/fastgallery/main.go | 4 ++- web/fastgallery.js | 8 +++--- web/template.html | 57 ++++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/cmd/fastgallery/main.go b/cmd/fastgallery/main.go index 5a5083d..6eb0ca5 100644 --- a/cmd/fastgallery/main.go +++ b/cmd/fastgallery/main.go @@ -44,6 +44,7 @@ var optDryRun = false var optCleanUp = false // templates +// TODO move templates externally const rawTemplate = ` @@ -355,6 +356,7 @@ func getHTMLRelPath(originalRelPath string, newRootDir string, sourceRootDir str } func createHTML(subdirectories []directory, files []file, sourceRootDir string, htmlDirectoryPath string) { + // TODO include root directory assets and link relatively htmlFilePath := filepath.Join(htmlDirectoryPath, "index.html") var data htmlData @@ -451,7 +453,7 @@ func resizeThumbnailVideo(source string, destination string) { image, err := vips.NewImageFromFile(destination) checkError(err) - // TODO don't load overlay separately + // TODO preload overlay globally to reduce overhead playbuttonOverlayImage, err := vips.NewImageFromFile(assetPlaybuttonImage) checkError(err) diff --git a/web/fastgallery.js b/web/fastgallery.js index b1bb79e..256573b 100644 --- a/web/fastgallery.js +++ b/web/fastgallery.js @@ -57,7 +57,7 @@ const displayModal = (display) => { const preload = (number) => { var preloadLink = document.createElement("link") preloadLink.rel = "prefetch" - preloadLink.href = pictures[number].fullsize + preloadLink.href = encodeURI(pictures[number].fullsize) const fileExtension = preloadLink.href.split("\.").pop() if (fileExtension == videoExtension) { preloadLink.as = "video" @@ -110,9 +110,9 @@ const changePicture = (number) => { window.location.hash = thumbnailFilename.substring(thumbnailFilename.indexOf("/") + 1) const fileExtension = pictures[number].fullsize.split("\.").pop() if (fileExtension == videoExtension) { - document.getElementById("modalMedia").innerHTML = "" + document.getElementById("modalMedia").innerHTML = "" } else { - document.getElementById("modalMedia").innerHTML = "\""" + document.getElementById("modalMedia").innerHTML = "\""" } document.getElementById("modalDescription").innerHTML = pictures[number].fullsize.substring(pictures[number].fullsize.indexOf("/") + 1) document.getElementById("modalDownload").href = pictures[number].original @@ -122,7 +122,7 @@ const changePicture = (number) => { // if URL links directly to thumbnail via hash link, open modal for that pic on page load const hashNavigate = () => { if (window.location.hash) { - const thumbnail = decodeURIComponent(window.location.hash.substring(1)) + const thumbnail = decodeURI(window.location.hash.substring(1)) id = pictures.findIndex(item => item.thumbnail.substring(item.thumbnail.indexOf("/") + 1) == thumbnail) if (id != -1 && id >= 0 && id < pictures.length) { changePicture(id) diff --git a/web/template.html b/web/template.html index a281aaa..96241a3 100644 --- a/web/template.html +++ b/web/template.html @@ -19,11 +19,13 @@ diipadaapa - temp2 + temp2
2018-03-31 16.48.28.jpg - 2018-03-31 16.48.28.jpg + 2018-03-31 + 16.48.28.jpg
2018-03-31 16.48.28.jpg @@ -96,32 +98,33 @@
+ - - - - - + + + + +