Merge branch 'master' of github.com:gogits/gogs

This commit is contained in:
Lunny Xiao 2014-03-11 12:18:56 +08:00
commit 5b5d54621e
11 changed files with 54 additions and 35 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ gogs
.DS_Store .DS_Store
*.db *.db
*.log *.log
conf/custom.ini

View file

@ -3,7 +3,6 @@ RUN_USER = lunny
[repository] [repository]
ROOT = /Users/lunny/git/gogs-repositories ROOT = /Users/lunny/git/gogs-repositories
ROOT_jiahuachen = /Users/jiahuachen/git/gogs-repositories
[server] [server]
HTTP_ADDR = HTTP_ADDR =
@ -15,7 +14,6 @@ HOST =
NAME = gogs NAME = gogs
USER = root USER = root
PASSWD = PASSWD =
PASSWD_jiahua = root
[security] [security]
USER_PASSWD_SALT = !#@FDEWREWR&*( USER_PASSWD_SALT = !#@FDEWREWR&*(

View file

@ -7,7 +7,6 @@ package models
import ( import (
"fmt" "fmt"
"os" "os"
"os/user"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm" "github.com/lunny/xorm"
@ -47,16 +46,7 @@ func setEngine() {
dbUser := base.Cfg.MustValue("database", "USER") dbUser := base.Cfg.MustValue("database", "USER")
dbPwd := base.Cfg.MustValue("database", "PASSWD") dbPwd := base.Cfg.MustValue("database", "PASSWD")
uname, err := user.Current() var err error
if err != nil {
fmt.Printf("models.init -> fail to get user: %s\n", err)
os.Exit(2)
}
if uname.Username == "jiahuachen" {
dbPwd = base.Cfg.MustValue("database", "PASSWD_jiahua")
}
switch dbType { switch dbType {
case "mysql": case "mysql":
orm, err = xorm.NewEngine("mysql", fmt.Sprintf("%v:%v@%v/%v?charset=utf8", orm, err = xorm.NewEngine("mysql", fmt.Sprintf("%v:%v@%v/%v?charset=utf8",
@ -83,9 +73,6 @@ func setEngine() {
//log.Trace("Initialized database -> %s", dbName) //log.Trace("Initialized database -> %s", dbName)
RepoRootPath = base.Cfg.MustValue("repository", "ROOT") RepoRootPath = base.Cfg.MustValue("repository", "ROOT")
if uname.Username == "jiahuachen" {
RepoRootPath = base.Cfg.MustValue("repository", "ROOT_jiahuachen")
}
} }
func init() { func init() {

View file

@ -11,6 +11,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"github.com/Unknwon/com"
"github.com/Unknwon/goconfig" "github.com/Unknwon/goconfig"
) )
@ -36,11 +37,20 @@ func init() {
os.Exit(2) os.Exit(2)
} }
cfgPath := filepath.Join(workDir, "conf", "app.ini") cfgPathPrefix := filepath.Join(workDir, "conf")
cfgPath := filepath.Join(cfgPathPrefix, "app.ini")
Cfg, err = goconfig.LoadConfigFile(cfgPath) Cfg, err = goconfig.LoadConfigFile(cfgPath)
if err != nil { if err != nil {
fmt.Printf("Cannot load config file '%s'\n", cfgPath) fmt.Printf("Cannot load config file '%s'\n", cfgPath)
os.Exit(2) os.Exit(2)
} }
cfgPath = filepath.Join(cfgPathPrefix, "custom.ini")
if com.IsFile(cfgPath) {
if err = Cfg.AppendFiles(cfgPath); err != nil {
fmt.Printf("Cannot load config file '%s'\n", cfgPath)
os.Exit(2)
}
}
Cfg.BlockMode = false Cfg.BlockMode = false
} }

View file

@ -234,7 +234,7 @@ body {
/* gogits user setting */ /* gogits user setting */
#gogs-user-setting-nav > h4, #gogs-user-setting-container > h4 ,#gogs-ssh-keys > h4{ #gogs-user-setting-nav > h4, #gogs-user-setting-container > h4, #gogs-ssh-keys > h4, #gogs-user-delete > h4 {
padding-bottom: 18px; padding-bottom: 18px;
margin-bottom: 18px; margin-bottom: 18px;
border-bottom: 1px solid #CCC; border-bottom: 1px solid #CCC;

View file

@ -104,7 +104,7 @@ function initUserSetting(){
var $this = $(this); var $this = $(this);
Gogits.ajaxDelete("",{"id":$this.data("del")},function(json){ Gogits.ajaxDelete("",{"id":$this.data("del")},function(json){
if(json.ok){ if(json.ok){
$this.parent().remove(); window.location.reload();
}else{ }else{
alert(json.err); alert(json.err);
} }

View file

@ -56,6 +56,7 @@ func SettingSSHKeys(form auth.AddSSHKeyForm, r render.Render, data base.TmplData
"ok": true, "ok": true,
}) })
} }
return
} }
// Add new SSH key. // Add new SSH key.

View file

@ -134,7 +134,7 @@ func SignUp(form auth.RegisterForm, data base.TmplData, req *http.Request, r ren
// TODO: unfinished // TODO: unfinished
func Delete(data base.TmplData, req *http.Request, r render.Render) { func Delete(data base.TmplData, req *http.Request, r render.Render) {
data["Title"] = "Delete user" data["Title"] = "Delete Account"
if req.Method == "GET" { if req.Method == "GET" {
r.HTML(200, "user/delete", data) r.HTML(200, "user/delete", data)

View file

@ -1,12 +1,34 @@
{{template "base/head" .}} {{template "base/head" .}}
{{template "base/navbar" .}} {{template "base/navbar" .}}
<div class="container" id="gogs-body"> <div id="gogs-body" class="container">
<form action="/user/delete" method="post" class="form-horizontal"> <div id="gogs-user-setting-nav" class="col-md-3">
<h4>Account Setting</h4>
<ul class="list-group">
<li class="list-group-item"><a href="/user/setting">Account Profile</a></li>
<li class="list-group-item"><a href="#">Emails and Password</a></li>
<li class="list-group-item"><a href="#">Notifications</a></li>
<li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
<li class="list-group-item"><a href="#">Security</a></li>
<li class="list-group-item list-group-item-success"><a href="/user/delete">Delete Account</a></li>
</ul>
</div>
<div id="gogs-user-setting-container" class="col-md-9">
<form action="/user/delete" method="post" class="form-horizontal" id="gogs-user-delete">
<h4>Delete Account</h4>
<p class="alert alert-danger">Deleting your account is permanent. Sorry to see you go, if you have any feedback you can contact us.</p>
<div class="form-group"> <div class="form-group">
<div class="col-md-offset-4 col-md-3"> <div class="col-md-3">
<button type="submit" class="btn btn-danger">Delete user</button> <button type="submit" class="btn btn-danger btn-lg">Delete Account</button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div>
<script>
$(function(){
$('#gogs-user-delete').on('submit',function(){
return confirm("Are you sure ?");
})
});
</script>
{{template "base/footer" .}} {{template "base/footer" .}}

View file

@ -9,7 +9,7 @@
<li class="list-group-item"><a href="#">Notifications</a></li> <li class="list-group-item"><a href="#">Notifications</a></li>
<li class="list-group-item list-group-item-success"><a href="/user/setting/ssh/">SSH Keys</a></li> <li class="list-group-item list-group-item-success"><a href="/user/setting/ssh/">SSH Keys</a></li>
<li class="list-group-item"><a href="#">Security</a></li> <li class="list-group-item"><a href="#">Security</a></li>
<li class="list-group-item"><a href="#">Kill Myself</a></li> <li class="list-group-item"><a href="/user/delete">Delete Account</a></li>
</ul> </ul>
</div> </div>

View file

@ -9,7 +9,7 @@
<li class="list-group-item"><a href="#">Notifications</a></li> <li class="list-group-item"><a href="#">Notifications</a></li>
<li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li> <li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
<li class="list-group-item"><a href="#">Security</a></li> <li class="list-group-item"><a href="#">Security</a></li>
<li class="list-group-item"><a href="#">Kill Myself</a></li> <li class="list-group-item"><a href="/user/delete">Delete Account</a></li>
</ul> </ul>
</div> </div>
<div id="gogs-user-setting-container" class="col-md-9"> <div id="gogs-user-setting-container" class="col-md-9">