From 34ef2555c07c6eaf4d905565851b0d6877e216be Mon Sep 17 00:00:00 2001 From: Toni Melisma Date: Fri, 19 Mar 2021 14:35:07 +0200 Subject: [PATCH] Add manifest link --- cmd/fastgallery/assets/gallery.gohtml | 3 +++ cmd/fastgallery/main.go | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/fastgallery/assets/gallery.gohtml b/cmd/fastgallery/assets/gallery.gohtml index 25eed4f..ecf419c 100644 --- a/cmd/fastgallery/assets/gallery.gohtml +++ b/cmd/fastgallery/assets/gallery.gohtml @@ -5,6 +5,9 @@ {{ .Title }} + {{if .ManifestFile }} + + {{ end }} {{ range .CSS }} {{ end }} diff --git a/cmd/fastgallery/main.go b/cmd/fastgallery/main.go index 9a993fd..4153691 100644 --- a/cmd/fastgallery/main.go +++ b/cmd/fastgallery/main.go @@ -142,6 +142,7 @@ type htmlData struct { JS []string FolderIcon string BackIcon string + ManifestFile string } // transformationJob struct is used to communicate needed image/video transformations to @@ -664,8 +665,6 @@ func getIconType(iconPath string) (filetype string, err error) { // createPWAManifest creates a customized manifest.json for a PWA if PWA url is supplied in args func createPWAManifest(gallery directory, source directory, dryRun bool, config configuration) { - // TODO Fill in data structure, load template and execute it - // TODO Iterate over icons, grab size from filename // TODO Add manifest link to HTMLs // TODO Add apple-touch-icon to HTML // TODO register service worker in HTML, add manifest and apple-touch-icon links to head @@ -848,9 +847,15 @@ func createHTML(depth int, source directory, galleryDirectory string, dryRun boo if depth > 0 { thisHTML.BackIcon = filepath.Join(rootEscape, config.assets.backIcon) } + // Generic folder icon to be used for each subfolder thisHTML.FolderIcon = filepath.Join(rootEscape, config.assets.folderIcon) + // If we're in the root directory, add manifest link + if depth == 0 { + thisHTML.ManifestFile = config.assets.manifestFile + } + // thisHTML struct has been filled in successfully, parse the HTML template, // fill in the data and write it to the correct file htmlFilePath := filepath.Join(galleryDirectory, config.assets.htmlFile)