1
0
mirror of https://github.com/go-gitea/gitea synced 2024-12-24 03:35:55 +01:00

Merge branch 'dev' of github.com:gogits/gogs into dev

Conflicts:
	routers/repo/repo.go
This commit is contained in:
Lunny Xiao 2014-04-05 15:30:49 +08:00
commit a92826a8fe
20 changed files with 262 additions and 54 deletions

@ -19,6 +19,9 @@ github.com/gogits/gfm=
github.com/gogits/cache= github.com/gogits/cache=
github.com/gogits/session= github.com/gogits/session=
github.com/gogits/webdav= github.com/gogits/webdav=
github.com/martini-contrib/oauth2=
github.com/martini-contrib/sessions=
code.google.com/p/goauth2=
[res] [res]
include=templates|public|conf include=templates|public|conf

@ -30,8 +30,8 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
- Activity timeline - Activity timeline
- SSH/HTTPS(Clone only) protocol support. - SSH/HTTPS(Clone only) protocol support.
- Register/delete account. - Register/delete/rename account.
- Create/delete/watch public repository. - Create/delete/watch/rename public repository.
- Repository viewer. - Repository viewer.
- Issue tracker. - Issue tracker.
- Gravatar and cache support. - Gravatar and cache support.

@ -24,8 +24,8 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
- 活动时间线 - 活动时间线
- SSH/HTTPS仅限 Clone 协议支持 - SSH/HTTPS仅限 Clone 协议支持
- 注册/删除用户 - 注册/删除/重命名用户
- 创建/删除/关注公开仓库 - 创建/删除/关注/重命名公开仓库
- 仓库浏览器 - 仓库浏览器
- Bug 追踪系统 - Bug 追踪系统
- Gravatar 以及缓存支持 - Gravatar 以及缓存支持

