diff --git a/README.md b/README.md index e947d7739..42eba6362 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language ![Demo](http://gowalker.org/public/gogs_demo.gif) -##### Current version: 0.1.6 Alpha +##### Current version: 0.1.7 Alpha #### Other language version @@ -27,7 +27,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o ## Features - Activity timeline -- SSH protocol support. +- SSH/HTTPS protocol support. - Register/delete account. - Create/delete/watch public repository. - User profile page. diff --git a/README_ZH.md b/README_ZH.md index 78e26fada..b405e0419 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。 ![Demo](http://gowalker.org/public/gogs_demo.gif) -##### 当前版本:0.1.6 Alpha +##### 当前版本:0.1.7 Alpha ## 开发目的 @@ -23,7 +23,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 ## 功能特性 - 活动时间线 -- SSH 协议支持 +- SSH/HTTPS 协议支持 - 注册/删除用户 - 创建/删除/关注公开仓库 - 用户个人信息页面 diff --git a/conf/app.ini b/conf/app.ini index b051557f4..ab9f6dc4b 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -32,6 +32,8 @@ PATH = data/gogs.db [admin] [security] +; Use HTTPS to clone repository, otherwise use HTTP. +ENABLE_HTTPS_CLONE = false ; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! SECRET_KEY = !#@FDEWREWR&*( ; Auto-login remember days diff --git a/gogs.go b/gogs.go index 0bdbbc069..09b28f9b3 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.1.6.0323.1" +const APP_VER = "0.1.7.0323.1" func init() { base.AppVer = APP_VER diff --git a/models/user.go b/models/user.go index 9333d1ee6..c9d6e6130 100644 --- a/models/user.go +++ b/models/user.go @@ -208,7 +208,7 @@ func UpdateUser(user *User) (err error) { user.Website = user.Website[:255] } - _, err = orm.Id(user.Id).UseBool().Cols("website", "location").Update(user) + _, err = orm.Id(user.Id).UseBool().Cols("website", "location", "is_active", "is_admin").Update(user) return err } diff --git a/modules/base/conf.go b/modules/base/conf.go index 19f587077..fba05e880 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -38,6 +38,8 @@ var ( RunUser string RepoRootPath string + EnableHttpsClone bool + LogInRememberDays int CookieUserName string CookieRememberName string @@ -260,6 +262,8 @@ func NewConfigContext() { SecretKey = Cfg.MustValue("security", "SECRET_KEY") RunUser = Cfg.MustValue("", "RUN_USER") + EnableHttpsClone = Cfg.MustBool("security", "ENABLE_HTTPS_CLONE", false) + LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS") CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") diff --git a/modules/base/tool.go b/modules/base/tool.go index b48566f54..6d31b0525 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -519,7 +519,7 @@ func ActionDesc(act Actioner, avatarLink string) string { buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n") } if push.Len > 3 { - buf.WriteString(fmt.Sprintf(`
%d other commits >>
`, actUserName, repoName, push.Len)) + buf.WriteString(fmt.Sprintf(`
%d other commits >>
`, actUserName, repoName, branch, push.Len)) } return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, branch, branch, actUserName, repoName, actUserName, repoName, buf.String()) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 3864caaf8..eea2570ca 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -69,8 +69,12 @@ func RepoAssignment(redirect bool) martini.Handler { ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id) } ctx.Repo.Repository = repo + scheme := "http" + if base.EnableHttpsClone { + scheme = "https" + } ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName) - ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("https://%s/%s/%s.git", base.Domain, user.LowerName, repo.LowerName) + ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName) ctx.Data["IsRepositoryValid"] = true ctx.Data["Repository"] = repo diff --git a/routers/admin/admin.go b/routers/admin/admin.go index c0f39f715..f1f951ef2 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -141,6 +141,7 @@ func Config(ctx *middleware.Context) { ctx.Data["Domain"] = base.Domain ctx.Data["RunUser"] = base.RunUser ctx.Data["RunMode"] = strings.Title(martini.Env) + ctx.Data["EnableHttpsClone"] = base.EnableHttpsClone ctx.Data["RepoRootPath"] = base.RepoRootPath ctx.Data["Service"] = base.Service diff --git a/routers/dashboard.go b/routers/dashboard.go index dafe9f31e..76ecc3f67 100644 --- a/routers/dashboard.go +++ b/routers/dashboard.go @@ -26,6 +26,6 @@ func Help(ctx *middleware.Context) { func NotFound(ctx *middleware.Context) { ctx.Data["PageIsNotFound"] = true - ctx.Data["Title"] = 404 + ctx.Data["Title"] = "Page Not Found" ctx.Handle(404, "home.NotFound", nil) } diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 048740e61..915c9dc08 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -17,6 +17,7 @@
Run User: {{.RunUser}}
Run Mode: {{.RunMode}}

+
Enable HTTPS Clone
Repository Root Path: {{.RepoRootPath}}
diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl index c2cafe0c9..b971f279a 100644 --- a/templates/status/404.tmpl +++ b/templates/status/404.tmpl @@ -4,5 +4,6 @@

404


Application Version: {{AppVer}}

+

If you think it is an error, please open an issue on GitHub.

{{template "base/footer" .}} \ No newline at end of file