IDK man, changes I guess

This commit is contained in:
2026-11-06 17:57:01 +00:00
parent 9fb9395f99
commit 4c8cafd733
15 changed files with 785 additions and 61 deletions

28
fs.go
View File

@@ -9,6 +9,31 @@ import (
"strings"
)
// fileKind is a type of file the editor opens: what the open dialog and the
// built-in file browser show.
type fileKind struct {
Title string
Label string // file filter name
Exts []string
Multiple bool
}
var fileKinds = map[string]fileKind{
"video": {Title: "Add videos", Label: "Video files", Exts: mediaExts, Multiple: true},
"captions": {Title: "Load captions", Label: "Subtitle files", Exts: captionExts},
}
// captionExts are the caption files the editor loads (see captions.go).
var captionExts = []string{"srt"}
// fileKindOf returns the named file kind, videos by default.
func fileKindOf(name string) fileKind {
if k, ok := fileKinds[name]; ok {
return k
}
return fileKinds["video"]
}
type fsEntry struct {
Name string `json:"name"`
Path string `json:"path"`
@@ -23,6 +48,7 @@ func (a *App) handleFSList(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
dir := strings.TrimSpace(q.Get("path"))
showAll := q.Get("all") == "1"
exts := fileKindOf(q.Get("kind")).Exts
home, _ := os.UserHomeDir()
if dir == "" {
dir = home
@@ -57,7 +83,7 @@ func (a *App) handleFSList(w http.ResponseWriter, r *http.Request) {
}
if !isD && !showAll {
ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(name), "."))
if !slices.Contains(mediaExts, ext) {
if !slices.Contains(exts, ext) {
continue
}
}