admin: Fix video route

This commit is contained in:
nemunaire 2022-05-23 01:39:35 +02:00
commit 4a190f51c5
8 changed files with 28 additions and 7 deletions

View file

@ -235,6 +235,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]*
errs = append(errs, fmt.Sprintf("%q: resolution.mp4: The file is empty!", edir))
e.VideoURI = ""
} else {
e.VideoURI = path.Join("$FILES$", e.VideoURI)
resolutionFound = true
}

View file

@ -41,6 +41,11 @@ type Importer interface {
stat(filename string) (os.FileInfo, error)
}
// DirectAccessImporter abstracts importer that support direct file access through a local path
type DirectAccessImporter interface {
GetLocalPath(p ...string) string
}
// GlobalImporter stores the main importer instance to use for global imports.
var GlobalImporter Importer

View file

@ -22,6 +22,10 @@ func (i GitImporter) toURL(filename string) string {
return i.li.toURL(filename)
}
func (i GitImporter) GetLocalPath(filename ...string) string {
return i.li.GetLocalPath(filename...)
}
func (i GitImporter) importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error) {
return i.li.importFile(URI, next)
}

View file

@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io/ioutil"
"log"
"os"
"path"
)
@ -53,9 +54,14 @@ func (i LocalImporter) exists(filename string) bool {
}
func (i LocalImporter) toURL(filename string) string {
log.Println(i.Base, filename, path.Join(i.Base, filename))
return path.Join(i.Base, filename)
}
func (i LocalImporter) GetLocalPath(p ...string) string {
return i.toURL(path.Join(p...))
}
func (i LocalImporter) importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error) {
if i.Symlink {
dest := getDestinationFilePath(URI)