From c7cbdd34fb7ecb1c06ef00e17d0d289774899c5b Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Sat, 3 Jan 2015 22:03:41 +1030 Subject: [PATCH 01/38] Adjust MentionPattern to not match users mid-sentence (or email addresses) Fix link to user profile, update based on adjusted MentionPattern --- modules/base/markdown.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index b2f94c480..f18d459ff 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -100,7 +100,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, } var ( - MentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`) + MentionPattern = regexp.MustCompile(`(\s@)[0-9a-zA-Z_]{1,}`) commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`) issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`) issueIndexPattern = regexp.MustCompile(`#[0-9]+`) @@ -123,7 +123,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[1:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[2:], m)), -1) } } From 04d698bfbcb4ee584700e5ff3134dd74e1688c1b Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Sat, 3 Jan 2015 22:43:02 +1030 Subject: [PATCH 02/38] add some padding to markdown paragraphs --- public/ng/css/gogs.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index aa5afaec1..143b55b42 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -448,6 +448,9 @@ img.avatar-100 { margin: 15px 0; border-bottom: 2px solid #EEE; } +.markdown p { + margin: 20px 0; +} .markdown blockquote:last-child, .markdown ul:last-child, .markdown ol:last-child, From d0827e5d5ebc8713e7ba40f560617c3306007ed7 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Thu, 8 Jan 2015 09:16:38 -0500 Subject: [PATCH 03/38] allow http push by token - #842 --- models/token.go | 15 +++++++++++++++ routers/repo/http.go | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/models/token.go b/models/token.go index 909d05e07..9ad2d0517 100644 --- a/models/token.go +++ b/models/token.go @@ -62,6 +62,21 @@ func ListAccessTokens(uid int64) ([]*AccessToken, error) { return tokens, nil } +// ListAllAccessTokens returns all access tokens +func ListAllAccessTokens() ([]*AccessToken, error) { + tokens := make([]*AccessToken, 0, 5) + err := x.Desc("id").Find(&tokens) + if err != nil { + return nil, err + } + + for _, t := range tokens { + t.HasUsed = t.Updated.After(t.Created) + t.HasRecentActivity = t.Updated.Add(7 * 24 * time.Hour).After(time.Now()) + } + return tokens, nil +} + // DeleteAccessTokenById deletes access token by given ID. func DeleteAccessTokenById(id int64) error { _, err := x.Id(id).Delete(new(AccessToken)) diff --git a/routers/repo/http.go b/routers/repo/http.go index a5e01efc8..862974ce1 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -78,6 +78,7 @@ func Http(ctx *middleware.Context) { var askAuth = !isPublicPull || setting.Service.RequireSignInView var authUser *models.User var authUsername, passwd string + usedToken := false // check access if askAuth { @@ -103,15 +104,41 @@ func Http(ctx *middleware.Context) { authUser, err = models.GetUserByName(authUsername) if err != nil { - ctx.Handle(401, "no basic auth and digit auth", nil) - return + // check if a token was given instead of username + tokens, err := models.ListAllAccessTokens() + if err != nil { + ctx.Handle(401, "no basic auth and digit auth", nil) + return + } + + for _, token := range tokens { + if token.Sha1 == authUsername { + // get user belonging to token + authUser, err = models.GetUserById(token.Uid) + if err != nil { + ctx.Handle(401, "no basic auth and digit auth", nil) + return + } + authUsername = authUser.Name + usedToken = true + break + } + } + + if authUser == nil { + ctx.Handle(401, "no basic auth and digit auth", nil) + return + } } - newUser := &models.User{Passwd: passwd, Salt: authUser.Salt} - newUser.EncodePasswd() - if authUser.Passwd != newUser.Passwd { - ctx.Handle(401, "no basic auth and digit auth", nil) - return + // check password if token is not used + if !usedToken { + newUser := &models.User{Passwd: passwd, Salt: authUser.Salt} + newUser.EncodePasswd() + if authUser.Passwd != newUser.Passwd { + ctx.Handle(401, "no basic auth and digit auth", nil) + return + } } if !isPublicPull { From 1ab09e4f1b27789121dfba9a6c6e4aa0011ab215 Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Thu, 5 Feb 2015 12:12:37 +0200 Subject: [PATCH 04/38] Add option to provide configuration file on command line --- cmd/dump.go | 4 ++++ cmd/serve.go | 7 ++++++- cmd/update.go | 8 +++++++- cmd/web.go | 4 ++++ models/publickey.go | 4 ++-- models/repo.go | 4 ++-- modules/setting/setting.go | 14 +++++++++----- routers/install.go | 5 +++-- 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/cmd/dump.go b/cmd/dump.go index 3e1ccdb8a..57f1113ea 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -26,10 +26,14 @@ It can be used for backup and capture Gogs server image to send to maintainer`, Action: runDump, Flags: []cli.Flag{ cli.BoolFlag{"verbose, v", "show process details", ""}, + cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""}, }, } func runDump(ctx *cli.Context) { + if ctx.IsSet("config") { + setting.CustomConf = ctx.String("config") + } setting.NewConfigContext() models.LoadModelsConfig() models.SetEngine() diff --git a/cmd/serve.go b/cmd/serve.go index 239096234..7b593f40a 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -27,7 +27,9 @@ var CmdServ = cli.Command{ Usage: "This command should only be called by SSH shell", Description: `Serv provide access auth for repositories`, Action: runServ, - Flags: []cli.Flag{}, + Flags: []cli.Flag{ + cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""}, + }, } func setup(logPath string) { @@ -77,6 +79,9 @@ func In(b string, sl map[string]models.AccessType) bool { } func runServ(k *cli.Context) { + if k.IsSet("config") { + setting.CustomConf = k.String("config") + } setup("serv.log") keys := strings.Split(os.Args[2], "-") diff --git a/cmd/update.go b/cmd/update.go index cc55693e2..2ea7e942d 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -11,6 +11,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/setting" ) var CmdUpdate = cli.Command{ @@ -18,10 +19,15 @@ var CmdUpdate = cli.Command{ Usage: "This command should only be called by SSH shell", Description: `Update get pushed info and insert into database`, Action: runUpdate, - Flags: []cli.Flag{}, + Flags: []cli.Flag{ + cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""}, + }, } func runUpdate(c *cli.Context) { + if c.IsSet("config") { + setting.CustomConf = c.String("config") + } cmd := os.Getenv("SSH_ORIGINAL_COMMAND") if cmd == "" { return diff --git a/cmd/web.go b/cmd/web.go index 55b6bf087..ceb213444 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -55,6 +55,7 @@ and it takes care of all the other things for you`, Action: runWeb, Flags: []cli.Flag{ cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""}, + cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""}, }, } @@ -165,6 +166,9 @@ func newMacaron() *macaron.Macaron { } func runWeb(ctx *cli.Context) { + if ctx.IsSet("config") { + setting.CustomConf = ctx.String("config") + } routers.GlobalInit() checkVersion() diff --git a/models/publickey.go b/models/publickey.go index 67ab4242f..893ff5c96 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -29,7 +29,7 @@ import ( const ( // "### autogenerated by gitgos, DO NOT EDIT\n" - _TPL_PUBLICK_KEY = `command="%s serv key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n" + _TPL_PUBLICK_KEY = `command="%s serv --config=%s key-%d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n" ) var ( @@ -98,7 +98,7 @@ func (k *PublicKey) OmitEmail() string { // GetAuthorizedString generates and returns formatted public key string for authorized_keys file. func (key *PublicKey) GetAuthorizedString() string { - return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, key.Id, key.Content) + return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, setting.CustomConf, key.Id, key.Content) } var ( diff --git a/models/repo.go b/models/repo.go index b74582175..edd156133 100644 --- a/models/repo.go +++ b/models/repo.go @@ -30,7 +30,7 @@ import ( ) const ( - TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update $1 $2 $3\n" + TPL_UPDATE_HOOK = "#!/usr/bin/env %s\n%s update --config=%s $1 $2 $3\n" ) var ( @@ -424,7 +424,7 @@ func initRepository(f string, u *User, repo *Repository, initReadme bool, repoLa // hook/post-update if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"), - fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"")); err != nil { + fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, "\""+appPath+"\"", setting.CustomConf)); err != nil { return err } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index e7c44cdd4..79aaf7a06 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -124,6 +124,7 @@ var ( Cfg *ini.File ConfRootPath string CustomPath string // Custom directory path. + CustomConf string ProdMode bool RunUser string IsWindows bool @@ -172,13 +173,16 @@ func NewConfigContext() { CustomPath = path.Join(workDir, "custom") } - cfgPath := path.Join(CustomPath, "conf/app.ini") - if com.IsFile(cfgPath) { - if err = Cfg.Append(cfgPath); err != nil { - log.Fatal(4, "Fail to load custom 'conf/app.ini': %v", err) + if len(CustomConf) == 0 { + CustomConf = path.Join(CustomPath, "conf/app.ini") + } + + if com.IsFile(CustomConf) { + if err = Cfg.Append(CustomConf); err != nil { + log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err) } } else { - log.Warn("No custom 'conf/app.ini' found, ignore this if you're running first time") + log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf) } Cfg.NameMapper = ini.AllCapsUnderscore diff --git a/routers/install.go b/routers/install.go index 9c3f134d4..a3583a1a9 100644 --- a/routers/install.go +++ b/routers/install.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path" + "path/filepath" "strings" "github.com/Unknwon/com" @@ -221,8 +222,8 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { cfg.Section("security").Key("INSTALL_LOCK").SetValue("true") cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15)) - os.MkdirAll("custom/conf", os.ModePerm) - if err := cfg.SaveTo(path.Join(setting.CustomPath, "conf/app.ini")); err != nil { + os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm) + if err := cfg.SaveTo(setting.CustomConf); err != nil { ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form) return } From 2f40f614b5a833a72d21fdba01efa6e89cb33394 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Thu, 5 Feb 2015 15:56:48 +0300 Subject: [PATCH 05/38] fix css for del code --- public/ng/less/gogs/repository.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/ng/less/gogs/repository.less b/public/ng/less/gogs/repository.less index e48f5c871..f1345f891 100644 --- a/public/ng/less/gogs/repository.less +++ b/public/ng/less/gogs/repository.less @@ -653,12 +653,18 @@ background-color: #E0E0E0 !important; border-color: #ADADAD !important; } + td.selected-line, td.selected-line pre { + background-color: #ffffdd !important; + } } &.del-code { td, pre { background-color: #ffe2dd !important; border-color: #e9aeae !important; } + td.selected-line, td.selected-line pre { + background-color: #ffffdd !important; + } } &.add-code { td, pre { From 04adc94b26c588acb3ca6eac7c54426ee29d05b4 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Thu, 5 Feb 2015 16:02:37 +0300 Subject: [PATCH 06/38] fix css for same code --- public/ng/less/gogs/repository.less | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/ng/less/gogs/repository.less b/public/ng/less/gogs/repository.less index f1345f891..09691ee8b 100644 --- a/public/ng/less/gogs/repository.less +++ b/public/ng/less/gogs/repository.less @@ -657,6 +657,11 @@ background-color: #ffffdd !important; } } + &.same-code { + td.selected-line, td.selected-line pre { + background-color: #ffffdd !important; + } + } &.del-code { td, pre { background-color: #ffe2dd !important; From 16018e832394772591688a261646d3a80787ac9d Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 5 Feb 2015 08:22:59 -0500 Subject: [PATCH 07/38] public/ng/css: code generate for #907 --- public/ng/css/gogs.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index dc451a705..9a4440521 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -1620,11 +1620,23 @@ The register and sign-in page style background-color: #E0E0E0 !important; border-color: #ADADAD !important; } +.diff-file-box .code-diff tbody tr.tag-code td.selected-line, +.diff-file-box .code-diff tbody tr.tag-code td.selected-line pre { + background-color: #ffffdd !important; +} +.diff-file-box .code-diff tbody tr.same-code td.selected-line, +.diff-file-box .code-diff tbody tr.same-code td.selected-line pre { + background-color: #ffffdd !important; +} .diff-file-box .code-diff tbody tr.del-code td, .diff-file-box .code-diff tbody tr.del-code pre { background-color: #ffe2dd !important; border-color: #e9aeae !important; } +.diff-file-box .code-diff tbody tr.del-code td.selected-line, +.diff-file-box .code-diff tbody tr.del-code td.selected-line pre { + background-color: #ffffdd !important; +} .diff-file-box .code-diff tbody tr.add-code td, .diff-file-box .code-diff tbody tr.add-code pre { background-color: #d1ffd6 !important; From 79f328154841152d1add7d2035ff125a6ccc5e25 Mon Sep 17 00:00:00 2001 From: Raphael Randschau Date: Thu, 5 Feb 2015 17:09:26 +0100 Subject: [PATCH 08/38] Add ShowRegistrationButton configuration option --- modules/setting/setting.go | 2 ++ templates/admin/config.tmpl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index e7c44cdd4..4d407362c 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -311,6 +311,7 @@ func NewConfigContext() { var Service struct { RegisterEmailConfirm bool DisableRegistration bool + ShowRegistrationButton bool RequireSignInView bool EnableCacheAvatar bool EnableNotifyMail bool @@ -324,6 +325,7 @@ func newService() { Service.ActiveCodeLives = Cfg.Section("service").Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180) Service.ResetPwdCodeLives = Cfg.Section("service").Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180) Service.DisableRegistration = Cfg.Section("service").Key("DISABLE_REGISTRATION").MustBool() + Service.ShowRegistrationButton = Cfg.Section("service").Key("SHOW_REGISTRATION_BUTTON").MustBool() Service.RequireSignInView = Cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").MustBool() Service.EnableCacheAvatar = Cfg.Section("service").Key("ENABLE_CACHE_AVATAR").MustBool() Service.EnableReverseProxyAuth = Cfg.Section("service").Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool() diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 1f8a85ecb..f8b4be0b8 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -78,6 +78,8 @@
{{.i18n.Tr "admin.config.disable_register"}}
+
{{.i18n.Tr "admin.config.show_registration_button"}}
+
{{.i18n.Tr "admin.config.require_sign_in_view"}}
{{.i18n.Tr "admin.config.mail_notify"}}
From 3c65265871ce6d8305250ef870a751ebf47257ea Mon Sep 17 00:00:00 2001 From: Raphael Randschau Date: Thu, 5 Feb 2015 17:09:38 +0100 Subject: [PATCH 09/38] Hide the registration button depending on the setting --- routers/home.go | 1 + templates/home.tmpl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/routers/home.go b/routers/home.go index dd604ec7e..24fc77e12 100644 --- a/routers/home.go +++ b/routers/home.go @@ -41,6 +41,7 @@ func Home(ctx *middleware.Context) { ctx.Data["OauthEnabled"] = true ctx.Data["OauthService"] = setting.OauthService } + ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton ctx.Data["PageIsHome"] = true ctx.HTML(200, HOME) diff --git a/templates/home.tmpl b/templates/home.tmpl index 8603f26f4..29865dbf9 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -14,7 +14,9 @@ + {{if .ShowRegistrationButton}} + {{end}} + {{if $file.IsDeleted}} + {{$.i18n.Tr "repo.diff.view_file"}} + {{else}} {{$.i18n.Tr "repo.diff.view_file"}} + {{end}} {{$file.Name}} {{$isImage := (call $.IsImageFile $file.Name)}} From 066989722626deb9e0de1ea0cbe158aa387d8d26 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 6 Feb 2015 19:15:58 -0500 Subject: [PATCH 12/38] modules/base: fix markdown mention regex for #826 - conf/locale: add mew translator profile --- conf/locale/TRANSLATORS | 1 + gogs.go | 2 +- modules/base/markdown.go | 2 +- public/ng/css/gogs.css | 6 +- public/ng/less/gogs/markdown.less | 167 +++++++++++++++--------------- templates/.VERSION | 2 +- 6 files changed, 92 insertions(+), 88 deletions(-) diff --git a/conf/locale/TRANSLATORS b/conf/locale/TRANSLATORS index 6c72f3342..4cd8bf6a4 100644 --- a/conf/locale/TRANSLATORS +++ b/conf/locale/TRANSLATORS @@ -3,6 +3,7 @@ Akihiro YAGASAKI Christoph Kisfeld +Huimin Wang Thomas Fanninger Łukasz Jan Niemier Lafriks diff --git a/gogs.go b/gogs.go index 5e69bd68e..ce524af5a 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.12.0204 Beta" +const APP_VER = "0.5.12.0206 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 87aafda3e..412209861 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -106,7 +106,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, } var ( - MentionPattern = regexp.MustCompile(`(\s@)[0-9a-zA-Z_]{1,}`) + MentionPattern = regexp.MustCompile(`((^|\s)@)[0-9a-zA-Z_]{1,}`) commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`) issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`) issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`) diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index cf2b021df..1db8ee697 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -364,6 +364,9 @@ img.avatar-100 { .markdown table tr:nth-child(2n) { background-color: #F8F8F8; } +.markdown p { + margin: 20px 0; +} .markdown a { color: #428BCA; } @@ -448,9 +451,6 @@ img.avatar-100 { margin: 15px 0; border-bottom: 2px solid #EEE; } -.markdown p { - margin: 20px 0; -} .markdown blockquote:last-child, .markdown ul:last-child, .markdown ol:last-child, diff --git a/public/ng/less/gogs/markdown.less b/public/ng/less/gogs/markdown.less index e3abb480a..cd2eef99b 100644 --- a/public/ng/less/gogs/markdown.less +++ b/public/ng/less/gogs/markdown.less @@ -1,88 +1,91 @@ .markdown { - background-color: white; - font-size: 16px; - line-height: 24px; - .markdown-body { - padding-left: 24px; - padding-right: 16px; - } - h5, - h6 { - font-size: 1em; - } - ul { - padding: 10px 0 0 15px; - li { - list-style: inside; - } - } - ol li { - list-style: decimal inside; - } + background-color: white; + font-size: 16px; + line-height: 24px; + .markdown-body { + padding-left: 24px; + padding-right: 16px; + } + h5, + h6 { + font-size: 1em; + } + ul { + padding: 10px 0 0 15px; li { - line-height: 1.6; - margin-top: 6px; - &:first-child { - margin-top: 0; - } - } + list-style: inside; + } + } + ol li { + list-style: decimal inside; + } + li { + line-height: 1.6; + margin-top: 6px; + &:first-child { + margin-top: 0; + } + } + code { + padding: 0.2em 0.5em; + margin: 0; + background-color: rgba(0,0,0,0.04); + border-radius: 3px; + } + >pre { + font-size: 14px; + line-height: 1.6; + overflow: auto; + border: 1px solid #ddd; + border-radius: .25em; + margin: 5px 0; + padding: 10px; + background-color: #f8f8f8; code { - padding: 0.2em 0.5em; - margin: 0; - background-color: rgba(0,0,0,0.04); - border-radius: 3px; - } - >pre { - font-size: 14px; - line-height: 1.6; - overflow: auto; - border: 1px solid #ddd; - border-radius: .25em; - margin: 5px 0; - padding: 10px; - background-color: #f8f8f8; - code { - padding: 0; - background-color: inherit; - } - } - img { - padding: 10px 0; - max-width: 100%; - } - blockquote { - border-left: 4px solid #ddd; - margin-bottom: 16px; - p { - font-size: 14px; - padding: 5px 15px; - color: #777; - } - } - table { - display: block; - width: 100%; - overflow: auto; - word-break: normal; - margin: 15px 0; - border-collapse: collapse; - border-spacing: 0; - display: block; - th { - font-weight: 700; - } - th, td { - border: 1px solid #DDD; - padding: 6px 13px !important; - } - tr { - background-color: #FFF; - border-top: 1px solid #CCC; - &:nth-child(2n) { - background-color: #F8F8F8; - } - } - } + padding: 0; + background-color: inherit; + } + } + img { + padding: 10px 0; + max-width: 100%; + } + blockquote { + border-left: 4px solid #ddd; + margin-bottom: 16px; + p { + font-size: 14px; + padding: 5px 15px; + color: #777; + } + } + table { + display: block; + width: 100%; + overflow: auto; + word-break: normal; + margin: 15px 0; + border-collapse: collapse; + border-spacing: 0; + display: block; + th { + font-weight: 700; + } + th, td { + border: 1px solid #DDD; + padding: 6px 13px !important; + } + tr { + background-color: #FFF; + border-top: 1px solid #CCC; + &:nth-child(2n) { + background-color: #F8F8F8; + } + } + } + p { + margin: 20px 0; + } } .markdown a { color: #428BCA; diff --git a/templates/.VERSION b/templates/.VERSION index 40246b9ec..99de7de73 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.12.0204 Beta \ No newline at end of file +0.5.12.0206 Beta \ No newline at end of file From afccd0a3eeb070100b375cd9bb83cd5b213d01b3 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 6 Feb 2015 20:34:49 -0500 Subject: [PATCH 13/38] models/action.go: mirror fix on #892 - modules/base/markdown.go: fix issue link issue - routers/repo/view.go: remove useless code --- models/action.go | 22 ++++++++++++---------- modules/base/markdown.go | 4 ++-- routers/repo/view.go | 12 ------------ 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/models/action.go b/models/action.go index 318a5f6ad..ed90ad900 100644 --- a/models/action.go +++ b/models/action.go @@ -41,14 +41,14 @@ var ( var ( // Same as Github. See https://help.github.com/articles/closing-issues-via-commit-messages - IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} - IssueCloseKeywordsPat *regexp.Regexp + IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} + IssueCloseKeywordsPat *regexp.Regexp IssueReferenceKeywordsPat *regexp.Regexp ) func init() { IssueCloseKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(IssueCloseKeywords, "|"))) - IssueReferenceKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:) \S+`)) + IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`) } // Action represents user operation type and other information to repository., @@ -113,12 +113,14 @@ func (a Action) GetIssueInfos() []string { func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error { for _, c := range commits { references := IssueReferenceKeywordsPat.FindAllString(c.Message, -1) - + + // FIXME: should not be a reference when it comes with action. + // e.g. fixes #1 will not have duplicated reference message. for _, ref := range references { ref := ref[strings.IndexByte(ref, byte(' '))+1:] ref = strings.TrimRightFunc(ref, func(c rune) bool { - return !unicode.IsDigit(c) - }) + return !unicode.IsDigit(c) + }) if len(ref) == 0 { continue @@ -128,7 +130,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com if ref[0] == '#' { ref = fmt.Sprintf("%s/%s%s", repoUserName, repoName, ref) } else if strings.Contains(ref, "/") == false { - // We don't support User#ID syntax yet + // FIXME: We don't support User#ID syntax yet // return ErrNotImplemented continue @@ -153,8 +155,8 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com for _, ref := range closes { ref := ref[strings.IndexByte(ref, byte(' '))+1:] ref = strings.TrimRightFunc(ref, func(c rune) bool { - return !unicode.IsDigit(c) - }) + return !unicode.IsDigit(c) + }) if len(ref) == 0 { continue @@ -199,7 +201,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } } } - + } return nil diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 412209861..b5f397dce 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -177,8 +177,8 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte { func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte { ms := issueIndexPattern.FindAll(rawBytes, -1) for _, m := range ms { - rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf( - `%s`, urlPrefix, m[1:], m)), -1) + rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf(`%s`, + urlPrefix, strings.TrimPrefix(string(m[1:]), "#"), m)), -1) } return rawBytes } diff --git a/routers/repo/view.go b/routers/repo/view.go index cb689df6a..cfe0fa010 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -127,7 +127,6 @@ func Home(ctx *middleware.Context) { entries.Sort() files := make([][]interface{}, 0, len(entries)) - for _, te := range entries { if te.Type != git.COMMIT { c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) @@ -151,16 +150,6 @@ func Home(ctx *middleware.Context) { files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())}) } } - - // Render issue index links. - for _, f := range files { - switch c := f[1].(type) { - case *git.Commit: - c.CommitMessage = c.CommitMessage - case *git.SubModuleFile: - c.CommitMessage = c.CommitMessage - } - } ctx.Data["Files"] = files var readmeFile *git.Blob @@ -208,7 +197,6 @@ func Home(ctx *middleware.Context) { } lastCommit := ctx.Repo.Commit - lastCommit.CommitMessage = string(base.RenderIssueIndexPattern([]byte(lastCommit.CommitMessage), ctx.Repo.RepoLink)) if len(treePath) > 0 { c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath) if err != nil { From 5a99e9a37b1fa194675655e64d5f32ac6cf61729 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 6 Feb 2015 20:47:21 -0500 Subject: [PATCH 14/38] models/action.go: add action reopen for #462 - models/issue.go: format comment type names --- models/action.go | 79 +++++++++++++++++++++++++++++++++---------- models/issue.go | 26 ++++++-------- routers/repo/issue.go | 24 ++++++------- 3 files changed, 84 insertions(+), 45 deletions(-) diff --git a/models/action.go b/models/action.go index ed90ad900..34f543c4b 100644 --- a/models/action.go +++ b/models/action.go @@ -41,13 +41,20 @@ var ( var ( // Same as Github. See https://help.github.com/articles/closing-issues-via-commit-messages - IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} - IssueCloseKeywordsPat *regexp.Regexp - IssueReferenceKeywordsPat *regexp.Regexp + IssueCloseKeywords = []string{"close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"} + IssueReopenKeywords = []string{"reopen", "reopens", "reopened"} + + IssueCloseKeywordsPat, IssueReopenKeywordsPat *regexp.Regexp + IssueReferenceKeywordsPat *regexp.Regexp ) +func assembleKeywordsPattern(words []string) string { + return fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(words, "|")) +} + func init() { - IssueCloseKeywordsPat = regexp.MustCompile(fmt.Sprintf(`(?i)(?:%s) \S+`, strings.Join(IssueCloseKeywords, "|"))) + IssueCloseKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueCloseKeywords)) + IssueReopenKeywordsPat = regexp.MustCompile(assembleKeywordsPattern(IssueReopenKeywords)) IssueReferenceKeywordsPat = regexp.MustCompile(`(?i)(?:)(^| )\S+`) } @@ -112,11 +119,9 @@ func (a Action) GetIssueInfos() []string { func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error { for _, c := range commits { - references := IssueReferenceKeywordsPat.FindAllString(c.Message, -1) - // FIXME: should not be a reference when it comes with action. // e.g. fixes #1 will not have duplicated reference message. - for _, ref := range references { + for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) { ref := ref[strings.IndexByte(ref, byte(' '))+1:] ref = strings.TrimRightFunc(ref, func(c rune) bool { return !unicode.IsDigit(c) @@ -137,22 +142,18 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } issue, err := GetIssueByRef(ref) - if err != nil { return err } url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppSubUrl, repoUserName, repoName, c.Sha1) message := fmt.Sprintf(`%s`, url, c.Message) - - if _, err = CreateComment(userId, issue.RepoId, issue.Id, 0, 0, COMMIT, message, nil); err != nil { + if _, err = CreateComment(userId, issue.RepoId, issue.Id, 0, 0, COMMENT_TYPE_COMMIT, message, nil); err != nil { return err } } - closes := IssueCloseKeywordsPat.FindAllString(c.Message, -1) - - for _, ref := range closes { + for _, ref := range IssueCloseKeywordsPat.FindAllString(c.Message, -1) { ref := ref[strings.IndexByte(ref, byte(' '))+1:] ref = strings.TrimRightFunc(ref, func(c rune) bool { return !unicode.IsDigit(c) @@ -173,7 +174,6 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } issue, err := GetIssueByRef(ref) - if err != nil { return err } @@ -182,7 +182,6 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com if issue.IsClosed { continue } - issue.IsClosed = true if err = UpdateIssue(issue); err != nil { @@ -196,14 +195,60 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } // If commit happened in the referenced repository, it means the issue can be closed. - if _, err = CreateComment(userId, repoId, issue.Id, 0, 0, CLOSE, "", nil); err != nil { + if _, err = CreateComment(userId, repoId, issue.Id, 0, 0, COMMENT_TYPE_CLOSE, "", nil); err != nil { return err } } } - } + for _, ref := range IssueReopenKeywordsPat.FindAllString(c.Message, -1) { + ref := ref[strings.IndexByte(ref, byte(' '))+1:] + ref = strings.TrimRightFunc(ref, func(c rune) bool { + return !unicode.IsDigit(c) + }) + if len(ref) == 0 { + continue + } + + // Add repo name if missing + if ref[0] == '#' { + ref = fmt.Sprintf("%s/%s%s", repoUserName, repoName, ref) + } else if strings.Contains(ref, "/") == false { + // We don't support User#ID syntax yet + // return ErrNotImplemented + + continue + } + + issue, err := GetIssueByRef(ref) + if err != nil { + return err + } + + if issue.RepoId == repoId { + if !issue.IsClosed { + continue + } + issue.IsClosed = false + + if err = UpdateIssue(issue); err != nil { + return err + } else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil { + return err + } + + if err = ChangeMilestoneIssueStats(issue); err != nil { + return err + } + + // If commit happened in the referenced repository, it means the issue can be closed. + if _, err = CreateComment(userId, repoId, issue.Id, 0, 0, COMMENT_TYPE_REOPEN, "", nil); err != nil { + return err + } + } + } + } return nil } diff --git a/models/issue.go b/models/issue.go index c756e4975..d9a24063c 100644 --- a/models/issue.go +++ b/models/issue.go @@ -859,22 +859,16 @@ type CommentType int const ( // Plain comment, can be associated with a commit (CommitId > 0) and a line (Line > 0) - COMMENT CommentType = iota - - // Reopen action - REOPEN - - // Close action - CLOSE - - // Reference from another issue - ISSUE + COMMENT_TYPE_COMMENT CommentType = iota + COMMENT_TYPE_REOPEN + COMMENT_TYPE_CLOSE + // References. + COMMENT_TYPE_ISSUE // Reference from some commit (not part of a pull request) - COMMIT - + COMMENT_TYPE_COMMIT // Reference from some pull request - PULL + COMMENT_TYPE_PULL ) // Comment represents a comment in commit and issue page. @@ -908,7 +902,7 @@ func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType Commen // Check comment type. switch cmtType { - case COMMENT: + case COMMENT_TYPE_COMMENT: rawSql := "UPDATE `issue` SET num_comments = num_comments + 1 WHERE id = ?" if _, err := sess.Exec(rawSql, issueId); err != nil { sess.Rollback() @@ -929,13 +923,13 @@ func CreateComment(userId, repoId, issueId, commitId, line int64, cmtType Commen return nil, err } } - case REOPEN: + case COMMENT_TYPE_REOPEN: rawSql := "UPDATE `repository` SET num_closed_issues = num_closed_issues - 1 WHERE id = ?" if _, err := sess.Exec(rawSql, repoId); err != nil { sess.Rollback() return nil, err } - case CLOSE: + case COMMENT_TYPE_CLOSE: rawSql := "UPDATE `repository` SET num_closed_issues = num_closed_issues + 1 WHERE id = ?" if _, err := sess.Exec(rawSql, repoId); err != nil { sess.Rollback() diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 999fd0a89..3e0206daf 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -424,7 +424,7 @@ func ViewIssue(ctx *middleware.Context) { } comments[i].Poster = u - if comments[i].Type == models.COMMENT { + if comments[i].Type == models.COMMENT_TYPE_COMMENT { comments[i].Content = string(base.RenderMarkdown([]byte(comments[i].Content), ctx.Repo.RepoLink)) } } @@ -774,9 +774,9 @@ func Comment(ctx *middleware.Context) { } } - cmtType := models.CLOSE + cmtType := models.COMMENT_TYPE_CLOSE if !issue.IsClosed { - cmtType = models.REOPEN + cmtType = models.COMMENT_TYPE_REOPEN } if _, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.Id, 0, 0, cmtType, "", nil); err != nil { @@ -795,7 +795,7 @@ func Comment(ctx *middleware.Context) { if len(content) > 0 || len(ctx.Req.MultipartForm.File["attachments"]) > 0 { switch ctx.Params(":action") { case "new": - if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.Id, 0, 0, models.COMMENT, content, nil); err != nil { + if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.Id, 0, 0, models.COMMENT_TYPE_COMMENT, content, nil); err != nil { send(500, nil, err) return } @@ -1122,18 +1122,18 @@ func IssueGetAttachment(ctx *middleware.Context) { // testing route handler for new issue ui page // todo : move to Issue() function -func Issues2(ctx *middleware.Context){ - ctx.HTML(200,"repo/issue2/list") +func Issues2(ctx *middleware.Context) { + ctx.HTML(200, "repo/issue2/list") } -func PullRequest2(ctx *middleware.Context){ - ctx.HTML(200,"repo/pr2/list") +func PullRequest2(ctx *middleware.Context) { + ctx.HTML(200, "repo/pr2/list") } -func Labels2(ctx *middleware.Context){ - ctx.HTML(200,"repo/issue2/labels") +func Labels2(ctx *middleware.Context) { + ctx.HTML(200, "repo/issue2/labels") } -func Milestones2(ctx *middleware.Context){ - ctx.HTML(200,"repo/milestone2/list") +func Milestones2(ctx *middleware.Context) { + ctx.HTML(200, "repo/milestone2/list") } From 216683004e8bf3e7523236416be21b2123d32e8e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 6 Feb 2015 21:16:23 -0500 Subject: [PATCH 15/38] code fix for #908, and work for #884 --- modules/middleware/context.go | 2 ++ modules/setting/setting.go | 2 +- routers/home.go | 1 - templates/ng/base/header.tmpl | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/middleware/context.go b/modules/middleware/context.go index fc7814401..28be3a302 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -192,6 +192,8 @@ func Contexter() macaron.Handler { ctx.Data["CsrfToken"] = x.GetToken() ctx.Data["CsrfTokenHtml"] = template.HTML(``) + ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton + c.Map(ctx) } } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 4d407362c..e79e6d6b9 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -325,7 +325,7 @@ func newService() { Service.ActiveCodeLives = Cfg.Section("service").Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180) Service.ResetPwdCodeLives = Cfg.Section("service").Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180) Service.DisableRegistration = Cfg.Section("service").Key("DISABLE_REGISTRATION").MustBool() - Service.ShowRegistrationButton = Cfg.Section("service").Key("SHOW_REGISTRATION_BUTTON").MustBool() + Service.ShowRegistrationButton = Cfg.Section("service").Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration) Service.RequireSignInView = Cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").MustBool() Service.EnableCacheAvatar = Cfg.Section("service").Key("ENABLE_CACHE_AVATAR").MustBool() Service.EnableReverseProxyAuth = Cfg.Section("service").Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool() diff --git a/routers/home.go b/routers/home.go index 24fc77e12..dd604ec7e 100644 --- a/routers/home.go +++ b/routers/home.go @@ -41,7 +41,6 @@ func Home(ctx *middleware.Context) { ctx.Data["OauthEnabled"] = true ctx.Data["OauthService"] = setting.OauthService } - ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton ctx.Data["PageIsHome"] = true ctx.HTML(200, HOME) diff --git a/templates/ng/base/header.tmpl b/templates/ng/base/header.tmpl index aec4e2ef6..da9218368 100644 --- a/templates/ng/base/header.tmpl +++ b/templates/ng/base/header.tmpl @@ -49,10 +49,12 @@
  • {{.i18n.Tr "sign_in"}}
  • + {{if .ShowRegistrationButton}}
  • {{.i18n.Tr "register"}}
  • {{end}} + {{end}} {{end}} \ No newline at end of file From 3f2e99962cd466da2eb09fe4719f258e6f7a39e4 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 6 Feb 2015 21:29:15 -0500 Subject: [PATCH 16/38] conf/locale: update French locale --- conf/locale/locale_fr-CA.ini | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/conf/locale/locale_fr-CA.ini b/conf/locale/locale_fr-CA.ini index 06a810e55..ebe74e19b 100755 --- a/conf/locale/locale_fr-CA.ini +++ b/conf/locale/locale_fr-CA.ini @@ -61,7 +61,7 @@ domain=Domaine domain_helper=Cela affecte les doublons d'URL SSH. app_url=URL de l'Application app_url_helper=Cela affecte les doublons d'URL HTTP/HTTPS et le contenu d'e-mail. -email_title=E-mail Service Settings (Optional) +email_title=Paramètres du Service de Messagerie (Facultatif) smtp_host=Hôte SMTP mailer_user=E-mail de l'Expéditeur mailer_password=Mot de Passe de l'Expéditeur @@ -109,7 +109,7 @@ confirmation_mail_sent_prompt=Un nouveau mail de confirmation à été envoyé sign_in_email=Connexion avec l'E-mail active_your_account=Activer votre Compte resent_limit_prompt=Désolé, vos tentatives d'activation sont trop fréquentes. Veuillez réessayer dans 3 minutes. -has_unconfirmed_mail=Hi %s, you have an unconfirmed e-mail address %s). If you haven't received a confirmation e-mail or need to resend a new one, please click on the button below. +has_unconfirmed_mail=Bonjour %s, votre adresse courriel (%s) n'a pas été confirmée. Si vous n'avez reçu aucun courriel de confirmation ou souhaitez renouveler l'envoi, appuyez sur le bouton ci-dessous. resend_mail=Appuyez ici pour renvoyer un mail de confirmation email_not_associate=Cette adresse e-mail n'est associée à aucun compte. send_reset_mail=Appuyez ici pour (r)envoyer le mail de réinitialisation du mot de passe @@ -192,7 +192,7 @@ delete=Supprimer le Compte uid=ID d'Utilisateur public_profile=Profil Public -profile_desc=Your E-mail address is public and will be used for any account related notifications, and any web based operations made via the site. +profile_desc=Votre adresse e-mail est publique et sera utilisée pour les notifications relatives au compte, ainsi que pour toute opération Web effectuée via le site. full_name=Non Complet website=Site Web location=Localisation @@ -217,15 +217,15 @@ new_password=Nouveau Mot de Passe password_incorrect=Mot de passe actuel incorrect. change_password_success=Mot de passe modifié avec succès. Vous pouvez à présent vous connecter avec le nouveau mot de passe. -emails=E-mail Addresses -manage_emails=Manage e-mail addresses -email_desc=Your primary e-mail address will be used for notifications and other operations. -primary=Primary -primary_email=Set as primary -delete_email=Delete -add_new_email=Add new e-mail address -add_email=Add e-mail -add_email_success=Your new E-mail address was successfully added. +emails=Adresses E-mail +manage_emails=Gérer les adresses e-mail +email_desc=Votre adresse e-mail principale sera utilisée pour les notifications et d'autres opérations. +primary=Principale +primary_email=Définir comme principale +delete_email=Supprimer +add_new_email=Ajouter une nouvelle adresse courriel +add_email=Ajouter un courriel +add_email_success=Votre courriel a été ajouté avec succès. manage_ssh_keys=Gérer les clés SSH add_key=Ajouter une Clé @@ -414,7 +414,7 @@ release.tag_name_already_exist=Une publication avec ce nom de tag a déjà exist [org] org_name_holder=Nom d'organisation org_name_helper=Idéalement, un nom d'organisation devrait être court et mémorable. -org_email_helper=Organization's E-mail receives all notifications and confirmations. +org_email_helper=Le courriel de l'organisation recevra toutes les notifications et confirmations. create_org=Créer une organisation repo_updated=Mis à jour people=Contacts @@ -629,9 +629,8 @@ config.db_ssl_mode_helper=("postgres" uniquement) config.db_path=Emplacement config.db_path_helper=("sqlite3" uniquement) config.service_config=Configuration du Service -config.register_email_confirm=Require E-mail Confirmation +config.register_email_confirm=Nécessite une confirmation par courriel config.disable_register=Désactiver l'Enregistrement -config.show_registration_button = Affichage bouton Se inscrire config.require_sign_in_view=Connexion Obligatoire pour Visualiser config.mail_notify=Mailer les Notifications config.enable_cache_avatar=Activer le Cache d'Avatar From 2a2596fe615e4f18e0aff02cc8a016fea0463849 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 7 Feb 2015 10:46:57 -0500 Subject: [PATCH 17/38] able to disable SSH for #883 --- README.md | 2 +- README_ZH.md | 2 +- cmd/serve.go | 6 ++++++ conf/app.ini | 2 ++ gogs.go | 2 +- models/action.go | 2 -- models/repo.go | 4 ++-- modules/middleware/repo.go | 1 + modules/setting/setting.go | 6 ++++-- templates/.VERSION | 2 +- templates/repo/header.tmpl | 8 +++++--- 11 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3d87e3a1f..e93e599e7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Gogs(Go Git Service) is a painless self-hosted Git Service written in Go. ![Demo](http://gogs.qiniudn.com/gogs_demo.gif) -##### Current version: 0.5.12 Beta +##### Current version: 0.5.13 Beta ### NOTICES diff --git a/README_ZH.md b/README_ZH.md index be3a2b1bc..54e66315a 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个基于 Go 语言的自助 Git 服务。 ![Demo](http://gogs.qiniudn.com/gogs_demo.gif) -##### 当前版本:0.5.12 Beta +##### 当前版本:0.5.13 Beta ## 开发目的 diff --git a/cmd/serve.go b/cmd/serve.go index 239096234..1f5d944d4 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -33,6 +33,12 @@ var CmdServ = cli.Command{ func setup(logPath string) { setting.NewConfigContext() log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath)) + + if setting.DisableSSH { + println("Gogs: SSH has been disabled") + os.Exit(1) + } + models.LoadModelsConfig() if models.UseSQLite3 { diff --git a/conf/app.ini b/conf/app.ini index b7a0f1a7c..17d1a3b3b 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -18,6 +18,8 @@ DOMAIN = localhost ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/ HTTP_ADDR = HTTP_PORT = 3000 +; Disable SSH feature when not available +DISABLE_SSH = false SSH_PORT = 22 ; Disable CDN even in "prod" mode OFFLINE_MODE = false diff --git a/gogs.go b/gogs.go index ce524af5a..c09c4ca19 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.12.0206 Beta" +const APP_VER = "0.5.13.0207 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/action.go b/models/action.go index 34f543c4b..a6c6cfbfa 100644 --- a/models/action.go +++ b/models/action.go @@ -119,8 +119,6 @@ func (a Action) GetIssueInfos() []string { func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, commits []*base.PushCommit) error { for _, c := range commits { - // FIXME: should not be a reference when it comes with action. - // e.g. fixes #1 will not have duplicated reference message. for _, ref := range IssueReferenceKeywordsPat.FindAllString(c.Message, -1) { ref := ref[strings.IndexByte(ref, byte(' '))+1:] ref = strings.TrimRightFunc(ref, func(c rune) bool { diff --git a/models/repo.go b/models/repo.go index b74582175..3e07adba6 100644 --- a/models/repo.go +++ b/models/repo.go @@ -247,8 +247,8 @@ func (repo *Repository) CloneLink() (cl CloneLink, err error) { if err = repo.GetOwner(); err != nil { return cl, err } - if setting.SshPort != 22 { - cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SshPort, repo.Owner.LowerName, repo.LowerName) + if setting.SSHPort != 22 { + cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.Domain, setting.SSHPort, repo.Owner.LowerName, repo.LowerName) } else { cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.Domain, repo.Owner.LowerName, repo.LowerName) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index d143d8a86..1ab158dd6 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -386,6 +386,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner ctx.Data["IsRepositoryTrueOwner"] = ctx.Repo.IsTrueOwner + ctx.Data["DisableSSH"] = setting.DisableSSH ctx.Repo.CloneLink, err = repo.CloneLink() if err != nil { ctx.Handle(500, "CloneLink", err) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index e79e6d6b9..6a205921b 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -50,7 +50,8 @@ var ( Protocol Scheme Domain string HttpAddr, HttpPort string - SshPort int + DisableSSH bool + SSHPort int OfflineMode bool DisableRouterLog bool CertFile, KeyFile string @@ -209,7 +210,8 @@ func NewConfigContext() { Domain = sec.Key("DOMAIN").MustString("localhost") HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0") HttpPort = sec.Key("HTTP_PORT").MustString("3000") - SshPort = sec.Key("SSH_PORT").MustInt(22) + DisableSSH = sec.Key("DISABLE_SSH").MustBool() + SSHPort = sec.Key("SSH_PORT").MustInt(22) OfflineMode = sec.Key("OFFLINE_MODE").MustBool() DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool() StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) diff --git a/templates/.VERSION b/templates/.VERSION index 99de7de73..5a5ed364d 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.12.0206 Beta \ No newline at end of file +0.5.13.0207 Beta \ No newline at end of file diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 20e67db81..9e52efc72 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -18,9 +18,11 @@