@ -19,7 +19,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition. // Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true const go12tag = true
const APP_VER = "0.2.0.0403 Alpha" const APP_VER = "0.2.0.0404 Alpha"
func init() { func init() {
base.AppVer = APP_VER base.AppVer = APP_VER

@ -7,6 +7,8 @@ package models
import ( import (
"strings" "strings"
"time" "time"
"github.com/lunny/xorm"
) )
// Access types. // Access types.
@ -40,6 +42,15 @@ func UpdateAccess(access *Access) error {
return err return err
} }
// UpdateAccess updates access information with session for rolling back.
func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
if _, err := sess.Id(access.Id).Update(access); err != nil {
sess.Rollback()
return err
}
return nil
}
// HasAccess returns true if someone can read or write to given repository. // HasAccess returns true if someone can read or write to given repository.
func HasAccess(userName, repoName string, mode int) (bool, error) { func HasAccess(userName, repoName string, mode int) (bool, error) {
return orm.Get(&Access{ return orm.Get(&Access{

@ -21,6 +21,7 @@ const (
OP_COMMIT_REPO OP_COMMIT_REPO
OP_CREATE_ISSUE OP_CREATE_ISSUE
OP_PULL_REQUEST OP_PULL_REQUEST
OP_TRANSFER_REPO
) )
// Action represents user operation type and other information to repository., // Action represents user operation type and other information to repository.,
@ -108,6 +109,18 @@ func NewRepoAction(user *User, repo *Repository) (err error) {
return err return err
} }
// TransferRepoAction adds new action for transfering repository.
func TransferRepoAction(user, newUser *User, repo *Repository) (err error) {
if err = NotifyWatchers(&Action{ActUserId: user.Id, ActUserName: user.Name, ActEmail: user.Email,
OpType: OP_TRANSFER_REPO, RepoId: repo.Id, RepoName: repo.Name, Content: newUser.Name}); err != nil {
log.Error("action.TransferRepoAction(notify watchers): %d/%s", user.Id, repo.Name)
return err
}
log.Trace("action.TransferRepoAction: %s/%s", user.LowerName, repo.LowerName)
return err
}
// GetFeeds returns action list of given user in given context. // GetFeeds returns action list of given user in given context.
func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) { func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) {
actions := make([]Action, 0, 20) actions := make([]Action, 0, 20)

@ -53,10 +53,10 @@ func NewTestEngine(x *xorm.Engine) (err error) {
// os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) // os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm)
// x, err = xorm.NewEngine("sqlite3", DbCfg.Path) // x, err = xorm.NewEngine("sqlite3", DbCfg.Path)
default: default:
return fmt.Errorf("Unknown database type: %s\n", DbCfg.Type) return fmt.Errorf("Unknown database type: %s", DbCfg.Type)
} }
if err != nil { if err != nil {
return fmt.Errorf("models.init(fail to conntect database): %v\n", err) return fmt.Errorf("models.init(fail to conntect database): %v", err)
} }
return x.Sync(new(User), new(PublicKey), new(Repository), new(Watch), return x.Sync(new(User), new(PublicKey), new(Repository), new(Watch),
@ -75,10 +75,10 @@ func SetEngine() (err error) {
os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm)
orm, err = xorm.NewEngine("sqlite3", DbCfg.Path) orm, err = xorm.NewEngine("sqlite3", DbCfg.Path)
default: default:
return fmt.Errorf("Unknown database type: %s\n", DbCfg.Type) return fmt.Errorf("Unknown database type: %s", DbCfg.Type)
} }
if err != nil { if err != nil {
return fmt.Errorf("models.init(fail to conntect database): %v\n", err) return fmt.Errorf("models.init(fail to conntect database): %v", err)
} }
// WARNNING: for serv command, MUST remove the output to os.stdout, // WARNNING: for serv command, MUST remove the output to os.stdout,
@ -89,7 +89,7 @@ func SetEngine() (err error) {
f, err := os.Create(logPath) f, err := os.Create(logPath)
if err != nil { if err != nil {
return fmt.Errorf("models.init(fail to create xorm.log): %v\n", err) return fmt.Errorf("models.init(fail to create xorm.log): %v", err)
} }
orm.Logger = f orm.Logger = f
@ -104,7 +104,7 @@ func NewEngine() (err error) {
return err return err
} else if err = orm.Sync(new(User), new(PublicKey), new(Repository), new(Watch), } else if err = orm.Sync(new(User), new(PublicKey), new(Repository), new(Watch),
new(Action), new(Access), new(Issue), new(Comment)); err != nil { new(Action), new(Access), new(Issue), new(Comment)); err != nil {
return fmt.Errorf("sync database struct error: %v\n", err) return fmt.Errorf("sync database struct error: %v", err)
} }
return nil return nil
} }

@ -77,8 +77,8 @@ func init() {
// PublicKey represents a SSH key of user. // PublicKey represents a SSH key of user.
type PublicKey struct { type PublicKey struct {
Id int64 Id int64
OwnerId int64 `xorm:"index"` OwnerId int64 `xorm:" index not null"`
Name string `xorm:"unique not null"` Name string `xorm:" not null"` //UNIQUE(s)
Fingerprint string Fingerprint string
Content string `xorm:"TEXT not null"` Content string `xorm:"TEXT not null"`
Created time.Time `xorm:"created"` Created time.Time `xorm:"created"`

@ -143,17 +143,17 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
if err = initRepository(repoPath, user, repo, initReadme, repoLang, license); err != nil { if err = initRepository(repoPath, user, repo, initReadme, repoLang, license); err != nil {
return nil, err return nil, err
} }
session := orm.NewSession() sess := orm.NewSession()
defer session.Close() defer sess.Close()
session.Begin() sess.Begin()
if _, err = session.Insert(repo); err != nil { if _, err = sess.Insert(repo); err != nil {
if err2 := os.RemoveAll(repoPath); err2 != nil { if err2 := os.RemoveAll(repoPath); err2 != nil {
log.Error("repo.CreateRepository(repo): %v", err) log.Error("repo.CreateRepository(repo): %v", err)
return nil, errors.New(fmt.Sprintf( return nil, errors.New(fmt.Sprintf(
"delete repo directory %s/%s failed(1): %v", user.Name, repoName, err2)) "delete repo directory %s/%s failed(1): %v", user.Name, repoName, err2))
} }
session.Rollback() sess.Rollback()
return nil, err return nil, err
} }
@ -162,8 +162,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
RepoName: strings.ToLower(path.Join(user.Name, repo.Name)), RepoName: strings.ToLower(path.Join(user.Name, repo.Name)),
Mode: AU_WRITABLE, Mode: AU_WRITABLE,
} }
if _, err = session.Insert(&access); err != nil { if _, err = sess.Insert(&access); err != nil {
session.Rollback() sess.Rollback()
if err2 := os.RemoveAll(repoPath); err2 != nil { if err2 := os.RemoveAll(repoPath); err2 != nil {
log.Error("repo.CreateRepository(access): %v", err) log.Error("repo.CreateRepository(access): %v", err)
return nil, errors.New(fmt.Sprintf( return nil, errors.New(fmt.Sprintf(
@ -173,8 +173,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
} }
rawSql := "UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?" rawSql := "UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?"
if _, err = session.Exec(rawSql, user.Id); err != nil { if _, err = sess.Exec(rawSql, user.Id); err != nil {
session.Rollback() sess.Rollback()
if err2 := os.RemoveAll(repoPath); err2 != nil { if err2 := os.RemoveAll(repoPath); err2 != nil {
log.Error("repo.CreateRepository(repo count): %v", err) log.Error("repo.CreateRepository(repo count): %v", err)
return nil, errors.New(fmt.Sprintf( return nil, errors.New(fmt.Sprintf(
@ -183,8 +183,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
return nil, err return nil, err
} }
if err = session.Commit(); err != nil { if err = sess.Commit(); err != nil {
session.Rollback() sess.Rollback()
if err2 := os.RemoveAll(repoPath); err2 != nil { if err2 := os.RemoveAll(repoPath); err2 != nil {
log.Error("repo.CreateRepository(commit): %v", err) log.Error("repo.CreateRepository(commit): %v", err)
return nil, errors.New(fmt.Sprintf( return nil, errors.New(fmt.Sprintf(
@ -369,6 +369,76 @@ func RepoPath(userName, repoName string) string {
return filepath.Join(UserPath(userName), strings.ToLower(repoName)+".git") return filepath.Join(UserPath(userName), strings.ToLower(repoName)+".git")
} }
// TransferOwnership transfers all corresponding setting from old user to new one.
func TransferOwnership(user *User, newOwner string, repo *Repository) (err error) {
newUser, err := GetUserByName(newOwner)
if err != nil {
return err
}
// Update accesses.
accesses := make([]Access, 0, 10)
if err = orm.Find(&accesses, &Access{RepoName: user.LowerName + "/" + repo.LowerName}); err != nil {
return err
}
sess := orm.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}
for i := range accesses {
accesses[i].RepoName = newUser.LowerName + "/" + repo.LowerName
if accesses[i].UserName == user.LowerName {
accesses[i].UserName = newUser.LowerName
}
if err = UpdateAccessWithSession(sess, &accesses[i]); err != nil {
return err
}
}
// Update repository.
repo.OwnerId = newUser.Id
if _, err := sess.Id(repo.Id).Update(repo); err != nil {
sess.Rollback()
return err
}
// Update user repository number.
rawSql := "UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?"
if _, err = sess.Exec(rawSql, newUser.Id); err != nil {
sess.Rollback()
return err
}
rawSql = "UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?"
if _, err = sess.Exec(rawSql, user.Id); err != nil {
sess.Rollback()
return err
}
// Add watch of new owner to repository.
if !IsWatching(newUser.Id, repo.Id) {
if err = WatchRepo(newUser.Id, repo.Id, true); err != nil {
sess.Rollback()
return err
}
}
if err = TransferRepoAction(user, newUser, repo); err != nil {
sess.Rollback()
return err
}
// Change repository directory name.
if err = os.Rename(RepoPath(user.Name, repo.Name), RepoPath(newUser.Name, repo.Name)); err != nil {
sess.Rollback()
return err
}
return sess.Commit()
}
// ChangeRepositoryName changes all corresponding setting from old repository name to new one. // ChangeRepositoryName changes all corresponding setting from old repository name to new one.
func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error) { func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error) {
// Update accesses. // Update accesses.
@ -376,15 +446,27 @@ func ChangeRepositoryName(userName, oldRepoName, newRepoName string) (err error)
if err = orm.Find(&accesses, &Access{RepoName: strings.ToLower(userName + "/" + oldRepoName)}); err != nil { if err = orm.Find(&accesses, &Access{RepoName: strings.ToLower(userName + "/" + oldRepoName)}); err != nil {
return err return err
} }
sess := orm.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}
for i := range accesses { for i := range accesses {
accesses[i].RepoName = userName + "/" + newRepoName accesses[i].RepoName = userName + "/" + newRepoName
if err = UpdateAccess(&accesses[i]); err != nil { if err = UpdateAccessWithSession(sess, &accesses[i]); err != nil {
return err return err
} }
} }
// Change repository directory name. // Change repository directory name.
return os.Rename(RepoPath(userName, oldRepoName), RepoPath(userName, newRepoName)) if err = os.Rename(RepoPath(userName, oldRepoName), RepoPath(userName, newRepoName)); err != nil {
sess.Rollback()
return err
}
return sess.Commit()
} }
func UpdateRepository(repo *Repository) error { func UpdateRepository(repo *Repository) error {
@ -410,29 +492,30 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
return ErrRepoNotExist return ErrRepoNotExist
} }
session := orm.NewSession() sess := orm.NewSession()
if err = session.Begin(); err != nil { defer sess.Close()
if err = sess.Begin(); err != nil {
return err return err
} }
if _, err = session.Delete(&Repository{Id: repoId}); err != nil { if _, err = sess.Delete(&Repository{Id: repoId}); err != nil {
session.Rollback() sess.Rollback()
return err return err
} }
if _, err := session.Delete(&Access{RepoName: strings.ToLower(path.Join(userName, repo.Name))}); err != nil { if _, err := sess.Delete(&Access{RepoName: strings.ToLower(path.Join(userName, repo.Name))}); err != nil {
session.Rollback() sess.Rollback()
return err return err
} }
rawSql := "UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?" rawSql := "UPDATE `user` SET num_repos = num_repos - 1 WHERE id = ?"
if _, err = session.Exec(rawSql, userId); err != nil { if _, err = sess.Exec(rawSql, userId); err != nil {
session.Rollback() sess.Rollback()
return err return err
} }
if _, err = session.Delete(&Watch{RepoId: repoId}); err != nil { if _, err = sess.Delete(&Watch{RepoId: repoId}); err != nil {
session.Rollback() sess.Rollback()
return err return err
} }
if err = session.Commit(); err != nil { if err = sess.Commit(); err != nil {
session.Rollback() sess.Rollback()
return err return err
} }
if err = os.RemoveAll(RepoPath(userName, repo.Name)); err != nil { if err = os.RemoveAll(RepoPath(userName, repo.Name)); err != nil {

@ -105,11 +105,17 @@ type Member struct {
// IsUserExist checks if given user name exist, // IsUserExist checks if given user name exist,
// the user name should be noncased unique. // the user name should be noncased unique.
func IsUserExist(name string) (bool, error) { func IsUserExist(name string) (bool, error) {
if len(name) == 0 {
return false, nil
}
return orm.Get(&User{LowerName: strings.ToLower(name)}) return orm.Get(&User{LowerName: strings.ToLower(name)})
} }
// IsEmailUsed returns true if the e-mail has been used. // IsEmailUsed returns true if the e-mail has been used.
func IsEmailUsed(email string) (bool, error) { func IsEmailUsed(email string) (bool, error) {
if len(email) == 0 {
return false, nil
}
return orm.Get(&User{Email: email}) return orm.Get(&User{Email: email})
} }
@ -212,11 +218,18 @@ func ChangeUserName(user *User, newUserName string) (err error) {
if err = orm.Find(&accesses, &Access{UserName: user.LowerName}); err != nil { if err = orm.Find(&accesses, &Access{UserName: user.LowerName}); err != nil {
return err return err
} }
sess := orm.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}
for i := range accesses { for i := range accesses {
accesses[i].UserName = newUserName accesses[i].UserName = newUserName
if strings.HasPrefix(accesses[i].RepoName, user.LowerName+"/") { if strings.HasPrefix(accesses[i].RepoName, user.LowerName+"/") {
accesses[i].RepoName = strings.Replace(accesses[i].RepoName, user.LowerName, newUserName, 1) accesses[i].RepoName = strings.Replace(accesses[i].RepoName, user.LowerName, newUserName, 1)
if err = UpdateAccess(&accesses[i]); err != nil { if err = UpdateAccessWithSession(sess, &accesses[i]); err != nil {
return err return err
} }
} }
@ -235,14 +248,19 @@ func ChangeUserName(user *User, newUserName string) (err error) {
for j := range accesses { for j := range accesses {
accesses[j].RepoName = newUserName + "/" + repos[i].LowerName accesses[j].RepoName = newUserName + "/" + repos[i].LowerName
if err = UpdateAccess(&accesses[j]); err != nil { if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil {
return err return err
} }
} }
} }
// Change user directory name. // Change user directory name.
return os.Rename(UserPath(user.LowerName), UserPath(newUserName)) if err = os.Rename(UserPath(user.LowerName), UserPath(newUserName)); err != nil {
sess.Rollback()
return err
}
return sess.Commit()
} }
// UpdateUser updates user's information. // UpdateUser updates user's information.

@ -494,6 +494,8 @@ func ActionIcon(opType int) string {
return "arrow-circle-o-right" return "arrow-circle-o-right"
case 6: // Create issue. case 6: // Create issue.
return "exclamation-circle" return "exclamation-circle"
case 8: // Transfer repository.
return "share"
default: default:
return "invalid type" return "invalid type"
} }
@ -503,8 +505,9 @@ const (
TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s">%s</a>` TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s">%s</a>`
TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>%s` TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>%s`
TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s">%s</a> %s</div>` TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s">%s</a> %s</div>`
TPL_CREATE_Issue = `<a href="/user/%s">%s</a> opened issue <a href="/%s/issues/%s">%s#%s</a> TPL_CREATE_ISSUE = `<a href="/user/%s">%s</a> opened issue <a href="/%s/issues/%s">%s#%s</a>
<div><img src="%s?s=16" alt="user-avatar"/> %s</div>` <div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
TPL_TRANSFER_REPO = `<a href="/user/%s">%s</a> transfered repository <code>%s</code> to <a href="/%s">%s</a>`
) )
type PushCommit struct { type PushCommit struct {
@ -547,8 +550,11 @@ func ActionDesc(act Actioner) string {
buf.String()) buf.String())
case 6: // Create issue. case 6: // Create issue.
infos := strings.SplitN(content, "|", 2) infos := strings.SplitN(content, "|", 2)
return fmt.Sprintf(TPL_CREATE_Issue, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], return fmt.Sprintf(TPL_CREATE_ISSUE, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
AvatarLink(email), infos[1]) AvatarLink(email), infos[1])
case 8: // Transfer repository.
newRepoLink := content + "/" + repoName
return fmt.Sprintf(TPL_TRANSFER_REPO, actUserName, actUserName, repoLink, newRepoLink, newRepoLink)
default: default:
return "invalid type" return "invalid type"
} }

@ -43,7 +43,7 @@ func GlobalInit() {
if base.InstallLock { if base.InstallLock {
if err := models.NewEngine(); err != nil { if err := models.NewEngine(); err != nil {
fmt.Println("%v", err) fmt.Println(err)
os.Exit(2) os.Exit(2)
} }

@ -338,10 +338,11 @@ func Http(ctx *middleware.Context, params martini.Params) {
} }
} }
dir := models.RepoPath(username, reponame)
prefix := path.Join("/", username, params["reponame"]) prefix := path.Join("/", username, params["reponame"])
server := webdav.NewServer( server := webdav.NewServer(
models.RepoPath(username, reponame), dir, prefix, true)
prefix, true)
server.ServeHTTP(ctx.ResponseWriter, ctx.Req) server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
} }
@ -406,6 +407,29 @@ func SettingPost(ctx *middleware.Context) {
ctx.HTML(200, "repo/setting") ctx.HTML(200, "repo/setting")
} }
log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, 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.", "repo/setting", nil)
return
}
newOwner := ctx.Query("owner")
// Check if new owner exists.
isExist, err := models.IsUserExist(newOwner)
if err != nil {
ctx.Handle(404, "repo.SettingPost(transfer: check existence)", err)
return
} else if !isExist {
ctx.RenderWithErr("Please make sure you entered owner name is correct.", "repo/setting", nil)
return
} else if err = models.TransferOwnership(ctx.User, newOwner, ctx.Repo.Repository); err != nil {
ctx.Handle(404, "repo.SettingPost(transfer repository)", err)
return
}
log.Trace("%s Repository transfered: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newOwner)
ctx.Redirect("/")
return
case "delete": case "delete":
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") { 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.", "repo/setting", nil) ctx.RenderWithErr("Please make sure you entered repository name is correct.", "repo/setting", nil)

@ -2,7 +2,7 @@
{{template "base/navbar" .}} {{template "base/navbar" .}}
<div id="body" class="container" data-page="admin"> <div id="body" class="container" data-page="admin">
{{template "admin/nav" .}} {{template "admin/nav" .}}
<div id="admin-container" class="col-md-9"> <div id="admin-container" class="col-md-10">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Server Configuration Server Configuration

@ -2,7 +2,7 @@
{{template "base/navbar" .}} {{template "base/navbar" .}}
<div id="body" class="container" data-page="admin"> <div id="body" class="container" data-page="admin">
{{template "admin/nav" .}} {{template "admin/nav" .}}
<div id="admin-container" class="col-md-9"> <div id="admin-container" class="col-md-10">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Statistic Statistic

@ -1,4 +1,4 @@
<div id="user-setting-nav" class="col-md-3 admin-nav"> <div id="user-setting-nav" class="col-md-2 admin-nav">
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item{{if .PageIsDashboard}} active{{end}}"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li> <li class="list-group-item{{if .PageIsDashboard}} active{{end}}"><a href="/admin"><i class="fa fa-tachometer fa-lg"></i> Dashboard</a></li>
<li class="list-group-item{{if .PageIsUsers}} active{{end}}"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li> <li class="list-group-item{{if .PageIsUsers}} active{{end}}"><a href="/admin/users"><i class="fa fa-users fa-lg"></i> Users</a></li>

@ -2,7 +2,7 @@
{{template "base/navbar" .}} {{template "base/navbar" .}}
<div id="body" class="container" data-page="admin"> <div id="body" class="container" data-page="admin">
{{template "admin/nav" .}} {{template "admin/nav" .}}
<div id="admin-container" class="col-md-9"> <div id="admin-container" class="col-md-10">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Repository Management Repository Management

@ -2,7 +2,7 @@
{{template "base/navbar" .}} {{template "base/navbar" .}}
<div id="body" class="container" data-page="admin"> <div id="body" class="container" data-page="admin">
{{template "admin/nav" .}} {{template "admin/nav" .}}
<div id="admin-container" class="col-md-9"> <div id="admin-container" class="col-md-10">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
User Management User Management

@ -25,7 +25,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-3 text-right">Name</label> <label class="col-md-3 text-right">Name</label>
<div class="col-md-9"> <div class="col-md-9">
<input class="form-control" name="name" value="{{.Repository.Name}}" /> <input class="form-control" name="name" value="{{.Repository.Name}}" title="{{.Repository.Name}}" />
</div> </div>
</div> </div>
@ -64,12 +64,62 @@
Danger Zone Danger Zone
</div> </div>
<div class="panel-body">
<button type="button" class="btn btn-default pull-right" href="#transfer-repository-modal" data-toggle="modal">
Transfer ownership
</button>
<dd>
<dt>Transfer ownership</dt>
<dl>Transfer this repo to another user or to an organization where you have admin rights.</dl>
</dd>
<div class="modal fade" id="transfer-repository-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<form action="/{{.Owner.Name}}/{{.Repository.Name}}/settings" method="post" class="modal-content">
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="transfer">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Do you really want to transfer this repo?</h4>
</div>
<div class="modal-body">
<div class="alert alert-warning">This is important, pay attention.</div>
<ul>
<!-- <li>Transferring may be delayed until the new owner approves the transfer.</li> -->
<!-- <li>If you are transferring into an org, teams <strong>will not be set</strong>. An owner on the org will need to set teams for the repo.</li> -->
<li>Admin rights will be transferred to the new owner, you <strong>will lose admin rights</strong>.</li>
<!-- <li>Admin rights will be transferred to the new owner, you <strong>may lose admin rights</strong> if you are transferring into an organization account.</li> -->
<li>Redirect entries <strong>will NOT be</strong> set up from the previous location.</li>
<li>Git access <strong>will NOT continue</strong> to work from the previous location.</li>
</ul>
<div class="form-group">
<label>Please type the name of the repository to confirm "<strong class="text-danger">{{.Repository.Name}}</strong>"</label>
<input name="repository" class="form-control" type="text" placeholder="Type your repository name" required="required">
</div>
<div class="form-group">
<label>Please type the name of the new owner:</label>
<input name="owner" class="form-control" type="text" placeholder="Type new owner's name" required="required">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button class="btn btn-danger btn-lg">I understand the consequences, transfer this repository</button>
</div>
</form>
</div>
</div>
</div>
<hr>
<div class="panel-body"> <div class="panel-body">
<button type="button" class="btn btn-default pull-right" href="#delete-repository-modal" data-toggle="modal"> <button type="button" class="btn btn-default pull-right" href="#delete-repository-modal" data-toggle="modal">
Delete this repository Delete this repository
</button> </button>
<dd> <dd>
<dt>Delete this repository.</dt> <dt>Delete this repository</dt>
<dl>Once you delete a repository, there is no going back. Please be certain.</dl> <dl>Once you delete a repository, there is no going back. Please be certain.</dl>
</dd> </dd>

@ -12,7 +12,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Username<strong class="text-danger">*</strong></label> <label class="col-md-2 control-label">Username<strong class="text-danger">*</strong></label>
<div class="col-md-8"> <div class="col-md-8">
<input name="username" class="form-control" placeholder="Type your user name" required="required" value="{{.SignedUser.Name}}"> <input name="username" class="form-control" placeholder="Type your user name" required="required" value="{{.SignedUser.Name}}" title="{{.SignedUser.Name}}">
</div> </div>
</div> </div>