Add looping and preload to audio and video files, add file types listed as supported by MDN

This commit is contained in:
Seednode 2023-09-11 21:22:26 -05:00
parent e614846302
commit 2097a9ab13
6 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -12,7 +12,7 @@ import (
)
const (
Version string = "0.69.2"
Version string = "0.69.3"
)
var (

View File

@ -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)

View File

@ -15,7 +15,7 @@ func RegisterAudioFormats() *SupportedFormat {
return fmt.Sprintf(`<title>%s</title>`, fileName)
},
Body: func(queryParams, fileUri, filePath, fileName, mime string) string {
return fmt.Sprintf(`<a href="/%s"><audio controls autoplay><source src="%s" type="%s" alt="Roulette selected: %s">Your browser does not support the audio tag.</audio></a>`,
return fmt.Sprintf(`<a href="/%s"><audio controls autoplay loop preload="auto"><source src="%s" type="%s" alt="Roulette selected: %s">Your browser does not support the audio tag.</audio></a>`,
queryParams,
fileUri,
mime,

View File

@ -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 {

View File

@ -15,7 +15,7 @@ func RegisterVideoFormats() *SupportedFormat {
return fmt.Sprintf(`<title>%s</title>`, fileName)
},
Body: func(queryParams, fileUri, filePath, fileName, mime string) string {
return fmt.Sprintf(`<a href="/%s"><video controls autoplay><source src="%s" type="%s" alt="Roulette selected: %s">Your browser does not support the video tag.</video></a>`,
return fmt.Sprintf(`<a href="/%s"><video controls autoplay loop preload="auto"><source src="%s" type="%s" alt="Roulette selected: %s">Your browser does not support the video tag.</video></a>`,
queryParams,
fileUri,
mime,