Browse Source

improve

tags/v1.21.12.1
palytoxin 5 years ago
parent
commit
53d339e3dc
4 changed files with 21 additions and 21 deletions
  1. +3
    -0
      modules/templates/helper.go
  2. +8
    -7
      routers/repo/dir.go
  3. +3
    -3
      templates/repo/datasets/dirs/dir_list.tmpl
  4. +7
    -11
      templates/repo/datasets/dirs/index.tmpl

+ 3
- 0
modules/templates/helper.go View File

@@ -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)
},
}}
}



+ 8
- 7
routers/repo/dir.go View File

@@ -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)
}

+ 3
- 3
templates/repo/datasets/dirs/dir_list.tmpl View File

@@ -2,15 +2,15 @@
{{range .Dirs}}
<div class="ui grid item">
<div class="row">
<div class="six wide column">
<div class="ten wide column">
<a class="title" href="{{if .IsDir}}{{$.RepoLink}}/datasets/dirs/{{.UUID}}?parentDir={{.ParenDir}}{{end}}">
<span class="fitted">{{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}}</span> {{.FileName}}
<span class="fitted">{{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}}</span> {{.FileName}}
</a>
</div>
<div class="two wide column">
{{.Size | FileSize}}
</div>
<div class="six wide column">
<div class="four wide column">
<span>{{.ModTime}}</span>
</div>



+ 7
- 11
templates/repo/datasets/dirs/index.tmpl View File

@@ -5,24 +5,20 @@
<div class="ui stackable grid {{if .Error}}hide{{end}}" id="dir-content">
<div class="row">
<div class="column sixteen wide">
<h2>{{.Title}}</h2>
<p>
{{ range $index, $item := .Path }}
<a href='{{$.Link}}/?parentDir={{if gt $index 0}}{{DatasetPathJoin $.Path $index "/"}}{{else}}{{$item}}{{end}}'>{{ $item }}</a>/
{{ end }}
</p>
</div>
</div>
</div>

<div class="ui divider"></div>
<div class="ui grid">
<div class="row">
<div class="ui twelve wide column">
<div class="ui sixteen wide column">
<div class="ui two column stackable grid">
<div class="column">
<h2>{{.i18n.Tr "dataset.dir"}}</h2>
</div>
</div>
</div>
<div class="ui sixteen wide column">
<div class="dir list">
{{/* {{template "repo/datasets/dirs/dir_list" .}} */}}
{{template "repo/datasets/dirs/dir_list" .}}
</div>
</div>
</div>


Loading…
Cancel
Save