admin: Fix video route
This commit is contained in:
parent
b92381f007
commit
4a190f51c5
|
@ -98,14 +98,14 @@ func declareStaticRoutes(router *gin.RouterGroup, cfg *settings.Settings, baseUR
|
|||
})
|
||||
|
||||
router.GET("/files/*_", func(c *gin.Context) {
|
||||
http.ServeFile(c.Writer, c.Request, path.Join(fic.FilesDir, strings.TrimPrefix(c.Request.URL.Path, "/files")))
|
||||
http.ServeFile(c.Writer, c.Request, path.Join(fic.FilesDir, strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "files"))))
|
||||
})
|
||||
router.GET("/submissions/*_", func(c *gin.Context) {
|
||||
http.ServeFile(c.Writer, c.Request, path.Join(api.TimestampCheck, strings.TrimPrefix(c.Request.URL.Path, "/submissions")))
|
||||
http.ServeFile(c.Writer, c.Request, path.Join(api.TimestampCheck, strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "submissions"))))
|
||||
})
|
||||
router.GET("/vids/*_", func(c *gin.Context) {
|
||||
if importer, ok := sync.GlobalImporter.(sync.LocalImporter); ok {
|
||||
http.ServeFile(c.Writer, c.Request, path.Join(importer.Base, strings.TrimPrefix(c.Request.URL.Path, "/vids")))
|
||||
if importer, ok := sync.GlobalImporter.(sync.DirectAccessImporter); ok {
|
||||
http.ServeFile(c.Writer, c.Request, importer.GetLocalPath(strings.TrimPrefix(c.Request.URL.Path, path.Join(baseURL, "vids"))))
|
||||
} else {
|
||||
c.AbortWithError(http.StatusBadRequest, errors.New("Only available with local importer."))
|
||||
}
|
||||
|
|
|
@ -84,6 +84,11 @@ angular.module("FICApp")
|
|||
}]);
|
||||
|
||||
angular.module("FICApp")
|
||||
.filter("escapeURL", function() {
|
||||
return function(input) {
|
||||
return encodeURIComponent(input);
|
||||
}
|
||||
})
|
||||
.filter("stripHTML", function() {
|
||||
return function(input) {
|
||||
if (!input)
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
</h2>
|
||||
|
||||
<div class="text-center">
|
||||
<video src="vids/{{exercice.videoURI}}" controls style="height: 80vh; margin: auto;"></video>
|
||||
<video src="vids/{{exercice.videoURI.replace('\$FILES\$/','').replace('?', '%3F')}}" controls style="height: 80vh; margin: auto;"></video>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
Solution du défi
|
||||
</CardHeader>
|
||||
<CardBody class="text-indent ratio ratio-16x9">
|
||||
<iframe type="text/html" src="{uri}" class="embed-responsive-item" title="Vidéo de résolution">
|
||||
Regardez la vidéo de résolution de ce défi : <a href="{uri}">{uri}</a>.
|
||||
<iframe type="text/html" src="{uri.replace('$FILES$','/resolution')}" class="embed-responsive-item" title="Vidéo de résolution">
|
||||
Regardez la vidéo de résolution de ce défi : <a href="{uri.replace('$FILES$','/resolution')}">{uri.replace('$FILES$','/resolution')}</a>.
|
||||
</iframe>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
|
Loading…
Reference in New Issue