Reviewed-by: berry <senluowanxiangt@gmail.com>master
@@ -1,6 +1,6 @@ | |||||
<div class="ui container" id="navbar"> | <div class="ui container" id="navbar"> | ||||
<div class="item brand" style="justify-content: space-between;"> | <div class="item brand" style="justify-content: space-between;"> | ||||
<a href="https://www.openi.org.cn/"> | |||||
<a href="/"> | |||||
<img class="ui mini image" src="{{StaticUrlPrefix}}/img/openi-logo-w.svg?v=2020041802"> | <img class="ui mini image" src="{{StaticUrlPrefix}}/img/openi-logo-w.svg?v=2020041802"> | ||||
</a> | </a> | ||||
<div class="ui basic icon button mobile-only" id="navbar-expand-toggle"> | <div class="ui basic icon button mobile-only" id="navbar-expand-toggle"> | ||||
@@ -21,7 +21,7 @@ | |||||
<a class="item" href="https://www.openi.org.cn/html/news/dongtai/">{{.i18n.Tr "custom.head.community_infos"}}</a> | <a class="item" href="https://www.openi.org.cn/html/news/dongtai/">{{.i18n.Tr "custom.head.community_infos"}}</a> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<a class="item" href="{{AppSubUrl}}/datasets">{{.i18n.Tr "datasets"}}</a> | |||||
<a class="item" href="{{AppSubUrl}}/explore/datasets">{{.i18n.Tr "datasets"}}</a> | |||||
<a class="item" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | ||||
{{if not .UnitIssuesGlobalDisabled}} | {{if not .UnitIssuesGlobalDisabled}} | ||||
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a> | <a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a> | ||||
@@ -37,7 +37,7 @@ | |||||
<i class="dropdown icon"></i> | <i class="dropdown icon"></i> | ||||
<div class="menu"> | <div class="menu"> | ||||
<a class="item" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | <a class="item" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | ||||
<a class="item" href="{{AppSubUrl}}/datasets">{{.i18n.Tr "datasets"}}</a> | |||||
<a class="item" href="{{AppSubUrl}}/explore/datasets">{{.i18n.Tr "custom.head.dataset"}}</a> | |||||
<a class="item" href="javascript:alert('WIP')">{{.i18n.Tr "custom.head.study"}}</a> | <a class="item" href="javascript:alert('WIP')">{{.i18n.Tr "custom.head.study"}}</a> | ||||
<a class="item" href="javascript:alert('WIP')">{{.i18n.Tr "custom.head.activity"}}</a> | <a class="item" href="javascript:alert('WIP')">{{.i18n.Tr "custom.head.activity"}}</a> | ||||
</div> | </div> | ||||
@@ -61,7 +61,7 @@ | |||||
<i class="dropdown icon"></i> | <i class="dropdown icon"></i> | ||||
<div class="menu"> | <div class="menu"> | ||||
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | <a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "custom.head.project"}}</a> | ||||
<a class="item" href="{{AppSubUrl}}/datasets">{{.i18n.Tr "datasets"}}</a> | |||||
<a class="item" href="{{AppSubUrl}}/explore/datasets">{{.i18n.Tr "datasets"}}</a> | |||||
<a class="item" href="javascript:alert('WIP')" target="_blank">{{.i18n.Tr "custom.head.project"}}</a> | <a class="item" href="javascript:alert('WIP')" target="_blank">{{.i18n.Tr "custom.head.project"}}</a> | ||||
<a class="item" href="javascript:alert('WIP')" target="_blank">{{.i18n.Tr "custom.head.activity"}}</a> | <a class="item" href="javascript:alert('WIP')" target="_blank">{{.i18n.Tr "custom.head.activity"}}</a> | ||||
</div> | </div> | ||||
@@ -0,0 +1,49 @@ | |||||
<h2 class="ui left floated medium header"> | |||||
{{.i18n.Tr "datasets"}} | |||||
</h2> | |||||
<div class="ui right floated secondary filter menu"> | |||||
<!-- Sort --> | |||||
<div class="ui right dropdown type jump item"> | |||||
<span class="text"> | |||||
{{.i18n.Tr "repo.issues.filter_sort"}} | |||||
<i class="dropdown icon"></i> | |||||
</span> | |||||
<div class="menu"> | |||||
<a class="{{if eq .SortType "newest"}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a> | |||||
<a class="{{if eq .SortType "oldest"}}active{{end}} item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a> | |||||
<a class="{{if eq .SortType "recentupdate"}}active{{end}} item" href="{{$.Link}}?sort=recentupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a> | |||||
<a class="{{if eq .SortType "leastupdate"}}active{{end}} item" href="{{$.Link}}?sort=leastupdate&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="ui clearing divider"></div> | |||||
<div class="ui dataset list"> | |||||
<div class="ui sixteen wide mobile ten wide tablet ten wide computer colum"> | |||||
{{range .Datasets}} | |||||
<div class="item"> | |||||
<div class="ui header"> | |||||
<a class="name" href="/datasets/{{.ID}}"> | |||||
{{.Title}} | |||||
</a> | |||||
<div class="ui right metas"> | |||||
<span class="text grey">{{svg "octicon-tasklist" 16}} {{$.i18n.Tr (printf "dataset.task.%s" .Task)}}</span> | |||||
<span class="text grey">{{svg "octicon-tag" 16}}{{$.i18n.Tr (printf "dataset.category.%s" .Category)}}</span> | |||||
{{if ne .DownloadTimes 0}} | |||||
<span class="text grey">{{svg "octicon-flame" 16}} {{.DownloadTimes}}</span> | |||||
{{end}} | |||||
</div> | |||||
</div> | |||||
<div class="description"> | |||||
<a><div class="ui small label topic">{{.Description}}</div></a> | |||||
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix $.i18n.Lang}}</p> | |||||
</div> | |||||
</div> | |||||
{{else}} | |||||
<div> | |||||
{{$.i18n.Tr "explore.dataset_no_results"}} | |||||
</div> | |||||
{{end}} | |||||
</div> | |||||
</div> |
@@ -0,0 +1,14 @@ | |||||
<div class="repos--seach"> | |||||
<div class="ui container"> | |||||
<div class="ui two column centered grid"> | |||||
<form class="mobile ten wide tablet computer column ui form ignore-dirty"> | |||||
<div class="ui fluid action input"> | |||||
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus> | |||||
<input type="hidden" name="tab" value="{{$.TabName}}"> | |||||
<input type="hidden" name="sort" value="{{$.SortType}}"> | |||||
<button class="ui blue button">{{.i18n.Tr "explore.search"}}</button> | |||||
</div> | |||||
</form> | |||||
</div> | |||||
</div> | |||||
</div> |
@@ -0,0 +1,17 @@ | |||||
{{template "base/head" .}} | |||||
<div class="explore repositories"> | |||||
{{template "explore/dataset_search" .}} | |||||
<div class="ui container"> | |||||
<div class="ui grid"> | |||||
{{template "explore/navbar" .}} | |||||
<div class="ui sixteen wide mobile ten wide tablet ten wide computer column"> | |||||
{{template "explore/dataset_list" .}} | |||||
{{template "base/paginate" .}} | |||||
</div> | |||||
<div class="ui sixteen wide mobile six wide tablet three wide computer column"> | |||||
{{template "explore/repo_right" .}} | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{template "base/footer" .}} |
@@ -3,6 +3,9 @@ | |||||
<a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos"> | <a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos"> | ||||
{{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} | {{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} | ||||
</a> | </a> | ||||
<a class="{{if .PageIsDatasets}}active{{end}} item" href="{{AppSubUrl}}/explore/datasets"> | |||||
{{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} | |||||
</a> | |||||
<a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users"> | <a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users"> | ||||
{{svg "octicon-person" 16}} {{.i18n.Tr "explore.users"}} | {{svg "octicon-person" 16}} {{.i18n.Tr "explore.users"}} | ||||
</a> | </a> | ||||
@@ -24,7 +27,7 @@ | |||||
<a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos"> | <a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos"> | ||||
{{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} | {{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} | ||||
</a> | </a> | ||||
<a class="{{if .PageIsDatasets}}active{{end}} item" href="{{AppSubUrl}}/datasets"> | |||||
<a class="{{if .PageIsDatasets}}active{{end}} item" href="{{AppSubUrl}}/explore/datasets"> | |||||
{{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} | {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} | ||||
</a> | </a> | ||||
<a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users"> | <a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users"> | ||||
@@ -1,10 +1,10 @@ | |||||
{{template "base/head" .}} | {{template "base/head" .}} | ||||
<div class="explore users"> | <div class="explore users"> | ||||
{{template "explore/search" .}} | {{template "explore/search" .}} | ||||
<div class="ui container"> | <div class="ui container"> | ||||
<div class="ui grid"> | <div class="ui grid"> | ||||
{{template "explore/navbar" .}} | |||||
{{template "explore/navbar" .}} | |||||
<div class="sixteen wide mobile ten wide tablet ten wide computer column"> | <div class="sixteen wide mobile ten wide tablet ten wide computer column"> | ||||
<h2 class="ui left floated medium header"> | <h2 class="ui left floated medium header"> | ||||
{{.i18n.Tr "explore.organizations"}} | {{.i18n.Tr "explore.organizations"}} | ||||
@@ -26,9 +26,9 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="ui clearing divider"></div> | <div class="ui clearing divider"></div> | ||||
<div class="ui user list"> | <div class="ui user list"> | ||||
{{range .Users}} | {{range .Users}} | ||||
<div class="item"> | <div class="item"> | ||||
@@ -59,7 +59,7 @@ | |||||
{{template "base/paginate" .}} | {{template "base/paginate" .}} | ||||
</div> | </div> | ||||
<div class="sixteen wide mobile six wide tablet four wide computer column"> | |||||
<div class="sixteen wide mobile six wide tablet three wide computer column"> | |||||
{{template "explore/repo_right" .}} | {{template "explore/repo_right" .}} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -53,7 +53,7 @@ | |||||
</div> | </div> | ||||
{{template "base/paginate" .}} | {{template "base/paginate" .}} | ||||
</div> | </div> | ||||
<div class="sixteen wide mobile six wide tablet four wide computer column"> | |||||
<div class="sixteen wide mobile six wide tablet three wide computer column"> | |||||
{{template "explore/repo_right" .}} | {{template "explore/repo_right" .}} | ||||
</div> | </div> | ||||
@@ -2448,6 +2448,7 @@ head.license= OpenI open source license | |||||
head.community_charter= OpenI Community Charter | head.community_charter= OpenI Community Charter | ||||
head.community_infos= Community News | head.community_infos= Community News | ||||
head.project= Project | head.project= Project | ||||
head.dataset= Dataset | |||||
head.study= Study | head.study= Study | ||||
head.activity= Activity | head.activity= Activity | ||||
foot.council= Council | foot.council= Council | ||||
@@ -2448,6 +2448,7 @@ head.license=启智开源许可证 | |||||
head.community_charter=启智社区章程 | head.community_charter=启智社区章程 | ||||
head.community_infos=社区动态 | head.community_infos=社区动态 | ||||
head.project=项目 | head.project=项目 | ||||
head.dataset=数据集 | |||||
head.study=学些 | head.study=学些 | ||||
head.activity=活动 | head.activity=活动 | ||||
foot.council=理事会 | foot.council=理事会 | ||||
@@ -25,6 +25,8 @@ const ( | |||||
tplHome base.TplName = "home" | tplHome base.TplName = "home" | ||||
// tplExploreRepos explore repositories page template | // tplExploreRepos explore repositories page template | ||||
tplExploreRepos base.TplName = "explore/repos" | tplExploreRepos base.TplName = "explore/repos" | ||||
// tplExploreDataset explore datasets page template | |||||
tplExploreDataset base.TplName = "explore/datasets" | |||||
// tplExploreUsers explore users page template | // tplExploreUsers explore users page template | ||||
tplExploreUsers base.TplName = "explore/users" | tplExploreUsers base.TplName = "explore/users" | ||||
// tplExploreOrganizations explore organizations page template | // tplExploreOrganizations explore organizations page template | ||||
@@ -188,6 +190,77 @@ func ExploreRepos(ctx *context.Context) { | |||||
}) | }) | ||||
} | } | ||||
func ExploreDatasets(ctx *context.Context) { | |||||
ctx.Data["Title"] = ctx.Tr("explore") | |||||
ctx.Data["PageIsExplore"] = true | |||||
ctx.Data["PageIsExploreDatasets"] = true | |||||
// ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled | |||||
var ( | |||||
datasets []*models.Dataset | |||||
count int64 | |||||
err error | |||||
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 | |||||
case "reversealphabetically": | |||||
orderBy = models.SearchOrderByAlphabeticallyReverse | |||||
case "alphabetically": | |||||
orderBy = models.SearchOrderByAlphabetically | |||||
case "reversesize": | |||||
orderBy = models.SearchOrderBySizeReverse | |||||
default: | |||||
ctx.Data["SortType"] = "recentupdate" | |||||
orderBy = models.SearchOrderByRecentUpdated | |||||
} | |||||
keyword := strings.Trim(ctx.Query("q"), " ") | |||||
var ownerID int64 | |||||
if ctx.User != nil && !ctx.User.IsAdmin { | |||||
ownerID = ctx.User.ID | |||||
} | |||||
opts := &models.SearchDatasetOptions{ | |||||
Keyword: keyword, | |||||
IncludePublic: true, | |||||
SearchOrderBy: orderBy, | |||||
OwnerID: ownerID, | |||||
ListOptions: models.ListOptions{ | |||||
Page: page, | |||||
PageSize: setting.UI.ExplorePagingNum, | |||||
}, | |||||
} | |||||
datasets, count, err = models.SearchDataset(opts) | |||||
if err != nil { | |||||
ctx.ServerError("SearchDatasets", err) | |||||
return | |||||
} | |||||
pager := context.NewPagination(int(count), opts.PageSize, page, 5) | |||||
pager.SetDefaultParams(ctx) | |||||
ctx.Data["Page"] = pager | |||||
ctx.Data["Keyword"] = opts.Keyword | |||||
ctx.Data["Datasets"] = datasets | |||||
ctx.Data["Total"] = count | |||||
ctx.Data["PageIsDatasets"] = true | |||||
ctx.HTML(200, tplExploreDataset) | |||||
} | |||||
// RenderUserSearch render user search page | // RenderUserSearch render user search page | ||||
func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplName base.TplName) { | func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplName base.TplName) { | ||||
opts.Page = ctx.QueryInt("page") | opts.Page = ctx.QueryInt("page") | ||||
@@ -291,6 +291,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
ctx.Redirect(setting.AppSubURL + "/explore/repos") | ctx.Redirect(setting.AppSubURL + "/explore/repos") | ||||
}) | }) | ||||
m.Get("/repos", routers.ExploreRepos) | m.Get("/repos", routers.ExploreRepos) | ||||
m.Get("/datasets", routers.ExploreDatasets) | |||||
m.Get("/users", routers.ExploreUsers) | m.Get("/users", routers.ExploreUsers) | ||||
m.Get("/organizations", routers.ExploreOrganizations) | m.Get("/organizations", routers.ExploreOrganizations) | ||||
m.Get("/code", routers.ExploreCode) | m.Get("/code", routers.ExploreCode) | ||||
@@ -1007,7 +1008,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
// DataSet | // DataSet | ||||
m.Group("/datasets", func() { | m.Group("/datasets", func() { | ||||
m.Get("", dataset.List) | |||||
// m.Get("", dataset.List) | |||||
m.Get("/create", dataset.Create) | m.Get("/create", dataset.Create) | ||||
m.Post("/create", bindIgnErr(auth.CreateDatasetForm{}), dataset.CreatePost) | m.Post("/create", bindIgnErr(auth.CreateDatasetForm{}), dataset.CreatePost) | ||||
m.Post("/delete", dataset.Delete) | m.Post("/delete", dataset.Delete) | ||||