From e1a4833ba1088dcd3cce041934cd87a9261851a9 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 21 Dec 2021 11:01:17 +0800 Subject: [PATCH 01/13] #981 1. submit tag 2. query tag repo list --- models/error.go | 13 +++++ models/models.go | 2 + models/repo_tag.go | 107 +++++++++++++++++++++++++++++++++++++++ modules/auth/org.go | 4 ++ routers/org/tag.go | 98 +++++++++++++++++++++++++++++++++++ routers/routes/routes.go | 4 ++ 6 files changed, 228 insertions(+) create mode 100644 models/repo_tag.go create mode 100644 routers/org/tag.go diff --git a/models/error.go b/models/error.go index 9d1c68658..46917e15e 100755 --- a/models/error.go +++ b/models/error.go @@ -1999,3 +1999,16 @@ func IsErrJobNotExist(err error) bool { func (err ErrJobNotExist) Error() string { return fmt.Sprintf("the job does not exist") } + +type ErrTagNotExist struct { + TagID int64 +} + +func (err ErrTagNotExist) Error() string { + return fmt.Sprintf("the tag does not exist") +} + +func IsErrTagNotExist(err error) bool { + _, ok := err.(ErrTagNotExist) + return ok +} diff --git a/models/models.go b/models/models.go index e8a71bbd8..a72ebe5db 100755 --- a/models/models.go +++ b/models/models.go @@ -134,6 +134,8 @@ func init() { new(BlockChain), new(RecommendOrg), new(AiModelManage), + new(OfficialTag), + new(OfficialTagRepos), ) tablesStatistic = append(tablesStatistic, diff --git a/models/repo_tag.go b/models/repo_tag.go new file mode 100644 index 000000000..6f3cc510f --- /dev/null +++ b/models/repo_tag.go @@ -0,0 +1,107 @@ +package models + +import ( + "code.gitea.io/gitea/modules/timeutil" + "fmt" +) + +const DefaultOrgTagLimit = -1 + +type OfficialTag struct { + ID int64 `xorm:"pk autoincr"` + Name string `xorm:"NOT NULL"` + Limit int `xorm:"NOT NULL default(-1)"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` + UpdatedUnix timeutil.TimeStamp `xorm:"updated"` +} + +type OfficialTagRepos struct { + ID int64 `xorm:"pk autoincr"` + OrgID int64 `xorm:"NOT NULL INDEX"` + TagID int64 `xorm:"NOT NULL"` + RepoID int64 `xorm:"NOT NULL INDEX"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` + UpdatedUnix timeutil.TimeStamp `xorm:"updated"` +} + +type TagReposBrief struct { + RepoID int64 + RepoName string + TagID int64 +} + +type TagReposSelected struct { + RepoID int64 + RepoName string + Selected bool +} + +func GetTagByID(id int64) (*OfficialTag, error) { + r := &OfficialTag{ + ID: id, + } + has, err := x.Get(r) + if err != nil { + return nil, err + } else if !has { + return nil, ErrTagNotExist{0} + } + return r, nil +} + +func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error { + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { + return fmt.Errorf("UpdateTagReposByID[tagId: %d, orgID: %d,error:%v", tagID, orgID, err) + } + //delete old tag repos + r := &OfficialTagRepos{ + TagID: tagID, + OrgID: orgID, + } + _, err := sess.Delete(r) + if err != nil { + return err + } + + //add new tag repos + data := make([]*OfficialTagRepos, 0) + for _, repoId := range repoIdList { + data = append(data, &OfficialTagRepos{ + OrgID: orgID, + TagID: tagID, + RepoID: repoId, + }) + } + _, err = sess.Insert(&data) + if err != nil { + sess.Rollback() + return err + } + return sess.Commit() +} + +func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) { + + t := make([]TagReposBrief, 0) + const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false" + + if err := x.SQL(SQLCmd, tagID, orgID).Find(&t); err != nil { + return nil, err + } + r := make([]TagReposSelected, 0) + for _, v := range t { + selected := false + if v.TagID > 0 { + selected = true + } + r = append(r, TagReposSelected{ + RepoID: v.RepoID, + RepoName: v.RepoName, + Selected: selected, + }) + } + return r, nil +} diff --git a/modules/auth/org.go b/modules/auth/org.go index 20e2b0999..9642e1ce6 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -70,3 +70,7 @@ type CreateTeamForm struct { func (f *CreateTeamForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { return validate(errs, ctx.Data, f, ctx.Locale) } + +type SubmitReposOfTagForm struct { + RepoList []int64 +} diff --git a/routers/org/tag.go b/routers/org/tag.go new file mode 100644 index 000000000..650d4690c --- /dev/null +++ b/routers/org/tag.go @@ -0,0 +1,98 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2020 The Gitea Authors. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package org + +import ( + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/auth" + "code.gitea.io/gitea/modules/context" + "errors" + "strconv" +) + +// SubmitTags submit repos of org tag +func SubmitTags(ctx *context.Context, form auth.SubmitReposOfTagForm) { + org, tag := getOrgAndTagFromContext(ctx) + if ctx.Written() { + return + } + + err := models.UpdateTagReposByID(tag.ID, org.ID, form.RepoList) + if err != nil { + ctx.ServerError("UpdateTagReposByID", err) + return + } + + ctx.JSON(200, map[string]interface{}{ + "code": "00", + "msg": "success", + }) +} + +// GetTagRepos get repos under org tag +func GetTagRepos(ctx *context.Context) { + org, tag := getOrgAndTagFromContext(ctx) + if ctx.Written() { + return + } + + r, err := models.GetTagRepos(tag.ID, org.ID) + if err != nil { + ctx.ServerError("GetTagRepos", err) + return + } + + ctx.JSON(200, map[string]interface{}{ + "code": "00", + "msg": "success", + "data": r, + }) +} + +// getDashboardContextUser finds out dashboard is viewing as which context user. +func getOrgAndTagFromContext(ctx *context.Context) (*models.User, *models.OfficialTag) { + + var org *models.User + var tag *models.OfficialTag + var err error + + orgName := ctx.Params(":org") + + if len(orgName) > 0 { + // Organization. + org, err = models.GetUserByName(orgName) + if err != nil { + if models.IsErrUserNotExist(err) { + ctx.NotFound("GetUserByName", err) + } else { + ctx.ServerError("GetUserByName", err) + } + return nil, nil + } + if !org.IsOrganization() { + ctx.ServerError("GetUserByName", errors.New("it is not an organization")) + return nil, nil + } + } + + tagIdStr := ctx.Query("tagId") + if len(tagIdStr) == 0 { + ctx.ServerError("GetTagInfo", errors.New("tag is not exist")) + return nil, nil + } + tagId, _ := strconv.ParseInt(tagIdStr, 10, 32) + tag, err = models.GetTagByID(tagId) + if err != nil { + if models.IsErrTagNotExist(err) { + ctx.NotFound("GetTagInfo", err) + } else { + ctx.ServerError("GetTagInfo", err) + } + return nil, nil + } + + return org, tag +} diff --git a/routers/routes/routes.go b/routers/routes/routes.go index cfd962603..c3a8b4abd 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -627,6 +627,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/org", func() { m.Group("/:org", func() { m.Get("/members", org.Members) + m.Group("/org_tag", func() { + m.Get("/repo_list", org.GetTagRepos) + m.Post("/repo_submit", bindIgnErr(auth.SubmitReposOfTagForm{}), org.SubmitTags) + }) }, context.OrgAssignment()) }) m.Group("/org", func() { From 74c9595aac9011cd5c115f22a4709527b92a0b83 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 21 Dec 2021 14:33:11 +0800 Subject: [PATCH 02/13] #981 add tag in org index --- models/repo_tag.go | 48 ++++++++++++++++++++++++++++++++++++++++++++- routers/org/home.go | 8 ++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/models/repo_tag.go b/models/repo_tag.go index 6f3cc510f..579a6cf5f 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -36,6 +36,24 @@ type TagReposSelected struct { Selected bool } +type TagsDetail struct { + TagId int64 + TagName string + RepoList []RepositoryForTag +} + +type RepositoryForTag struct { + TagId int64 + TagName string + ID int64 + Name string + Description string + NumWatches int + NumStars int + NumForks int + Topics []string +} + func GetTagByID(id int64) (*OfficialTag, error) { r := &OfficialTag{ ID: id, @@ -84,7 +102,6 @@ func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error { } func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) { - t := make([]TagReposBrief, 0) const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false" @@ -105,3 +122,32 @@ func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) { } return r, nil } + +func GetTagsDetails(orgID int64) ([]TagsDetail, error) { + t := make([]RepositoryForTag, 0) + const SQLCmd = "select t1.tag_id ,t3.name as tag_name,t2.* from official_tag_repos t1 inner join repository t2 on t1.repo_id = t2.id inner join official_tag t3 on t1.tag_id = t3.id where t1.org_id = ?" + + if err := x.SQL(SQLCmd, orgID).Find(&t); err != nil { + return nil, err + } + r := make([]TagsDetail, 0) + tempMap := make(map[int64]TagsDetail, 0) + for _, v := range t { + tagId := v.TagId + detail, ok := tempMap[tagId] + if !ok { + detail = TagsDetail{ + TagId: v.TagId, + TagName: v.TagName, + RepoList: make([]RepositoryForTag, 0), + } + } + detail.RepoList = append(detail.RepoList, v) + tempMap[tagId] = detail + } + + for _, v := range tempMap { + r = append(r, v) + } + return r, nil +} diff --git a/routers/org/home.go b/routers/org/home.go index b11c179c1..1a80f001f 100755 --- a/routers/org/home.go +++ b/routers/org/home.go @@ -130,5 +130,13 @@ func Home(ctx *context.Context) { pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager + //find org tag info + tags, err := models.GetTagsDetails(org.ID) + if err != nil { + ctx.ServerError("GetTagsDetails", err) + return + } + + ctx.Data["tags"] = tags ctx.HTML(200, tplOrgHome) } From 535835416b52439e50076f788452923c38d3115b Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 21 Dec 2021 15:08:28 +0800 Subject: [PATCH 03/13] #981 add sql --- models/migrations/migrations.go | 2 ++ models/migrations/v140.go | 31 +++++++++++++++++++++++++++++++ models/repo_tag.go | 1 + 3 files changed, 34 insertions(+) create mode 100644 models/migrations/v140.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 00d84da2e..e134a875e 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -212,6 +212,8 @@ var migrations = []Migration{ NewMigration("Add ResolveDoerID to Comment table", addResolveDoerIDCommentColumn), // v139 -> v140 NewMigration("prepend refs/heads/ to issue refs", prependRefsHeadsToIssueRefs), + // v140 -> v141 + NewMigration("init selected tag", initSelectedTag), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v140.go b/models/migrations/v140.go new file mode 100644 index 000000000..5684dba44 --- /dev/null +++ b/models/migrations/v140.go @@ -0,0 +1,31 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "code.gitea.io/gitea/models" + "xorm.io/xorm" +) + +func initSelectedTag(x *xorm.Engine) error { + p := &models.OfficialTag{ + Code: "Selected", + } + + ok, err := x.Get(p) + + if ok { + return nil + } + + t := &models.OfficialTag{ + ID: 1, + Code: "Selected", + Name: "精选项目", + Limit: 9, + } + _, err = x.Insert(t) + return err +} diff --git a/models/repo_tag.go b/models/repo_tag.go index 579a6cf5f..21e742082 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -10,6 +10,7 @@ const DefaultOrgTagLimit = -1 type OfficialTag struct { ID int64 `xorm:"pk autoincr"` Name string `xorm:"NOT NULL"` + Code string `xorm:"NOT NULL"` Limit int `xorm:"NOT NULL default(-1)"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` From 35fbd89eba87c547ca0f70a19c89e39d1335a091 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 21 Dec 2021 15:15:04 +0800 Subject: [PATCH 04/13] #981 delete sql --- models/migrations/migrations.go | 2 -- models/migrations/v140.go | 31 ------------------------------- 2 files changed, 33 deletions(-) delete mode 100644 models/migrations/v140.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index e134a875e..00d84da2e 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -212,8 +212,6 @@ var migrations = []Migration{ NewMigration("Add ResolveDoerID to Comment table", addResolveDoerIDCommentColumn), // v139 -> v140 NewMigration("prepend refs/heads/ to issue refs", prependRefsHeadsToIssueRefs), - // v140 -> v141 - NewMigration("init selected tag", initSelectedTag), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v140.go b/models/migrations/v140.go deleted file mode 100644 index 5684dba44..000000000 --- a/models/migrations/v140.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package migrations - -import ( - "code.gitea.io/gitea/models" - "xorm.io/xorm" -) - -func initSelectedTag(x *xorm.Engine) error { - p := &models.OfficialTag{ - Code: "Selected", - } - - ok, err := x.Get(p) - - if ok { - return nil - } - - t := &models.OfficialTag{ - ID: 1, - Code: "Selected", - Name: "精选项目", - Limit: 9, - } - _, err = x.Insert(t) - return err -} From 7e3f0d7994c392860087b3f550188bca755f7e9c Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 22 Dec 2021 10:55:42 +0800 Subject: [PATCH 05/13] #981 update --- models/repo_tag.go | 102 ++++++++++++++++++++++++++++++-------------- routers/org/home.go | 4 +- 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/models/repo_tag.go b/models/repo_tag.go index 21e742082..7abe0f1e7 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -1,6 +1,7 @@ package models import ( + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "fmt" ) @@ -12,6 +13,7 @@ type OfficialTag struct { Name string `xorm:"NOT NULL"` Code string `xorm:"NOT NULL"` Limit int `xorm:"NOT NULL default(-1)"` + Status int `xorm:"NOT NULL default(0)"` CreatedUnix timeutil.TimeStamp `xorm:"created"` UpdatedUnix timeutil.TimeStamp `xorm:"updated"` } @@ -40,21 +42,41 @@ type TagReposSelected struct { type TagsDetail struct { TagId int64 TagName string - RepoList []RepositoryForTag + TagLimit int + RepoList []Repository } type RepositoryForTag struct { - TagId int64 - TagName string - ID int64 - Name string - Description string - NumWatches int - NumStars int - NumForks int - Topics []string + TagId int64 + TagName string + Repo Repository } +// +//type RepositoryForTag struct { +// TagId int64 +// TagName string +// ID int64 +// Name string +// Description string +// NumWatches int +// NumStars int +// NumForks int +// Topics []string +// Link string +// OwnerName string +//} + +//// Link returns the repository link +//func (repo *RepositoryForTag) FullPath() string { +// return setting.AppSubURL + "/" + repo.FullName() +//} +// +//// FullName returns the repository full name +//func (repo *RepositoryForTag) FullName() string { +// return repo.OwnerName + "/" + repo.Name +//} + func GetTagByID(id int64) (*OfficialTag, error) { r := &OfficialTag{ ID: id, @@ -104,7 +126,7 @@ func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error { func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) { t := make([]TagReposBrief, 0) - const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false" + const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false order by t1.updated_unix desc" if err := x.SQL(SQLCmd, tagID, orgID).Find(&t); err != nil { return nil, err @@ -124,31 +146,47 @@ func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) { return r, nil } -func GetTagsDetails(orgID int64) ([]TagsDetail, error) { - t := make([]RepositoryForTag, 0) - const SQLCmd = "select t1.tag_id ,t3.name as tag_name,t2.* from official_tag_repos t1 inner join repository t2 on t1.repo_id = t2.id inner join official_tag t3 on t1.tag_id = t3.id where t1.org_id = ?" - - if err := x.SQL(SQLCmd, orgID).Find(&t); err != nil { +func GetAllOfficialTagRepos(orgID int64, isOwner bool) ([]TagsDetail, error) { + result := make([]TagsDetail, 0) + tags, err := GetAllOfficialTags() + if err != nil { return nil, err } - r := make([]TagsDetail, 0) - tempMap := make(map[int64]TagsDetail, 0) - for _, v := range t { - tagId := v.TagId - detail, ok := tempMap[tagId] - if !ok { - detail = TagsDetail{ - TagId: v.TagId, - TagName: v.TagName, - RepoList: make([]RepositoryForTag, 0), - } + for _, tag := range tags { + repos, err := GetOfficialTagDetail(orgID, tag.ID) + if err != nil { + return nil, err } - detail.RepoList = append(detail.RepoList, v) - tempMap[tagId] = detail + if len(repos) == 0 && !isOwner { + continue + } + result = append(result, TagsDetail{ + TagId: tag.ID, + TagName: tag.Name, + TagLimit: tag.Limit, + RepoList: repos, + }) } + return result, nil +} + +func GetOfficialTagDetail(orgID, tagId int64) ([]Repository, error) { + t := make([]Repository, 0) + const SQLCmd = "select t2.* from official_tag_repos t1 inner join repository t2 on t1.repo_id = t2.id where t1.org_id = ? and t1.tag_id=? order by t2.updated_unix desc" - for _, v := range tempMap { - r = append(r, v) + if err := x.SQL(SQLCmd, orgID, tagId).Find(&t); err != nil { + return nil, err } - return r, nil + return t, nil +} + +func GetAllOfficialTags() ([]OfficialTag, error) { + //todo redis? + o := make([]OfficialTag, 0) + err := x.Where("status = ?", 0).Find(&o) + if err != nil { + log.Error("GetAllOfficialTags error,%v", err) + return nil, err + } + return o, nil } diff --git a/routers/org/home.go b/routers/org/home.go index 1a80f001f..df600d96d 100755 --- a/routers/org/home.go +++ b/routers/org/home.go @@ -131,9 +131,9 @@ func Home(ctx *context.Context) { ctx.Data["Page"] = pager //find org tag info - tags, err := models.GetTagsDetails(org.ID) + tags, err := models.GetAllOfficialTagRepos(org.ID, ctx.Org.IsOwner) if err != nil { - ctx.ServerError("GetTagsDetails", err) + ctx.ServerError("GetAllOfficialTagRepos", err) return } From e6bda98499c61b4f6c795b2afae82a795177f999 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 22 Dec 2021 10:56:57 +0800 Subject: [PATCH 06/13] #981 update --- models/repo_tag.go | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/models/repo_tag.go b/models/repo_tag.go index 7abe0f1e7..ceac2850e 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -46,37 +46,6 @@ type TagsDetail struct { RepoList []Repository } -type RepositoryForTag struct { - TagId int64 - TagName string - Repo Repository -} - -// -//type RepositoryForTag struct { -// TagId int64 -// TagName string -// ID int64 -// Name string -// Description string -// NumWatches int -// NumStars int -// NumForks int -// Topics []string -// Link string -// OwnerName string -//} - -//// Link returns the repository link -//func (repo *RepositoryForTag) FullPath() string { -// return setting.AppSubURL + "/" + repo.FullName() -//} -// -//// FullName returns the repository full name -//func (repo *RepositoryForTag) FullName() string { -// return repo.OwnerName + "/" + repo.Name -//} - func GetTagByID(id int64) (*OfficialTag, error) { r := &OfficialTag{ ID: id, From 19fae465a37f0d65969cda8a870f53da91b86120 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Fri, 24 Dec 2021 11:35:59 +0800 Subject: [PATCH 07/13] #981 fix bug --- models/repo_tag.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/repo_tag.go b/models/repo_tag.go index ceac2850e..c8e675d75 100644 --- a/models/repo_tag.go +++ b/models/repo_tag.go @@ -76,6 +76,10 @@ func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error { return err } + if len(repoIdList) == 0 { + return sess.Commit() + } + //add new tag repos data := make([]*OfficialTagRepos, 0) for _, repoId := range repoIdList { From ad07b86e2a8afac88c35b48801c3d246bbb9f301 Mon Sep 17 00:00:00 2001 From: Gitea Date: Fri, 24 Dec 2021 12:41:26 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix-981=20=E7=BB=84=E7=BB=87=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E5=A2=9E=E5=8A=A0=E7=B2=BE=E9=80=89=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options/locale/locale_en-US.ini | 3 + options/locale/locale_zh-CN.ini | 3 + templates/org/home.tmpl | 9 +- templates/org/member/members.tmpl | 5 +- templates/org/navber.tmpl | 42 ++++- templates/org/select_pro.tmpl | 285 ++++++++++++++++++++++++++++++ templates/org/team/teams.tmpl | 6 +- 7 files changed, 339 insertions(+), 14 deletions(-) create mode 100644 templates/org/select_pro.tmpl diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b58021ea2..3a65d974d 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -222,6 +222,7 @@ contributors = Contributors [explore] repos = Repositories +select_repos = Select the project users = Users organizations = Organizations images = CloudImages @@ -234,6 +235,8 @@ org_no_results = No matching organizations found. code_no_results = No source code matching your search term found. code_search_results = Search results for '%s' code_last_indexed_at = Last indexed %s +save=save +cancel=cancel [auth] create_new_account = Register Account diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 7c821824d..ee7ca709a 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -224,6 +224,7 @@ contributors=贡献者 [explore] repos=项目 +select_repos=精选项目 users=用户 organizations=组织 images = 云脑镜像 @@ -238,6 +239,8 @@ org_no_results=未找到匹配的组织。 code_no_results=未找到与搜索字词匹配的源代码。 code_search_results=“%s” 的搜索结果是 code_last_indexed_at=最后索引于 %s +save=保存 +cancel=取消 [auth] create_new_account=注册帐号 diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 7e9970d2b..e03c28a9e 100755 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -20,10 +20,11 @@
-
- {{template "org/navber" .}} - -
+ {{template "org/navber" .}} + {{template "org/select_pro" .}} +
+ +
{{if .CanCreateOrgRepo}} diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 810a9eabb..87189c015 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -3,10 +3,11 @@ {{template "org/header" .}}
{{template "base/alert" .}} + {{template "org/navber" .}}
- {{template "org/navber" .}} + -
+
{{ range .Members}}
diff --git a/templates/org/navber.tmpl b/templates/org/navber.tmpl index 7bb2ff69c..f7e88c1e9 100755 --- a/templates/org/navber.tmpl +++ b/templates/org/navber.tmpl @@ -1,4 +1,4 @@ -
+ -
+ \ No newline at end of file +
--> + + + + \ No newline at end of file diff --git a/templates/org/select_pro.tmpl b/templates/org/select_pro.tmpl new file mode 100644 index 000000000..30da2385e --- /dev/null +++ b/templates/org/select_pro.tmpl @@ -0,0 +1,285 @@ + +
+
+ {{if .tags}} + + 精选项目 + + + {{if .IsOrganizationOwner}} + {{svg "octicon-gear" 16}}自定义 + {{end}} + {{end}} + +
+
+ {{ range .tags}} + {{if eq .TagName "精选项目"}} + +
+ {{ range .RepoList}} +
+ +
+
+ {{.Name}} +
+
+ {{.Description}} +
+ + +
+ {{if .Topics }} +
+ {{range .Topics}} + {{if ne . "" }}
{{.}}
{{end}} + {{end}} +
+ {{end}} +
+ + + + + +
+
+ {{end}} +
+ + {{end}} + {{end}} + +
+ +
+ + + + \ No newline at end of file diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 21bd47e9e..e7081b58f 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -3,12 +3,12 @@ {{template "org/header" .}}
{{template "base/alert" .}} - + {{template "org/navber" .}}
- {{template "org/navber" .}} + -
+
{{range .Teams}}
From 1fcaf468ccd9856d67ed978259a9455ae20eb759 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 27 Dec 2021 08:31:01 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/org/select_pro.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/org/select_pro.tmpl b/templates/org/select_pro.tmpl index 30da2385e..5d324d1e6 100644 --- a/templates/org/select_pro.tmpl +++ b/templates/org/select_pro.tmpl @@ -67,8 +67,8 @@
-
- {{.Name}} +
{{.Description}} From 1803d523b3dc07cc75e5c6bd9837580602e555ae Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 27 Dec 2021 09:04:53 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/org/select_pro.tmpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/org/select_pro.tmpl b/templates/org/select_pro.tmpl index 5d324d1e6..0bf0b08a6 100644 --- a/templates/org/select_pro.tmpl +++ b/templates/org/select_pro.tmpl @@ -44,6 +44,9 @@ .full_height{ height: 100%; } + /deep/ ui.checkbox input[type=checkbox]::after{ + border: 1px solid #0366D6 !important; + }
@@ -189,7 +192,7 @@ pro_html += '
' } else{ - pro_html += `
` + pro_html += `
` pro_html += '
' } } From 3e1159d0454439736e98c80c655c1e8132692618 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 27 Dec 2021 09:57:18 +0800 Subject: [PATCH 11/13] fix issue --- options/locale/locale_en-US.ini | 2 ++ options/locale/locale_zh-CN.ini | 2 ++ templates/repo/modelmanage/showinfo.tmpl | 44 ++++++++++++++---------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b58021ea2..597e9fbc5 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -900,6 +900,8 @@ model.manage.F1 = F1 model.manage.Precision = Precision model.manage.Recall = Recall model.manage.sava_model = Sava Model +model.manage.model_manage = ModelManage +model.manage.model_accuracy = Model Accuracy template.items = Template Items template.git_content = Git Content (Default Branch) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 7c821824d..286816260 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -910,6 +910,8 @@ model.manage.F1 = F1值 model.manage.Precision = 精确率 model.manage.Recall = 召回率 model.manage.sava_model = 保存模型 +model.manage.model_manage = 模型管理 +model.manage.model_accuracy = 模型精度 template.items=模板选项 template.git_content=Git数据(默认分支) diff --git a/templates/repo/modelmanage/showinfo.tmpl b/templates/repo/modelmanage/showinfo.tmpl index 8cdb08a32..d15efe4a0 100644 --- a/templates/repo/modelmanage/showinfo.tmpl +++ b/templates/repo/modelmanage/showinfo.tmpl @@ -69,7 +69,7 @@
- 模型精度 + {{$.i18n.Tr "repo.model.manage.model_accuracy"}} - + @@ -157,11 +161,11 @@ - + - + @@ -173,6 +177,7 @@ {{template "base/footer" .}}
准确率{{$.i18n.Tr "repo.model.manage.Accuracy"}}
精确率{{$.i18n.Tr "repo.model.manage.Precision"}}
召回率{{$.i18n.Tr "repo.model.manage.Recall"}}