|
|
@@ -1,6 +1,8 @@ |
|
|
|
package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"sort" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/auth" |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
@@ -35,31 +37,30 @@ func DatasetIndex(ctx *context.Context) { |
|
|
|
ctx.ServerError("GetDatasetAttachments", err) |
|
|
|
return |
|
|
|
} |
|
|
|
attachments := dataset.Attachments |
|
|
|
|
|
|
|
// var orderBy models.SearchOrderBy |
|
|
|
// page := ctx.QueryInt("page") |
|
|
|
// if page <= 0 { |
|
|
|
// page = 1 |
|
|
|
// } |
|
|
|
// ctx.Data["SortType"] = ctx.Query("sort") |
|
|
|
// switch ctx.Query("sort") { |
|
|
|
// case "newest": |
|
|
|
// orderBy = models.SearchOrderByNewest |
|
|
|
// case "oldest": |
|
|
|
// orderBy = models.SearchOrderByOldest |
|
|
|
// case "recentupdate": |
|
|
|
// orderBy = models.SearchOrderByRecentUpdated |
|
|
|
// case "leastupdate": |
|
|
|
// orderBy = models.SearchOrderByLeastUpdated |
|
|
|
// default: |
|
|
|
// ctx.Data["SortType"] = "recentupdate" |
|
|
|
// orderBy = models.SearchOrderByRecentUpdated |
|
|
|
// } |
|
|
|
ctx.Data["SortType"] = ctx.Query("sort") |
|
|
|
switch ctx.Query("sort") { |
|
|
|
case "newest": |
|
|
|
sort.Slice(attachments, func(i, j int) bool { |
|
|
|
return attachments[i].CreatedUnix > attachments[j].CreatedUnix |
|
|
|
}) |
|
|
|
case "oldest": |
|
|
|
sort.Slice(attachments, func(i, j int) bool { |
|
|
|
return attachments[i].CreatedUnix < attachments[j].CreatedUnix |
|
|
|
}) |
|
|
|
default: |
|
|
|
ctx.Data["SortType"] = "newest" |
|
|
|
sort.Slice(attachments, func(i, j int) bool { |
|
|
|
return attachments[i].CreatedUnix > attachments[j].CreatedUnix |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["PageIsDataset"] = true |
|
|
|
ctx.Data["Title"] = ctx.Tr("dataset.show_dataset") |
|
|
|
ctx.Data["Link"] = ctx.Repo.RepoLink + "/datasets" |
|
|
|
ctx.Data["dataset"] = dataset |
|
|
|
ctx.Data["Attachments"] = attachments |
|
|
|
ctx.Data["IsOwner"] = true |
|
|
|
|
|
|
|
ctx.HTML(200, tplIndex) |
|
|
|