From 2097a9ab13711a9a96bd94a08b0eeece5b7b2bf5 Mon Sep 17 00:00:00 2001 From: Seednode Date: Mon, 11 Sep 2023 21:22:26 -0500 Subject: [PATCH] Add looping and preload to audio and video files, add file types listed as supported by MDN --- cmd/files.go | 6 ++++++ cmd/root.go | 2 +- cmd/web.go | 5 ----- formats/audio.go | 2 +- formats/images.go | 9 +++++++++ formats/video.go | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/files.go b/cmd/files.go index e8ec849..e80aaa1 100644 --- a/cmd/files.go +++ b/cmd/files.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "math/big" + "regexp" "crypto/rand" "os" @@ -30,6 +31,11 @@ const ( maxFileScans maxConcurrency = 256 ) +type Regexes struct { + alphanumeric *regexp.Regexp + filename *regexp.Regexp +} + type Concurrency struct { directoryScans chan int fileScans chan int diff --git a/cmd/root.go b/cmd/root.go index f80c217..6283f5e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - Version string = "0.69.2" + Version string = "0.69.3" ) var ( diff --git a/cmd/web.go b/cmd/web.go index cfb9e22..f1245a1 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -37,11 +37,6 @@ const ( Timeout time.Duration = 10 * time.Second ) -type Regexes struct { - alphanumeric *regexp.Regexp - filename *regexp.Regexp -} - func serveStaticFile(paths []string, stats *ServeStats, index *Index) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { path := strings.TrimPrefix(r.URL.Path, SourcePrefix) diff --git a/formats/audio.go b/formats/audio.go index db4acc4..a5fbdf1 100644 --- a/formats/audio.go +++ b/formats/audio.go @@ -15,7 +15,7 @@ func RegisterAudioFormats() *SupportedFormat { return fmt.Sprintf(`%s`, fileName) }, Body: func(queryParams, fileUri, filePath, fileName, mime string) string { - return fmt.Sprintf(``, + return fmt.Sprintf(``, queryParams, fileUri, mime, diff --git a/formats/images.go b/formats/images.go index 5ca3e3a..767a8af 100644 --- a/formats/images.go +++ b/formats/images.go @@ -51,18 +51,27 @@ func RegisterImageFormats() *SupportedFormat { fileName) }, Extensions: []string{ + `.apng`, + `.avif`, `.bmp`, `.gif`, `.jpg`, `.jpeg`, + `.jfif`, + `.pjp`, + `.pjpeg`, `.png`, + `.svg`, `.webp`, }, MimeTypes: []string{ + `image/apng`, + `image/avif`, `image/bmp`, `image/gif`, `image/jpeg`, `image/png`, + `image/svg+xml`, `image/webp`, }, Validate: func(filePath string) bool { diff --git a/formats/video.go b/formats/video.go index e6f18e9..b199b30 100644 --- a/formats/video.go +++ b/formats/video.go @@ -15,7 +15,7 @@ func RegisterVideoFormats() *SupportedFormat { return fmt.Sprintf(`%s`, fileName) }, Body: func(queryParams, fileUri, filePath, fileName, mime string) string { - return fmt.Sprintf(``, + return fmt.Sprintf(``, queryParams, fileUri, mime,