diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-29 14:35:54 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-29 14:35:54 +0800 |
commit | f48fc24670b122df069149801459eb55a67045c7 (patch) | |
tree | 04a054e989341953072f854134a50d62f75993c8 /modules | |
parent | e085d7738a683785a5d7d7e3a33a0437c87c340b (diff) | |
parent | d01820c125669367b7a585d767d5f11e73a701c2 (diff) | |
download | gitea-f48fc24670b122df069149801459eb55a67045c7.tar.gz gitea-f48fc24670b122df069149801459eb55a67045c7.zip |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/auth.go | 50 | ||||
-rw-r--r-- | modules/base/conf.go | 13 | ||||
-rw-r--r-- | modules/middleware/repo.go | 6 |
3 files changed, 60 insertions, 9 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go index 2e0555f6df..ac03a8f126 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -161,3 +161,53 @@ func AssignForm(form interface{}, data base.TmplData) { data[fieldName] = val.Field(i).Interface() } } + +type InstallForm struct { + Database string `form:"database" binding:"Required"` + Host string `form:"host"` + User string `form:"user"` + Passwd string `form:"passwd"` + DatabaseName string `form:"database_name"` + SslMode string `form:"ssl_mode"` + DatabasePath string `form:"database_path"` + RepoRootPath string `form:"repo_path"` + RunUser string `form:"run_user"` + AppUrl string `form:"app_url"` + AdminName string `form:"admin_name" binding:"Required"` + AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(30)"` + AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"` + SmtpHost string `form:"smtp_host"` + SmtpEmail string `form:"mailer_user"` + SmtpPasswd string `form:"mailer_pwd"` + RegisterConfirm string `form:"register_confirm"` + MailNotify string `form:"mail_notify"` +} + +func (f *InstallForm) Name(field string) string { + names := map[string]string{ + "Database": "Database name", + "AdminName": "Admin user name", + "AdminPasswd": "Admin password", + "AdminEmail": "Admin e-maill address", + } + return names[field] +} + +func (f *InstallForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) { + if req.Method == "GET" || errors.Count() == 0 { + return + } + + data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) + data["HasError"] = true + AssignForm(f, data) + + if len(errors.Overall) > 0 { + for _, err := range errors.Overall { + log.Error("InstallForm.Validate: %v", err) + } + return + } + + validate(errors, data, f) +} diff --git a/modules/base/conf.go b/modules/base/conf.go index 2e56883937..fd77cfd3ce 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -38,7 +38,7 @@ var ( RunUser string RepoRootPath string - EnableHttpsClone bool + InstallLock bool LogInRememberDays int CookieUserName string @@ -282,7 +282,7 @@ func NewConfigContext() { os.Exit(2) } - EnableHttpsClone = Cfg.MustBool("security", "ENABLE_HTTPS_CLONE", false) + InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false) LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS") CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") @@ -291,9 +291,14 @@ func NewConfigContext() { PictureService = Cfg.MustValue("picture", "SERVICE") // Determine and create root git reposiroty path. - RepoRootPath = Cfg.MustValue("repository", "ROOT") + homeDir, err := com.HomeDir() + if err != nil { + fmt.Printf("Fail to get home directory): %v\n", err) + os.Exit(2) + } + RepoRootPath = Cfg.MustValue("repository", "ROOT", filepath.Join(homeDir, "git/gogs-repositories")) if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil { - fmt.Printf("models.init(fail to create RepoRootPath(%s)): %v\n", RepoRootPath, err) + fmt.Printf("Fail to create RepoRootPath(%s): %v\n", RepoRootPath, err) os.Exit(2) } } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index cb4a8632a2..54b735af07 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -71,12 +71,8 @@ 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("%s@%s:%s/%s.git", base.RunUser, 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.Repo.CloneLink.HTTPS = fmt.Sprintf("%s%s/%s.git", base.AppUrl, user.LowerName, repo.LowerName) if len(params["branchname"]) == 0 { params["branchname"] = "master" |