diff --git a/admin/static.go b/admin/static.go
index bdf5e0a6..df54ea5d 100644
--- a/admin/static.go
+++ b/admin/static.go
@@ -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."))
}
diff --git a/admin/static/js/common.js b/admin/static/js/common.js
index ec0cc409..29eba62c 100644
--- a/admin/static/js/common.js
+++ b/admin/static/js/common.js
@@ -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)
diff --git a/admin/static/views/exercice-resolution.html b/admin/static/views/exercice-resolution.html
index 2a58267c..43736b1f 100644
--- a/admin/static/views/exercice-resolution.html
+++ b/admin/static/views/exercice-resolution.html
@@ -7,5 +7,5 @@
-
+
diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go
index d2e07c47..30830a31 100644
--- a/admin/sync/exercices.go
+++ b/admin/sync/exercices.go
@@ -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
}
diff --git a/admin/sync/file.go b/admin/sync/file.go
index eb6a3bef..057603ce 100644
--- a/admin/sync/file.go
+++ b/admin/sync/file.go
@@ -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
diff --git a/admin/sync/importer_git_common.go b/admin/sync/importer_git_common.go
index faf7b25c..179c3c5a 100644
--- a/admin/sync/importer_git_common.go
+++ b/admin/sync/importer_git_common.go
@@ -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)
}
diff --git a/admin/sync/importer_localfs.go b/admin/sync/importer_localfs.go
index 63f82df2..9c234294 100644
--- a/admin/sync/importer_localfs.go
+++ b/admin/sync/importer_localfs.go
@@ -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)
diff --git a/frontend/ui/src/components/ExerciceVideo.svelte b/frontend/ui/src/components/ExerciceVideo.svelte
index a13c20c8..9c889963 100644
--- a/frontend/ui/src/components/ExerciceVideo.svelte
+++ b/frontend/ui/src/components/ExerciceVideo.svelte
@@ -18,8 +18,8 @@
Solution du défi
-