IDK man, changes I guess
This commit is contained in:
28
fs.go
28
fs.go
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user