diff --git a/example-gallery/image-1 ' (2).jpg b/example-gallery/1.jpg similarity index 100% rename from example-gallery/image-1 ' (2).jpg rename to example-gallery/1.jpg diff --git a/example-gallery/image-2_2.jpg b/example-gallery/10.jpg similarity index 100% rename from example-gallery/image-2_2.jpg rename to example-gallery/10.jpg diff --git a/example-gallery/image-2_3.jpg b/example-gallery/11.jpg similarity index 100% rename from example-gallery/image-2_3.jpg rename to example-gallery/11.jpg diff --git a/example-gallery/image-3 (2).jpg b/example-gallery/12.jpg similarity index 100% rename from example-gallery/image-3 (2).jpg rename to example-gallery/12.jpg diff --git a/example-gallery/image-3.jpg b/example-gallery/13.jpg similarity index 100% rename from example-gallery/image-3.jpg rename to example-gallery/13.jpg diff --git a/example-gallery/image-3_1.jpg b/example-gallery/14.jpg similarity index 100% rename from example-gallery/image-3_1.jpg rename to example-gallery/14.jpg diff --git a/example-gallery/image-3_2.jpg b/example-gallery/15.jpg similarity index 100% rename from example-gallery/image-3_2.jpg rename to example-gallery/15.jpg diff --git a/example-gallery/image-3_3.jpg b/example-gallery/16.jpg similarity index 100% rename from example-gallery/image-3_3.jpg rename to example-gallery/16.jpg diff --git a/example-gallery/image-4 (2).jpg b/example-gallery/17.jpg similarity index 100% rename from example-gallery/image-4 (2).jpg rename to example-gallery/17.jpg diff --git a/example-gallery/image-4.jpg b/example-gallery/18.jpg similarity index 100% rename from example-gallery/image-4.jpg rename to example-gallery/18.jpg diff --git a/example-gallery/image-4_1.jpg b/example-gallery/19.jpg similarity index 100% rename from example-gallery/image-4_1.jpg rename to example-gallery/19.jpg diff --git a/example-gallery/image-1.jpg b/example-gallery/2.jpg similarity index 100% rename from example-gallery/image-1.jpg rename to example-gallery/2.jpg diff --git a/example-gallery/image-4_2.jpg b/example-gallery/20.jpg similarity index 100% rename from example-gallery/image-4_2.jpg rename to example-gallery/20.jpg diff --git a/example-gallery/image-4_3.jpg b/example-gallery/21.jpg similarity index 100% rename from example-gallery/image-4_3.jpg rename to example-gallery/21.jpg diff --git a/example-gallery/image-5 (2).jpg b/example-gallery/22.jpg similarity index 100% rename from example-gallery/image-5 (2).jpg rename to example-gallery/22.jpg diff --git a/example-gallery/image-5.jpg b/example-gallery/23.jpg similarity index 100% rename from example-gallery/image-5.jpg rename to example-gallery/23.jpg diff --git a/example-gallery/image-9_1.jpg b/example-gallery/24.jpg similarity index 100% rename from example-gallery/image-9_1.jpg rename to example-gallery/24.jpg diff --git a/example-gallery/image-8_1.jpg b/example-gallery/25.jpg similarity index 100% rename from example-gallery/image-8_1.jpg rename to example-gallery/25.jpg diff --git a/example-gallery/image-7 (2).jpg b/example-gallery/26.jpg similarity index 100% rename from example-gallery/image-7 (2).jpg rename to example-gallery/26.jpg diff --git a/example-gallery/image-8 (2).jpg b/example-gallery/27.jpg similarity index 100% rename from example-gallery/image-8 (2).jpg rename to example-gallery/27.jpg diff --git a/example-gallery/image-6_2.jpg b/example-gallery/28.jpg similarity index 100% rename from example-gallery/image-6_2.jpg rename to example-gallery/28.jpg diff --git a/example-gallery/image-10 (2).jpg b/example-gallery/29.jpg similarity index 100% rename from example-gallery/image-10 (2).jpg rename to example-gallery/29.jpg diff --git a/example-gallery/3.mp4 b/example-gallery/3.mp4 new file mode 100644 index 0000000..7936dc0 Binary files /dev/null and b/example-gallery/3.mp4 differ diff --git a/example-gallery/image-10.jpg b/example-gallery/30.jpg similarity index 100% rename from example-gallery/image-10.jpg rename to example-gallery/30.jpg diff --git a/example-gallery/image-10_1.jpg b/example-gallery/31.jpg similarity index 100% rename from example-gallery/image-10_1.jpg rename to example-gallery/31.jpg diff --git a/example-gallery/image-10_2.jpg b/example-gallery/32.jpg similarity index 100% rename from example-gallery/image-10_2.jpg rename to example-gallery/32.jpg diff --git a/example-gallery/image-7_2.jpg b/example-gallery/33.jpg similarity index 100% rename from example-gallery/image-7_2.jpg rename to example-gallery/33.jpg diff --git a/example-gallery/image-7_1.jpg b/example-gallery/34.jpg similarity index 100% rename from example-gallery/image-7_1.jpg rename to example-gallery/34.jpg diff --git a/example-gallery/image-7.jpg b/example-gallery/35.jpg similarity index 100% rename from example-gallery/image-7.jpg rename to example-gallery/35.jpg diff --git a/example-gallery/image-9 (2).jpg b/example-gallery/36.jpg similarity index 100% rename from example-gallery/image-9 (2).jpg rename to example-gallery/36.jpg diff --git a/example-gallery/image-8_2.jpg b/example-gallery/37.jpg similarity index 100% rename from example-gallery/image-8_2.jpg rename to example-gallery/37.jpg diff --git a/example-gallery/image-9.jpg b/example-gallery/38.jpg similarity index 100% rename from example-gallery/image-9.jpg rename to example-gallery/38.jpg diff --git a/example-gallery/image-9_2.jpg b/example-gallery/39.jpg similarity index 100% rename from example-gallery/image-9_2.jpg rename to example-gallery/39.jpg diff --git a/example-gallery/image-1_1.jpg b/example-gallery/4.jpg similarity index 100% rename from example-gallery/image-1_1.jpg rename to example-gallery/4.jpg diff --git a/example-gallery/image-5_3.jpg b/example-gallery/40.jpg similarity index 100% rename from example-gallery/image-5_3.jpg rename to example-gallery/40.jpg diff --git a/example-gallery/image-5_1.jpg b/example-gallery/41.jpg similarity index 100% rename from example-gallery/image-5_1.jpg rename to example-gallery/41.jpg diff --git a/example-gallery/image-5_2.jpg b/example-gallery/42.jpg similarity index 100% rename from example-gallery/image-5_2.jpg rename to example-gallery/42.jpg diff --git a/example-gallery/image-6 (2).jpg b/example-gallery/43.jpg similarity index 100% rename from example-gallery/image-6 (2).jpg rename to example-gallery/43.jpg diff --git a/example-gallery/image-6.jpg b/example-gallery/44.jpg similarity index 100% rename from example-gallery/image-6.jpg rename to example-gallery/44.jpg diff --git a/example-gallery/image-6_1.jpg b/example-gallery/45.jpg similarity index 100% rename from example-gallery/image-6_1.jpg rename to example-gallery/45.jpg diff --git a/example-gallery/image-8.jpg b/example-gallery/46.jpg similarity index 100% rename from example-gallery/image-8.jpg rename to example-gallery/46.jpg diff --git a/example-gallery/image-1_2.jpg b/example-gallery/5.jpg similarity index 100% rename from example-gallery/image-1_2.jpg rename to example-gallery/5.jpg diff --git a/example-gallery/image-1_3.jpg b/example-gallery/6.jpg similarity index 100% rename from example-gallery/image-1_3.jpg rename to example-gallery/6.jpg diff --git a/example-gallery/image-2 (2).jpg b/example-gallery/7.jpg similarity index 100% rename from example-gallery/image-2 (2).jpg rename to example-gallery/7.jpg diff --git a/example-gallery/image-2.jpg b/example-gallery/8.jpg similarity index 100% rename from example-gallery/image-2.jpg rename to example-gallery/8.jpg diff --git a/example-gallery/image-2_1.jpg b/example-gallery/9.jpg similarity index 100% rename from example-gallery/image-2_1.jpg rename to example-gallery/9.jpg diff --git a/example-gallery/gal.html b/example-gallery/gal.html index e84b327..54d031e 100644 --- a/example-gallery/gal.html +++ b/example-gallery/gal.html @@ -1 +1 @@ -example-gallery
🔀ℹī¸
\ No newline at end of file +example-gallery
🔀ℹī¸
\ No newline at end of file diff --git a/main.go b/main.go index 27e699a..6cdb56b 100644 --- a/main.go +++ b/main.go @@ -46,6 +46,13 @@ func createHTMLGallery(template, directoryAbsolutePath string, images []fs.FileI galleryInfo := fmt.Sprintf("Created on %s - %d images", time.Now().Format("January 2, 2006 at 3:04 PM"), len(images)) galleryContents := "" for _, image := range images { + if fileIsVideo(image) { + galleryContents += fmt.Sprintf(` +
+
`, h.EscapeString(image.Name())) + continue + } galleryContents += fmt.Sprintf(`
diff --git a/template.html b/template.html index a30c691..2469996 100644 --- a/template.html +++ b/template.html @@ -17,7 +17,7 @@ counter-increment: item-counter; margin: 0; } - img { + img, video { width: 100%; height: auto; display: block; diff --git a/util.go b/util.go index e906e60..f2cee0a 100644 --- a/util.go +++ b/util.go @@ -47,6 +47,22 @@ func openBrowser(url string, browser string) error { return exec.Command(cmd, args...).Start() } +func fileIsVideo(file fs.FileInfo) bool { + videoFileTypes := []string{ + ".mp4", + ".webm", + ".ogg", + ".mov", + ".mpg", + } + for _, fileType := range videoFileTypes { + if strings.HasSuffix(file.Name(), fileType) { + return true + } + } + return false +} + // fileIsImage checks if a file is a browser-compatible image based on its extension func fileIsImage(file fs.FileInfo) bool { // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types @@ -79,7 +95,7 @@ func getImagesInDirectory(afs afero.Fs, dir string) []fs.FileInfo { } images := []fs.FileInfo{} for _, file := range files { - if fileIsImage(file) { + if fileIsImage(file) || fileIsVideo(file) { images = append(images, file) } }