From d4028619daa21565356ca3e06f468a7faae391dd Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 3 Mar 2022 10:49:06 +0800 Subject: [PATCH 1/6] #1250 add org topics --- models/org.go | 4 ++-- models/topic.go | 13 +++++++++++++ routers/org/home.go | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/models/org.go b/models/org.go index e8006d55f..85fb157ae 100755 --- a/models/org.go +++ b/models/org.go @@ -180,8 +180,8 @@ func CreateOrganization(org, owner *User) (err error) { // Add initial creator to organization and owner team. if _, err = sess.Insert(&OrgUser{ - UID: owner.ID, - OrgID: org.ID, + UID: owner.ID, + OrgID: org.ID, IsPublic: setting.Service.DefaultOrgMemberVisible, }); err != nil { return fmt.Errorf("insert org-user relation: %v", err) diff --git a/models/topic.go b/models/topic.go index 5533da7bc..e95e0ed40 100644 --- a/models/topic.go +++ b/models/topic.go @@ -324,3 +324,16 @@ func SaveTopics(repoID int64, topicNames ...string) error { return sess.Commit() } + +func GetOrgTopics(orgId int64) ([]Topic, error) { + result := make([]Topic, 0) + sql := "select t.* from repository r " + + "inner join repo_topic rt on rt.repo_id = r.id " + + "inner join topic t on rt.topic_id = t.id " + + "where r.owner_id = ? order by repo_count desc" + if e := x.SQL(sql, orgId).Find(&result); e != nil { + return nil, e + } + + return result, nil +} diff --git a/routers/org/home.go b/routers/org/home.go index c9769f559..3ffb4fd86 100755 --- a/routers/org/home.go +++ b/routers/org/home.go @@ -94,6 +94,13 @@ func Home(ctx *context.Context) { recommendCourseKeyWords, _ := repository.GetRecommendCourseKeyWords() ctx.Data["CoursesKeywords"] = recommendCourseKeyWords + } else { + orgTopics, err := models.GetOrgTopics(org.ID) + if err != nil { + ctx.Error(500, "GetOrgTopics failed") + return + } + ctx.Data["OrgTopics"] = orgTopics } repos, count, err = models.SearchRepository(&models.SearchRepoOptions{ From 109c9b013e1065054ef9882742b9154879048433 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 3 Mar 2022 10:58:17 +0800 Subject: [PATCH 2/6] #1250 add topic display limit --- models/topic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/topic.go b/models/topic.go index e95e0ed40..8abc76b9c 100644 --- a/models/topic.go +++ b/models/topic.go @@ -330,7 +330,7 @@ func GetOrgTopics(orgId int64) ([]Topic, error) { sql := "select t.* from repository r " + "inner join repo_topic rt on rt.repo_id = r.id " + "inner join topic t on rt.topic_id = t.id " + - "where r.owner_id = ? order by repo_count desc" + "where r.owner_id = ? order by repo_count desc limit 50" if e := x.SQL(sql, orgId).Find(&result); e != nil { return nil, e } From 1b0df114345125cdb0a11b1c681a9bd2dd569066 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 3 Mar 2022 11:20:04 +0800 Subject: [PATCH 3/6] #1250 inherit parent repo's topics when fork --- modules/repository/fork.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/repository/fork.go b/modules/repository/fork.go index da9039d00..e3ebbfee2 100644 --- a/modules/repository/fork.go +++ b/modules/repository/fork.go @@ -86,5 +86,11 @@ func ForkRepository(doer, owner *models.User, oldRepo *models.Repository, name, if err := models.CopyLanguageStat(oldRepo, repo); err != nil { log.Error("Copy language stat from oldRepo failed") } + //inherit parent repo's topics + if len(oldRepo.Topics) > 0 { + if err := models.SaveTopics(repo.ID, oldRepo.Topics...); err != nil { + log.Error("SaveTopics failed when fork,e=%v", err) + } + } return repo, models.CopyLFS(ctx, repo, oldRepo) } From e959e7ebd2f702137cb902a2c09799890ea2257f Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 3 Mar 2022 14:45:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix-1250=20=E7=BB=84=E7=BB=87=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E5=A2=9E=E5=8A=A0=E6=A0=87=E7=AD=BE?= 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 | 95 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0787e6ce6..042886633 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2088,6 +2088,7 @@ team_unit_disabled = (Disabled) selected_couse=Selected Courses release_course = Publish Course all_keywords=All keywords +all_org_topics=All max_selectedPro= Select up to 9 public projects custom_select_courses = Customize selected courses recommend_remain_pro = Remain @@ -2096,6 +2097,8 @@ select_again = Select more than 9, please select again! custom_select_projects = Customize selected projects customize = Customize selected_project=Selected Projects +fold = Fold +unfold = Unfold form.name_reserved = The organization name '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in an organization name. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 2eeb72735..982dc1a49 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2096,6 +2096,7 @@ team_unit_disabled=(已禁用) selected_couse=精选课程 release_course = 发布课程 all_keywords=全部关键字 +all_org_topics=全部 max_selectedPro= 最多可选9个公开项目 custom_select_courses = 自定义精选课程 recommend_remain_pro = 还能推荐 @@ -2104,6 +2105,8 @@ select_again = 选择超过9个,请重新选择! custom_select_projects = 自定义精选项目 customize = 自定义 selected_project=精选项目 +fold = 折叠 +unfold = 展开 form.name_reserved=组织名称 '%s' 是被保留的。 form.name_pattern_not_allowed=组织名称中不允许使用 "%s"。 diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 865a780a8..3e0dc0a8a 100755 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -1,3 +1,47 @@ + {{template "base/head" .}}
{{/* overflow: auto is the clearfix - this avoids the image going beyond @@ -23,21 +67,50 @@ {{template "org/navber" .}} {{template "org/select_pro" .}}
+ +
+
+
+ {{if .OrgTopics}} + {{$.i18n.Tr "org.all_org_topics"}} + {{end}} + + {{range .OrgTopics}} + {{if ne .Name ""}} + + {{.Name}} + + {{end}} + {{end}} +
+ + +
+
+
+
- {{if .CanCreateOrgRepo}} + {{template "org/repo_list" .}} {{template "base/paginate" .}}
-

+ {{if .CanCreateOrgRepo}} + + {{end}} +

{{.i18n.Tr "org.people"}}

{{template "base/footer" .}} + + \ No newline at end of file From d39ca502e639d727c20bfe2931604246401bf4aa Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Thu, 3 Mar 2022 14:54:17 +0800 Subject: [PATCH 5/6] #1250 fix bug --- models/topic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/topic.go b/models/topic.go index 8abc76b9c..0b19bc1f0 100644 --- a/models/topic.go +++ b/models/topic.go @@ -327,7 +327,7 @@ func SaveTopics(repoID int64, topicNames ...string) error { func GetOrgTopics(orgId int64) ([]Topic, error) { result := make([]Topic, 0) - sql := "select t.* from repository r " + + sql := "select distinct(t.*) from repository r " + "inner join repo_topic rt on rt.repo_id = r.id " + "inner join topic t on rt.topic_id = t.id " + "where r.owner_id = ? order by repo_count desc limit 50" From 0d1abe0beb43672a5916de3aff97b3707cb3af8e Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 3 Mar 2022 16:29:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix-1250=20=E4=BF=AE=E6=94=B9=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/org/home.tmpl | 50 +++-------------------------------------- templates/org/home_courses.tmpl | 28 ++++------------------- web_src/less/openi.less | 36 ++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 72 deletions(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 3e0dc0a8a..3ac59d079 100755 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -1,47 +1,3 @@ - {{template "base/head" .}}
{{/* overflow: auto is the clearfix - this avoids the image going beyond @@ -70,7 +26,7 @@
-
+
{{if .OrgTopics}} {{$.i18n.Tr "org.all_org_topics"}} {{end}} @@ -83,8 +39,8 @@ {{end}} {{end}}
- diff --git a/templates/org/home_courses.tmpl b/templates/org/home_courses.tmpl index 03ca8c41e..0f553687d 100644 --- a/templates/org/home_courses.tmpl +++ b/templates/org/home_courses.tmpl @@ -32,27 +32,13 @@ .organization-info >.container { padding-bottom:0px !important; } - .tag_bg{ - background-color: #0366D6 !important; - color:#FFFFFF !important; - } .course{ padding:10px 0 15px !important; } .course_color{ color: #FA8C16; } - .tag_lable{ - border: 1px solid rgba(232, 232, 232, 100) ; - border-radius: 4px; - color: rgba(65, 80, 88, 100); - font-family: Microsoft Yahei; - font-size: 14px; - padding: 0.3em 0.5em; - height: 30px; - text-align: center; - margin: 0.2em; - } + .tag_lable_first{ border: 1px solid rgba(232, 232, 232, 100) ; border-radius: 4px; @@ -65,17 +51,11 @@ margin: 0.2em; margin-left: none; } - .tag_key{ - max-width:100%; - margin: 3px 3px; - display:inline-flex; - } + .bpadding{ padding:10px 40px } - .omit{ - overflow: hidden; white-space: nowrap; text-overflow: ellipsis; - } + .noborder{ border: none !important; } @@ -83,7 +63,7 @@ text-align: center; margin-top: 5px; margin-top: 10px; - } + } diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 6598f5f40..ff43f94e6 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -734,4 +734,38 @@ display: block; } .el-pagination.is-background .el-pager li:hover { color: #5bb973 !important; - } \ No newline at end of file + } + +.tag_key{ + max-width:100%; + margin: 3px 3px; + display:inline-flex; +} +.tag_lable{ + border: 1px solid rgba(232, 232, 232, 100) ; + border-radius: 4px; + color: rgba(65, 80, 88, 100); + font-family: Microsoft Yahei; + font-size: 14px; + padding: 0.3em 0.5em; + height: 30px; + text-align: center; + margin: 0.2em; +} +.omit{ + overflow: hidden; white-space: nowrap; text-overflow: ellipsis; +} +.tag_bg{ + background-color: #0366D6 !important; + color:#FFFFFF !important; +} +.margin-top20{ + margin-top: 20px; +} +.maxheight{ + max-height: 88px; + overflow: hidden; +} +.pad-botom{ + padding-bottom:0px !important; +} \ No newline at end of file