Skip to content

Commit

Permalink
Finish new repo settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Aug 2, 2014
1 parent 669552e commit 755eec7
Show file tree
Hide file tree
Showing 25 changed files with 502 additions and 347 deletions.
5 changes: 2 additions & 3 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions conf/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 <span class="label label-blue label-radius">Go-Getable</span>

need_auth = Need Authorization
migrate_type = Migration Type
migrate_type_helper = This repository will be a <span class="label label-blue label-radius">Mirror</span>
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.
Expand Down
26 changes: 26 additions & 0 deletions conf/locale/locale_zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ sign_up_now = 还没帐户?马上注册。

[form]
UserName = 用户名
RepoName = 仓库名称
Email = 邮箱地址
Password = 密码
Retype = 确认密码
Expand All @@ -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
Expand Down Expand Up @@ -143,12 +147,34 @@ license = 授权许可
license_helper = 请选择授权许可文件
init_readme = 使用 README.md 文件初始化仓库
create_repo = 创建仓库
default_branch = 默认分支
mirror_interval = 镜像同步周期(小时)
goget_meta = Go-Get 支持
goget_meta_helper = 本仓库将可以通过 <span class="label label-blue label-radius">Go Get</span> 获取

need_auth = 需要授权验证
migrate_type = 迁移类型
migrate_type_helper = 本仓库将是 <span class="label label-blue label-radius">镜像</span>
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 = 伟大的组织都有一个简短而寓意深刻的名字。
Expand Down
2 changes: 1 addition & 1 deletion gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 7 additions & 0 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/auth/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions modules/middleware/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
112 changes: 112 additions & 0 deletions public/ng/css/gogs.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions public/ng/css/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -290,6 +292,9 @@ pre {
overflow: auto;
padding: 0;
}
dt {
font-weight: bold;
}
.left {
float: left;
}
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions public/ng/js/gogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
3 changes: 2 additions & 1 deletion public/ng/less/gogs.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@import "gogs/dashboard";
@import "gogs/sign";
@import "gogs/repository";
@import "gogs/settings";
@import "gogs/settings";
@import "gogs/issue";
1 change: 1 addition & 0 deletions public/ng/less/ui/panel.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
border-bottom: 1px solid@panelBorderColor;
}
.panel-body {
background-color: white;
.panel-desc {
margin-bottom: 20px;
}
Expand Down
Loading

0 comments on commit 755eec7

Please sign in to comment.