From 24f16ee66a25468d8901dfa18a3bb9d560bd8131 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 25 Jan 2022 11:08:15 +0800 Subject: [PATCH 01/21] #1447 update notice --- modules/context/context.go | 10 +++++----- routers/notice/notice.go | 43 ++++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/modules/context/context.go b/modules/context/context.go index 6cb6c267a..25897d068 100755 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -45,8 +45,8 @@ type Context struct { IsSigned bool IsBasicAuth bool - Repo *Repository - Org *Organization + Repo *Repository + Org *Organization Cloudbrain *models.Cloudbrain } @@ -347,9 +347,9 @@ func Contexter() macaron.Handler { ctx.Data["EnableSwagger"] = setting.API.EnableSwagger ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn - notice, _ := notice.GetNewestNotice() - if notice != nil { - ctx.Data["notice"] = *notice + notices, _ := notice.GetNewestNotice() + if notices != nil { + ctx.Data["notices"] = notices } c.Map(ctx) } diff --git a/routers/notice/notice.go b/routers/notice/notice.go index f1e996e2d..5a39ee684 100644 --- a/routers/notice/notice.go +++ b/routers/notice/notice.go @@ -16,27 +16,31 @@ const ( ) type Notice struct { - Title string - Link string - Visible int //0 invisible, 1 visible + Title string + Link string + Visible int //0 invisible, 1 visible +} + +type NoticeResponse struct { + Notices []*Notice CommitId string } var lock int32 = 0 -func GetNewestNotice() (*Notice, error) { +func GetNewestNotice() (*NoticeResponse, error) { defer func() { if err := recover(); err != nil { log.Error("recover error", err) } }() - var notice *Notice + var notice *NoticeResponse var err error if setting.CacheOn { - notice, err = getNewestNoticeFromCacheAndDisk() + notice, err = getNewestNoticesFromCacheAndDisk() } else { - notice, err = getNewestNoticeFromDisk() + notice, err = getNewestNoticesFromDisk() } if err != nil { @@ -49,34 +53,39 @@ func getNoticeTimeout() time.Duration { return time.Duration(setting.CacheTimeOutSecond) * time.Second } -func getNewestNoticeFromDisk() (*Notice, error) { +func getNewestNoticesFromDisk() (*NoticeResponse, error) { log.Debug("Get notice from disk") - repoFile, err := models.ReadLatestFileInRepo(setting.UserNameOfNoticeRepo, setting.RepoNameOfNoticeRepo, setting.RefNameOfNoticeRepo, setting.TreePathOfNoticeRepo) + repo, err := models.GetRepositoryByOwnerAndAlias(setting.UserNameOfNoticeRepo, setting.RepoNameOfNoticeRepo) + if err != nil { + log.Error("get notice repo failed, error=%v", err) + return nil, err + } + repoFile, err := models.ReadLatestFileInRepo(repo.OwnerName, repo.Name, setting.RefNameOfNoticeRepo, setting.TreePathOfNoticeRepo) if err != nil { log.Error("GetNewestNotice failed, error=%v", err) return nil, err } - notice := &Notice{} - json.Unmarshal(repoFile.Content, notice) - if notice.Title == "" { + res := &NoticeResponse{} + json.Unmarshal(repoFile.Content, res) + if res == nil || len(res.Notices) == 0 { return nil, err } - notice.CommitId = repoFile.CommitId - return notice, nil + res.CommitId = repoFile.CommitId + return res, nil } -func getNewestNoticeFromCacheAndDisk() (*Notice, error) { +func getNewestNoticesFromCacheAndDisk() (*NoticeResponse, error) { v, success := noticeCache.Get(NOTICE_CACHE_KEY) if success { log.Debug("Get notice from cache,value = %v", v) if v == nil { return nil, nil } - n := v.(*Notice) + n := v.(*NoticeResponse) return n, nil } - notice, err := getNewestNoticeFromDisk() + notice, err := getNewestNoticesFromDisk() if err != nil { log.Error("GetNewestNotice failed, error=%v", err) noticeCache.Set(NOTICE_CACHE_KEY, nil, 30*time.Second) From 2be45b1f52b48ba3b33b2906f4e380ed97fc9821 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 26 Jan 2022 11:25:51 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/user/auth.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routers/user/auth.go b/routers/user/auth.go index 16af84b66..b4953beb3 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -143,6 +143,7 @@ func SignIn(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("sign_in") ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login" ctx.Data["PageIsSignIn"] = true + ctx.Data["IsCourse"] = ctx.QueryBool("course") ctx.Data["PageIsLogin"] = true ctx.Data["EnableSSPI"] = models.IsSSPIEnabled() ctx.Data["EnableCloudBrain"] = true @@ -565,6 +566,12 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR return setting.AppSubURL + "/dashboard" } + isCourse := ctx.QueryBool("course") + if isCourse { + redirectToCourse := setting.AppSubURL + "/" + setting.Course.OrgName + ctx.RedirectToFirst(redirectToCourse) + return redirectToCourse + } if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) { ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) if obeyRedirect { From c457cae8ef911f4f2361f4d0a1e4e3ffc0e8f732 Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 26 Jan 2022 12:46:37 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=83=E6=A0=A1?= =?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/base/head_navbar.tmpl | 12 +++++++++--- templates/org/home_courses.tmpl | 7 ++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index d8d9d50f2..9d63bcab5 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -215,9 +215,15 @@ {{svg "octicon-person" 16}} {{.i18n.Tr "register"}} {{end}} - - {{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}} - + {{if .IsCourse}} + + {{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}} + + {{else}} + + {{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}} + + {{end}} {{end}} diff --git a/templates/org/home_courses.tmpl b/templates/org/home_courses.tmpl index df164bd89..bd5f0f24e 100644 --- a/templates/org/home_courses.tmpl +++ b/templates/org/home_courses.tmpl @@ -136,11 +136,8 @@ From c24e6f28c809faa29ca8e5af61943502cce1007e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 26 Jan 2022 13:19:13 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/user/auth.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/user/auth.go b/routers/user/auth.go index b4953beb3..53a959f79 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -183,6 +183,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) { ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login" ctx.Data["PageIsSignIn"] = true ctx.Data["PageIsLogin"] = true + ctx.Data["IsCourse"] = ctx.QueryBool("course") ctx.Data["EnableSSPI"] = models.IsSSPIEnabled() if ctx.HasError() { From 8f2a1c6df24f2c70591ca2df9dca6a7c922744d9 Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 26 Jan 2022 15:24:58 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=B7=B3=E8=BD=AC=E5=B9=B3=E5=8F=B0=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_navbar.tmpl | 4 ++-- templates/org/home_courses.tmpl | 5 ++--- templates/user/auth/signin_inner.tmpl | 6 +++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 9d63bcab5..95fff82c3 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -216,11 +216,11 @@ {{end}} {{if .IsCourse}} - + {{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}} {{else}} - + {{svg "octicon-sign-in" 16}} {{.i18n.Tr "sign_in"}} {{end}} diff --git a/templates/org/home_courses.tmpl b/templates/org/home_courses.tmpl index bd5f0f24e..771b0169b 100644 --- a/templates/org/home_courses.tmpl +++ b/templates/org/home_courses.tmpl @@ -136,8 +136,7 @@ @@ -206,7 +205,7 @@ {{if .IsSigned}} {{.i18n.Tr "org.teams.join_teams"}} {{else}} - {{.i18n.Tr "org.teams.join_teams"}} + {{.i18n.Tr "org.teams.join_teams"}} {{end}} diff --git a/templates/user/auth/signin_inner.tmpl b/templates/user/auth/signin_inner.tmpl index a827bde9e..bdcd6a5c6 100644 --- a/templates/user/auth/signin_inner.tmpl +++ b/templates/user/auth/signin_inner.tmpl @@ -29,7 +29,11 @@
-
+ {{if .IsCourse}} + + {{else}} + + {{end}} {{.CsrfTokenHtml}}
From 72599d3e6dc02e7acc2c0c1b58aac3870974ffe9 Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 26 Jan 2022 15:44:21 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E5=8D=83=E6=A0=A1=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=BB=9D=E5=AF=B9=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_navbar.tmpl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 95fff82c3..4e9d265c8 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -211,9 +211,15 @@
{{if .ShowRegistrationButton}} - - {{svg "octicon-person" 16}} {{.i18n.Tr "register"}} - + {{if .IsCourse}} + + {{svg "octicon-person" 16}} {{.i18n.Tr "register"}} + + {{else}} + + {{svg "octicon-person" 16}} {{.i18n.Tr "register"}} + + {{end}} {{end}} {{if .IsCourse}} From 1cd3237dedbe66cd7f866782314b1cd4ad22fd57 Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 26 Jan 2022 16:33:03 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head.tmpl | 9 ++++++--- web_src/less/openi.less | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 859cacb62..2ffeec68c 100755 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -202,11 +202,14 @@ var _hmt = _hmt || [];
diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 39789d9d9..fd047ab30 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -604,10 +604,13 @@ display: block; font-weight: bold !important; } .a_width{ - width: 50% !important; + // width: 50% !important; + margin-right: 20em; display:inline-block !important; } - +.a_width i{ + vertical-align:middle; +} .footer_icon{ display: inline-block !important; vertical-align: middle !important; From 384553751756128b3cfd7b1879c144232a9076c1 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 26 Jan 2022 16:33:52 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/user/auth.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/routers/user/auth.go b/routers/user/auth.go index 53a959f79..2459602e7 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -116,8 +116,18 @@ func checkAutoLogin(ctx *context.Context) bool { } if isSucceed { - ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) - ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL)) + + isCourse := ctx.QueryBool("course") + if isCourse { + ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) + redirectToCourse := setting.AppSubURL + "/" + setting.Course.OrgName + ctx.RedirectToFirst(redirectToCourse) + + } else { + ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) + ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL)) + + } return true } From 36e7f266f1bd0f4909d59e54d543a284ab11eb92 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 26 Jan 2022 16:42:25 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/user/auth.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/routers/user/auth.go b/routers/user/auth.go index 2459602e7..a02cf24dc 100755 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -118,13 +118,11 @@ func checkAutoLogin(ctx *context.Context) bool { if isSucceed { isCourse := ctx.QueryBool("course") - if isCourse { - ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) + ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) + if redirectTo == "" && isCourse { redirectToCourse := setting.AppSubURL + "/" + setting.Course.OrgName ctx.RedirectToFirst(redirectToCourse) - } else { - ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true) ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL)) } From 83c2a080ae4bcb643004a9695afa9f52727db39d Mon Sep 17 00:00:00 2001 From: wangjr Date: Wed, 26 Jan 2022 16:43:13 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=83=E6=A0=A1?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=BB=84=E7=BB=87=E7=9A=84=E6=9C=AA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=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/home_courses.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/org/home_courses.tmpl b/templates/org/home_courses.tmpl index 771b0169b..dd287c87f 100644 --- a/templates/org/home_courses.tmpl +++ b/templates/org/home_courses.tmpl @@ -205,7 +205,7 @@ {{if .IsSigned}} {{.i18n.Tr "org.teams.join_teams"}} {{else}} - {{.i18n.Tr "org.teams.join_teams"}} + {{.i18n.Tr "org.teams.join_teams"}} {{end}}
From 32b80f365957cf3f452eb1e2f49b50546f41f893 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 26 Jan 2022 17:44:36 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/context/auth.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/context/auth.go b/modules/context/auth.go index 9877657eb..61a7b029b 100755 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -64,6 +64,11 @@ func Toggle(options *ToggleOptions) macaron.Handler { ctx.Redirect(setting.AppSubURL + "/") return } + + if ctx.QueryBool("course") { + ctx.Redirect(setting.AppSubURL + "/" + setting.Course.OrgName) + return + } } // Redirect to dashboard if user tries to visit any non-login page. From ee46a3122eaed40515dbac19330b9b9d10199c5f Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 27 Jan 2022 10:08:30 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=A4=9A=E5=85=AC?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head.tmpl | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 2ffeec68c..7a2fce2aa 100755 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -201,12 +201,15 @@ var _hmt = _hmt || []; {{template "base/head_navbar" .}} - @@ -232,7 +225,15 @@ var _hmt = _hmt || []; }else{ isNewNotice=false; } - if (JSON.parse("{{.notice.Visible}}")){ + let isShowNoticeTag = false; + let notices= {{.notices.Notices}} + for (i =0;i {{template "base/head_navbar" .}} - + {{template "base/head_notice" .}} {{end}} {{/* @@ -236,7 +229,15 @@ var _hmt = _hmt || []; }else{ isNewNotice=false; } - if (JSON.parse("{{.notice.Visible}}")){ + let isShowNoticeTag = false; + let notices= {{.notices.Notices}} + for (i =0;i +
+ + {{range .notices.Notices}} + + {{if eq .Visible 1}} + + {{.Title}} + {{end}} + + {{end}} + + +
+ +
+
+ + + {{end}} +{{end}} \ No newline at end of file diff --git a/templates/base/head_pro.tmpl b/templates/base/head_pro.tmpl index e6dbfc03e..85719cf9b 100644 --- a/templates/base/head_pro.tmpl +++ b/templates/base/head_pro.tmpl @@ -201,14 +201,7 @@ var _hmt = _hmt || []; - + {{template "base/head_notice" .}} {{end}} {{/* @@ -233,7 +226,15 @@ var _hmt = _hmt || []; }else{ isNewNotice=false; } - if (JSON.parse("{{.notice.Visible}}")){ + let isShowNoticeTag = false; + let notices= {{.notices.Notices}} + for (i =0;i Date: Thu, 27 Jan 2022 15:44:26 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_notice.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base/head_notice.tmpl b/templates/base/head_notice.tmpl index b9ca7ae17..6c52426bc 100644 --- a/templates/base/head_notice.tmpl +++ b/templates/base/head_notice.tmpl @@ -4,7 +4,7 @@
{{range .notices.Notices}} - + {{if eq .Visible 1}} {{.Title}} From ef05d62aa624b2d64078edda7a23345aa9908b4e Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 27 Jan 2022 16:03:57 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/org/course_list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/org/course_list.tmpl b/templates/org/course_list.tmpl index a4d140e46..310676b90 100644 --- a/templates/org/course_list.tmpl +++ b/templates/org/course_list.tmpl @@ -96,7 +96,7 @@ {{if .Topics }}
{{range .Topics}} - {{if ne . "" }}{{.}}{{end}} + {{if ne . "" }}{{.}}{{end}} {{end}}
From 8d5d8fb5d36d89c684f245b3b6c2e2ba89886d1d Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 27 Jan 2022 17:13:05 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA0=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=AE=B9=E4=B8=8D=E5=8D=A0=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_notice.tmpl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/base/head_notice.tmpl b/templates/base/head_notice.tmpl index 6c52426bc..2880b494d 100644 --- a/templates/base/head_notice.tmpl +++ b/templates/base/head_notice.tmpl @@ -4,12 +4,13 @@
{{range .notices.Notices}} - - {{if eq .Visible 1}} + {{if eq .Visible 1}} + {{.Title}} - {{end}} - + + {{end}} + {{end}} From c4a3d828684e5105b1c09973618bb5f3233b4c89 Mon Sep 17 00:00:00 2001 From: wangjr Date: Thu, 27 Jan 2022 17:44:16 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_notice.tmpl | 18 +++++++++++++----- web_src/less/openi.less | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/templates/base/head_notice.tmpl b/templates/base/head_notice.tmpl index 2880b494d..88615cc38 100644 --- a/templates/base/head_notice.tmpl +++ b/templates/base/head_notice.tmpl @@ -3,14 +3,22 @@
+ {{ $firstTag := true }} {{range .notices.Notices}} {{if eq .Visible 1}} - - - {{.Title}} - + {{if $firstTag}} + + + {{.Title}} + + {{else}} + + + {{.Title}} + + {{end}} + {{ $firstTag = false }} {{end}} - {{end}} diff --git a/web_src/less/openi.less b/web_src/less/openi.less index a4a812cce..1d165dda8 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -605,7 +605,7 @@ display: block; } .a_width{ // width: 50% !important; - margin-right: 20em; + margin-left: 20em; // display:inline-block !important; } .a_width i{ From b67274839a4384b9f60efc172ec96d06df3e98a9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 9 Feb 2022 18:00:04 +0800 Subject: [PATCH 19/21] fix 1483 --- web_src/js/components/ObsUploader.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 3b5bd3162..9da601b74 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -350,6 +350,17 @@ export default { etags[currentChunk] = res.headers.etag; } + async function uploadMinioNewMethod(url,e){ + var xhr = new XMLHttpRequest(); + xhr.open('PUT', url, false); + xhr.setRequestHeader('Content-Type', '') + xhr.send(e.target.result); + var etagValue = xhr.getResponseHeader('etag'); + //console.log(etagValue); + etags[currentChunk] = etagValue; + console.log(etagValue) + } + async function updateChunk(currentChunk) { await axios.post( '/attachments/update_chunk', @@ -372,7 +383,7 @@ export default { await getUploadChunkUrl(currentChunk, partSize); if (urls[currentChunk] != '') { // 上传到minio - await uploadMinio(urls[currentChunk], e); + await uploadMinioNewMethod(urls[currentChunk], e); if (etags[currentChunk] != '') { // 更新数据库:分片上传结果 //await updateChunk(currentChunk); From 29a77cdcf86991774c483c119a00b8b1d59902f9 Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 10 Feb 2022 11:12:00 +0800 Subject: [PATCH 20/21] fix bug:error happens when create repo by api --- models/repo.go | 3 +++ modules/structs/repo.go | 4 ++++ modules/validation/binding.go | 3 +++ routers/api/v1/repo/repo.go | 1 + 4 files changed, 11 insertions(+) diff --git a/models/repo.go b/models/repo.go index 5f90f97fc..6b3df9fe0 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1133,6 +1133,9 @@ func IsUsableRepoAlias(name string) error { // CreateRepository creates a repository for the user/organization. func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, opts ...CreateRepoOptions) (err error) { + if repo.Alias == "" { + repo.Alias = repo.Name + } repo.LowerAlias = strings.ToLower(repo.Alias) if err = IsUsableRepoName(repo.Name); err != nil { return err diff --git a/modules/structs/repo.go b/modules/structs/repo.go index e290488a4..6e9ece4b0 100755 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -100,6 +100,10 @@ type CreateRepoOption struct { // required: true // unique: true Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` + // Alias of the repository to create + // required: false + // unique: true + Alias string `json:"alias" binding:"AlphaDashDotChinese;MaxSize(100)"` // Description of the repository to create Description string `json:"description" binding:"MaxSize(255)"` // Whether the repository is private diff --git a/modules/validation/binding.go b/modules/validation/binding.go index b608cdea2..d52919475 100644 --- a/modules/validation/binding.go +++ b/modules/validation/binding.go @@ -128,6 +128,9 @@ func addAlphaDashDotChineseRule() { return strings.HasPrefix(rule, "AlphaDashDotChinese") }, IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { + if val == "" { + return true, errs + } if !ValidAlphaDashDotChinese(fmt.Sprintf("%v", val)) { errs.Add([]string{name}, ErrAlphaDashDotChinese, "ErrAlphaDashDotChinese") return false, errs diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index a724ebcc3..a85f88cb8 100755 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -232,6 +232,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR } repo, err := repo_service.CreateRepository(ctx.User, owner, models.CreateRepoOptions{ Name: opt.Name, + Alias: opt.Alias, Description: opt.Description, IssueLabels: opt.IssueLabels, Gitignores: opt.Gitignores, From e6855a4d63e143dd2ff71bcceefc1277d25323e9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 10 Feb 2022 15:05:06 +0800 Subject: [PATCH 21/21] multipart upload --- modules/storage/obs.go | 4 ++-- routers/repo/attachment.go | 2 +- web_src/js/components/ObsUploader.vue | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index a68bb7771..8e6b4201b 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -57,8 +57,8 @@ func ObsHasObject(path string) (bool, error) { return hasObject, nil } -func GetObsPartInfos(uuid string, uploadID string) (string, error) { - key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/") +func GetObsPartInfos(uuid, uploadID, fileName string) (string, error) { + key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") output, err := ObsCli.ListParts(&obs.ListPartsInput{ Bucket: setting.Bucket, diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 8443d6488..c2d096416 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -542,7 +542,7 @@ func GetSuccessChunks(ctx *context.Context) { log.Error("GetPartInfos failed:%v", err.Error()) } } else { - chunks, err = storage.GetObsPartInfos(fileChunk.UUID, fileChunk.UploadID) + chunks, err = storage.GetObsPartInfos(fileChunk.UUID, fileChunk.UploadID, fileName) if err != nil { log.Error("GetObsPartInfos failed:%v", err.Error()) } diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 9da601b74..b20594b86 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -355,10 +355,9 @@ export default { xhr.open('PUT', url, false); xhr.setRequestHeader('Content-Type', '') xhr.send(e.target.result); - var etagValue = xhr.getResponseHeader('etag'); + var etagValue = xhr.getResponseHeader('ETag'); //console.log(etagValue); etags[currentChunk] = etagValue; - console.log(etagValue) } async function updateChunk(currentChunk) {