diff --git a/modules/templates/helper.go b/modules/templates/helper.go index d5d7bcdab..762471ca5 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -307,6 +307,9 @@ func NewFuncMap() []template.FuncMap { "tasks": tasks, "categories": categories, "licenses": licenses, + "DatasetPathJoin": func(arr []string, index int, seq string) string { + return strings.Join(arr[0:index+1], seq) + }, }} } diff --git a/routers/repo/dir.go b/routers/repo/dir.go index e8aecbcd6..f99b3ad95 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -29,6 +29,7 @@ type FileInfo struct { func DirIndex(ctx *context.Context) { uuid := ctx.Params("uuid") parentDir := ctx.Query("parentDir") + dirArray := strings.Split(parentDir, "/") if parentDir == "" { attachment, err := models.GetAttachmentByUUID(uuid) @@ -41,15 +42,13 @@ func DirIndex(ctx *context.Context) { log.Error("The file is not zip file, can not query the dir") ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) return - } else { - if attachment.DecompressState != models.DecompressStateDone { - log.Error("The file has not been decompressed completely now") - ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) - return - } + } else if attachment.DecompressState != models.DecompressStateDone { + log.Error("The file has not been decompressed completely now") + ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) + return } - ctx.Data["Title"] = attachment.Name + // ctx.Data["OriginName"] = attachment.Name } files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + @@ -87,7 +86,9 @@ func DirIndex(ctx *context.Context) { i++ } + ctx.Data["Path"] = dirArray ctx.Data["Dirs"] = fileInfos + ctx.Data["PageIsDataset"] = true ctx.HTML(200, tplDirIndex) } diff --git a/templates/repo/datasets/dirs/dir_list.tmpl b/templates/repo/datasets/dirs/dir_list.tmpl index 93e4b09cc..15f15920d 100755 --- a/templates/repo/datasets/dirs/dir_list.tmpl +++ b/templates/repo/datasets/dirs/dir_list.tmpl @@ -2,15 +2,15 @@ {{range .Dirs}}
-
+
{{.Size | FileSize}}
-
+
{{.ModTime}}
diff --git a/templates/repo/datasets/dirs/index.tmpl b/templates/repo/datasets/dirs/index.tmpl index e89067a23..a6caf79db 100755 --- a/templates/repo/datasets/dirs/index.tmpl +++ b/templates/repo/datasets/dirs/index.tmpl @@ -5,24 +5,20 @@
-

{{.Title}}

+

+ {{ range $index, $item := .Path }} + {{ $item }}/ + {{ end }} +

-
-
-
-
-
-

{{.i18n.Tr "dataset.dir"}}

-
-
-
+
- {{/* {{template "repo/datasets/dirs/dir_list" .}} */}} + {{template "repo/datasets/dirs/dir_list" .}}