+
- {{.i18n.Tr "repo.settings.transfer_desc"}}
+ +
+
- {{.i18n.Tr "repo.settings.delete_desc"}}
+ +
diff --git a/cmd/web.go b/cmd/web.go index bd2eb79db..995aeb04a 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -242,9 +242,8 @@ func runWeb(*cli.Context) { }, reqSignIn) m.Group("/:username/:reponame", func(r *macaron.Router) { - r.Get("/settings", repo.Setting) - r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost) - + r.Get("/settings", repo.Settings) + r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingsPost) m.Group("/settings", func(r *macaron.Router) { r.Get("/collaboration", repo.Collaboration) r.Post("/collaboration", repo.CollaborationPost) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index d25064a8f..29a61e7f5 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -56,6 +56,7 @@ sign_up_now = Need an account? Sign up now. [form] UserName = Username +RepoName = Repository name Email = E-mail address Password = Password Retype = Re-type password @@ -82,6 +83,9 @@ illegal_username = Your username contains illegal characters. illegal_repo_name = Repository name contains illegal characters. illegal_org_name = Organization name contains illegal characters. username_password_incorrect = Username or password is not correct. +enterred_invalid_repo_name = Please make sure you entered repository name is correct. +enterred_invalid_owner_name = Please make sure you entered owner name is correct. +enterred_invalid_password = Please make sure you entered passord is correct. invalid_ssh_key = Sorry, we're not able to verify your SSH key: %s auth_failed = Authentication failed: %v @@ -143,12 +147,34 @@ license = License license_helper = Select a license file init_readme = Initialize this repository with a README.md create_repo = Create Repository +default_branch = Default Branch +mirror_interval = Mirror Interval(hour) +goget_meta = Go-Get Meta +goget_meta_helper = This repository will be Go-Getable need_auth = Need Authorization migrate_type = Migration Type migrate_type_helper = This repository will be a Mirror migrate_repo = Migrate Repository +settings = Settings +settings.options = Options +settings.collaboration = Collaboration +settings.hooks = Webhooks +settings.deploy_keys = Deploy Keys +settings.basic_settings = Basic Settings +settings.danger_zone = Danger Zone +settings.site = Official Site +settings.update_settings = Update Settings +settings.transfer = Transfer Ownership +settings.transfer_desc = Transfer this repo to another user or to an organization where you have admin rights. +settings.delete = Delete This Repository +settings.delete_desc = Once you delete a repository, there is no going back. Please be certain. +settings.update_settings_success = Repository options has been successfully updated. +settings.transfer_owner = New Owner +settings.make_transfer = Make Transfer +settings.confirm_delete = Confirm Deletion + [org] org_name_holder = Organization Name org_name_helper = Great organization names are short and memorable. diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 8ed157e66..a2b184018 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -56,6 +56,7 @@ sign_up_now = 还没帐户?马上注册。 [form] UserName = 用户名 +RepoName = 仓库名称 Email = 邮箱地址 Password = 密码 Retype = 确认密码 @@ -82,6 +83,9 @@ illegal_username = 您的用户名包含非法字符。 illegal_repo_name = 仓库名称包含非法字符。 illegal_org_name = 组织名称包含非法字符。 username_password_incorrect = 用户名或密码不正确。 +enterred_invalid_repo_name = 请检查您输入的仓库名称是正确。 +enterred_invalid_owner_name = 请检查您输入的新所有者用户名是否正确。 +enterred_invalid_password = 请检查您输入的密码是否正确。 invalid_ssh_key = 很抱歉,我们无法验证您输入的 SSH 密钥:%s auth_failed = 授权验证失败:%v @@ -143,12 +147,34 @@ license = 授权许可 license_helper = 请选择授权许可文件 init_readme = 使用 README.md 文件初始化仓库 create_repo = 创建仓库 +default_branch = 默认分支 +mirror_interval = 镜像同步周期(小时) +goget_meta = Go-Get 支持 +goget_meta_helper = 本仓库将可以通过 Go Get 获取 need_auth = 需要授权验证 migrate_type = 迁移类型 migrate_type_helper = 本仓库将是 镜像 migrate_repo = 迁移仓库 +settings = 仓库设置 +settings.options = 基本设置 +settings.collaboration = 管理协作者 +settings.hooks = 管理 Web 钩子 +settings.deploy_keys = 管理部署密钥 +settings.basic_settings = 基本设置 +settings.danger_zone = 危险操作区 +settings.site = 官方网站 +settings.update_settings = 更新仓库设置 +settings.transfer = 转移仓库所有权 +settings.transfer_desc = 您可以将仓库转移至您拥有管理员权限的帐户或组织。 +settings.delete = 删除本仓库 +settings.delete_desc = 删除仓库操作不可逆转,请三思而后行。 +settings.update_settings_success = 仓库设置更新成功! +settings.transfer_owner = 新拥有者 +settings.make_transfer = 确认转移仓库 +settings.confirm_delete = 确认删除仓库 + [org] org_name_holder = 组织名称 org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。 diff --git a/gogs.go b/gogs.go index 77a9b1b75..42d15db43 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.4.7.0801 Alpha" +const APP_VER = "0.4.7.0802 Alpha" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/user.go b/models/user.go index ca772556b..f4526b51d 100644 --- a/models/user.go +++ b/models/user.go @@ -116,6 +116,13 @@ func (u *User) EncodePasswd() { u.Passwd = fmt.Sprintf("%x", newPasswd) } +// ValidtePassword checks if given password matches the one belongs to the user. +func (u *User) ValidtePassword(passwd string) bool { + newUser := &User{Passwd: passwd, Salt: u.Salt} + newUser.EncodePasswd() + return u.Passwd == newUser.Passwd +} + // IsOrganization returns true if user is actually a organization. func (u *User) IsOrganization() bool { return u.Type == ORGANIZATION diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 12bf5df50..a6c71e99e 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -48,7 +48,7 @@ func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs *binding.Errors, l } type RepoSettingForm struct { - RepoName string `form:"name" binding:"Required;AlphaDash;MaxSize(100)"` + RepoName string `form:"repo_name" binding:"Required;AlphaDash;MaxSize(100)"` Description string `form:"desc" binding:"MaxSize(255)"` Website string `form:"site" binding:"Url;MaxSize(100)"` Branch string `form:"branch"` diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 5300539d4..1e6f8e952 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -96,9 +96,9 @@ func (ctx *Context) HasError() bool { return hasErr.(bool) } -// HTML calls render.HTML underlying but reduce one argument. +// HTML calls Context.HTML and converts template name to string. func (ctx *Context) HTML(status int, name base.TplName) { - ctx.Render.HTML(status, string(name), ctx.Data) + ctx.Context.HTML(status, string(name)) } // RenderWithErr used for page has form validation but need to prompt error to users. diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index b9eea52d2..938610af7 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -851,6 +851,7 @@ The register and sign-in page style color: #888888; font-size: 1.6em; font-weight: normal; + margin-bottom: 0; } #repo-header-name i { margin-right: 12px; @@ -1211,6 +1212,9 @@ The register and sign-in page style .code-view .lines-code > pre > ol.linenums > li.active { background: #ffffdd; } +.repo-setting-zone { + padding: 30px; +} #setting-wrapper { padding-bottom: 100px; } @@ -1237,17 +1241,27 @@ The register and sign-in page style .setting-content { margin-left: 32px; } +#repo-setting-form, #user-profile-form { background-color: #FFF; padding: 30px 0; } +#repo-setting-form textarea, +#user-profile-form textarea { + margin-left: 4px; + height: 100px; +} +#repo-setting-form label, #user-profile-form label, +#repo-setting-form .form-label, #user-profile-form .form-label { width: 240px; } +#repo-setting-form .ipt, #user-profile-form .ipt { width: 360px; } +#repo-setting-form .field, #user-profile-form .field { margin-bottom: 24px; } @@ -1298,3 +1312,101 @@ The register and sign-in page style #user-ssh-add-form .field { margin-bottom: 24px; } +.repo-issue-wrapper { + padding: 18px 0; +} +.pr-main { + padding-right: 40px; + box-sizing: border-box; +} +.pr-sidebar { + border-left: 1px solid #DDD; + box-sizing: border-box; +} +#pr-sidebar-nav { + margin-top: 6px; +} +#pr-sidebar-nav li { + margin-bottom: 4px; +} +#pr-sidebar-nav li > a { + border: 1px solid transparent; + border-left: none; +} +#pr-sidebar-nav li > a:hover { + background-color: #FFF; + border-color: #DDD; +} +#pr-sidebar-nav .label { + font-size: 12px; + line-height: 1.4em; + margin-top: 1px; +} +#pr-sidebar-nav li.current a { + background-color: #FFF; + border-color: #DDD; +} +.pr-title .pr-num { + font-weight: normal; + color: #888; +} +.pr-meta { + color: #888; +} +.pr-meta .pr-author { + margin: 0 8px; + color: #444; +} +.pr-meta .pr-author:hover { + text-decoration: underline; +} +.pr-meta .pr-branch { + margin: 0 4px; + font-size: 12px; + padding: 4px 6px; +} +.pr-nav { + border-bottom: 1px solid #DDD; + margin-top: 16px; +} +.pr-nav .octicon { + margin-right: 4px; +} +.pr-nav li > a { + padding: 3px 9px !important; + border: 1px solid transparent; + border-bottom: none; + border-top-left-radius: .2em; + border-top-right-radius: .2em; +} +.pr-nav li > a .label { + padding: 1px 5px; + font-size: 12px; + margin-left: 4px; +} +.pr-nav li.current > a { + background-color: #FFF; + border-color: #E6E6E6; +} +.diff-bar .diff-add { + color: #65ad4e; +} +.diff-bar .diff-delete { + color: #d9453d; +} +.diff-bar .diff-status { + width: 50px; + background-color: #d9453d; + height: 10px; + margin-top: 7px; + margin-left: 4px; + margin-right: 4px; + border-radius: .2em; +} +.diff-bar .diff-status-inner { + width: 45%; + background-color: #65ad4e; + height: 10px; + border-top-left-radius: .2em; + border-bottom-left-radius: .2em; +} diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index f32261234..5a5f7dc90 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -173,12 +173,14 @@ svg:not(:root) { label { font-weight: bold; } +textarea, input, .ipt { padding: .6em; line-height: normal; border: 1px solid #bbbbbb; } +textarea:focus, input:focus, .ipt:focus { background-color: #f2fffc; @@ -290,6 +292,9 @@ pre { overflow: auto; padding: 0; } +dt { + font-weight: bold; +} .left { float: left; } @@ -651,6 +656,9 @@ ul.menu-radius > li:last-child > a { background-color: #eeeeee; border-bottom: 1px solid #cccccc; } +.panel .panel-body { + background-color: white; +} .panel .panel-body .panel-desc { margin-bottom: 20px; } diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index a861255e3..37144ce99 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -174,11 +174,31 @@ function initRepoCreate() { console.log('initRepoCreate'); } +function initRepoSetting() { + // Confirmation of changing repository name. + $('#repo-setting-form').submit(function (e) { + var $reponame = $('#repo_name'); + if (($reponame.data('repo-name') != $reponame.val()) && !confirm('Repository name has been changed, do you want to continue?')) { + e.preventDefault(); + return true; + } + }); + $('#transfer-button').click(function () { + $('#transfer-form').show(); + }); + $('#delete-button').click(function () { + $('#delete-form').show(); + }); +} + $(document).ready(function () { initCore(); if ($('#repo-create-form').length || $('#repo-migrate-form').length) { initRepoCreate(); } + if ($('#repo-setting').length) { + initRepoSetting(); + } Tabs('#dashboard-sidebar-menu'); diff --git a/public/ng/less/gogs.less b/public/ng/less/gogs.less index d1b13e1e4..dd458af62 100644 --- a/public/ng/less/gogs.less +++ b/public/ng/less/gogs.less @@ -4,4 +4,5 @@ @import "gogs/dashboard"; @import "gogs/sign"; @import "gogs/repository"; -@import "gogs/settings"; \ No newline at end of file +@import "gogs/settings"; +@import "gogs/issue"; \ No newline at end of file diff --git a/public/ng/less/ui/panel.less b/public/ng/less/ui/panel.less index 52f8dafb0..b3e2dec95 100644 --- a/public/ng/less/ui/panel.less +++ b/public/ng/less/ui/panel.less @@ -8,6 +8,7 @@ border-bottom: 1px solid@panelBorderColor; } .panel-body { + background-color: white; .panel-desc { margin-bottom: 20px; } diff --git a/public/ng/less/ui/reset.less b/public/ng/less/ui/reset.less index a1501d657..f58e1a473 100644 --- a/public/ng/less/ui/reset.less +++ b/public/ng/less/ui/reset.less @@ -230,6 +230,7 @@ label { font-weight: bold; } +textarea, input, .ipt { padding: .6em; @@ -374,3 +375,7 @@ pre { overflow: auto; padding: 0; } + +dt { + font-weight: bold; +} \ No newline at end of file diff --git a/routers/repo/http.go b/routers/repo/http.go index 4ffe5ec34..56c85bf59 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -77,9 +77,9 @@ func Http(ctx *middleware.Context) { repoUser, err := models.GetUserByName(username) if err != nil { if err == models.ErrUserNotExist { - ctx.Handle(404, "repo.Http(GetUserByName)", nil) + ctx.Handle(404, "GetUserByName", nil) } else { - ctx.Handle(500, "repo.Http(GetUserByName)", err) + ctx.Handle(500, "GetUserByName", err) } return } @@ -87,9 +87,9 @@ func Http(ctx *middleware.Context) { repo, err := models.GetRepositoryByName(repoUser.Id, reponame) if err != nil { if err == models.ErrRepoNotExist { - ctx.Handle(404, "repo.Http(GetRepositoryByName)", nil) + ctx.Handle(404, "GetRepositoryByName", nil) } else { - ctx.Handle(500, "repo.Http(GetRepositoryByName)", err) + ctx.Handle(500, "GetRepositoryByName", err) } return } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 26f391346..3dc3bc568 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -21,27 +21,28 @@ import ( ) const ( - SETTING base.TplName = "repo/setting" - COLLABORATION base.TplName = "repo/collaboration" + SETTINGS_OPTIONS base.TplName = "repo/settings/options" + COLLABORATION base.TplName = "repo/collaboration" HOOKS base.TplName = "repo/hooks" HOOK_ADD base.TplName = "repo/hook_add" HOOK_EDIT base.TplName = "repo/hook_edit" ) -func Setting(ctx *middleware.Context) { - ctx.Data["IsRepoToolbarSetting"] = true - ctx.Data["Title"] = strings.TrimPrefix(ctx.Repo.RepoLink, "/") + " - settings" - ctx.HTML(200, SETTING) +func Settings(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("repo.settings") + ctx.Data["PageIsSettingsOptions"] = true + ctx.HTML(200, SETTINGS_OPTIONS) } -func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) { - ctx.Data["IsRepoToolbarSetting"] = true +func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { + ctx.Data["Title"] = ctx.Tr("repo.settings") + ctx.Data["PageIsSettingsOptions"] = true switch ctx.Query("action") { case "update": if ctx.HasError() { - ctx.HTML(200, SETTING) + ctx.HTML(200, SETTINGS_OPTIONS) return } @@ -50,17 +51,17 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) { if ctx.Repo.Repository.Name != newRepoName { isExist, err := models.IsRepositoryExist(ctx.Repo.Owner, newRepoName) if err != nil { - ctx.Handle(500, "setting.SettingPost(update: check existence)", err) + ctx.Handle(500, "IsRepositoryExist", err) return } else if isExist { - ctx.RenderWithErr("Repository name has been taken in your repositories.", SETTING, nil) + ctx.Data["Err_RepoName"] = true + ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), SETTINGS_OPTIONS, nil) return } else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil { - ctx.Handle(500, "setting.SettingPost(change repository name)", err) + ctx.Handle(500, "ChangeRepositoryName", err) return } - log.Trace("%s Repository name changed: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newRepoName) - + log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName) ctx.Repo.Repository.Name = newRepoName } @@ -77,7 +78,7 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) { ctx.Handle(404, "UpdateRepository", err) return } - log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + log.Trace("Repository updated: %s/%s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if ctx.Repo.Repository.IsMirror { if form.Interval > 0 { @@ -89,51 +90,42 @@ func SettingPost(ctx *middleware.Context, form auth.RepoSettingForm) { } } - ctx.Flash.Success("Repository options has been successfully updated.") + ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) case "transfer": - if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") { - ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil) - return - } else if ctx.Repo.Repository.IsMirror { - ctx.Error(404) + if ctx.Repo.Repository.Name != form.RepoName { + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) return } - newOwner := ctx.Query("owner") - // Check if new owner exists. + newOwner := ctx.Query("new_owner_name") isExist, err := models.IsUserExist(newOwner) if err != nil { - ctx.Handle(500, "setting.SettingPost(transfer: check existence)", err) + ctx.Handle(500, "IsUserExist", err) return } else if !isExist { - ctx.RenderWithErr("Please make sure you entered owner name is correct.", SETTING, nil) + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), SETTINGS_OPTIONS, nil) return } else if err = models.TransferOwnership(ctx.Repo.Owner, newOwner, ctx.Repo.Repository); err != nil { - ctx.Handle(500, "setting.SettingPost(transfer repository)", err) + ctx.Handle(500, "TransferOwnership", err) return } - log.Trace("%s Repository transfered: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newOwner) - + log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newOwner) ctx.Redirect("/") case "delete": - if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") { - ctx.RenderWithErr("Please make sure you entered repository name is correct.", SETTING, nil) + if ctx.Repo.Repository.Name != form.RepoName { + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) return - } - - if ctx.Repo.Owner.IsOrganization() && - !ctx.Repo.Owner.IsOrgOwner(ctx.User.Id) { - ctx.Error(403) + } else if !ctx.Repo.Owner.ValidtePassword(ctx.Query("password")) { + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_OPTIONS, nil) return } if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.Id, ctx.Repo.Owner.Name); err != nil { - ctx.Handle(500, "setting.Delete(DeleteRepository)", err) + ctx.Handle(500, "DeleteRepository", err) return } - log.Trace("%s Repository deleted: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.LowerName, ctx.Repo.Repository.LowerName) - + log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if ctx.Repo.Owner.IsOrganization() { ctx.Redirect("/org/" + ctx.Repo.Owner.Name + "/dashboard") } else { diff --git a/templates/.VERSION b/templates/.VERSION index 7cfc6b858..bdaabb3ff 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.4.7.0801 Alpha \ No newline at end of file +0.4.7.0802 Alpha \ No newline at end of file diff --git a/templates/org/create.tmpl b/templates/org/create.tmpl index 4fcb07c4d..820cf7e75 100644 --- a/templates/org/create.tmpl +++ b/templates/org/create.tmpl @@ -8,23 +8,23 @@
+
+
+
+
+
+
+
@@ -128,34 +72,7 @@ {{template "repo/view_list" .}} {{end}}
+
- - +
+
diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl deleted file mode 100644 index 99835640f..000000000 --- a/templates/repo/setting.tmpl +++ /dev/null @@ -1,182 +0,0 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -{{template "repo/nav" .}} -{{template "repo/toolbar" .}} -