summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2015-02-01 12:41:03 -0500
committerUnknwon <joe2010xtmf@163.com>2015-02-01 12:41:03 -0500
commitb293b6eaa6b305bbac2147f76d5722607e8aa04b (patch)
tree92e60483c65594729b7bbcf60ca9d15b1932be1f /modules
parent3d9cda2d98940102b1bdffc053e036cc696b9f8e (diff)
downloadgitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.tar.gz
gitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.zip
cmd: CMD option for port number of `gogs web` to prevent first time run conflict
- routers: use new binding convention to simplify code - templates: able to set HTTP port number in install page
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/auth.go7
-rw-r--r--modules/auth/user_form.go41
-rw-r--r--modules/setting/setting.go2
3 files changed, 29 insertions, 21 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go
index 1dd96d8d40..ad7ce5b9ad 100644
--- a/modules/auth/auth.go
+++ b/modules/auth/auth.go
@@ -9,6 +9,7 @@ import (
"reflect"
"strings"
+ "github.com/Unknwon/com"
"github.com/Unknwon/macaron"
"github.com/macaron-contrib/binding"
"github.com/macaron-contrib/session"
@@ -135,6 +136,10 @@ type Form interface {
binding.Validator
}
+func init() {
+ binding.SetNameMapper(com.ToSnakeCase)
+}
+
// AssignForm assign form values back to the template data.
func AssignForm(form interface{}, data map[string]interface{}) {
typ := reflect.TypeOf(form)
@@ -152,6 +157,8 @@ func AssignForm(form interface{}, data map[string]interface{}) {
// Allow ignored fields in the struct
if fieldName == "-" {
continue
+ } else if len(fieldName) == 0 {
+ fieldName = com.ToSnakeCase(field.Name)
}
data[fieldName] = val.Field(i).Interface()
diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go
index becd5cbca8..3c0ff65174 100644
--- a/modules/auth/user_form.go
+++ b/modules/auth/user_form.go
@@ -12,26 +12,27 @@ import (
)
type InstallForm struct {
- Database string `form:"database" binding:"Required"`
- DbHost string `form:"host"`
- DbUser string `form:"user"`
- DbPasswd string `form:"passwd"`
- DatabaseName string `form:"database_name"`
- SslMode string `form:"ssl_mode"`
- DatabasePath string `form:"database_path"`
- RepoRootPath string `form:"repo_path" binding:"Required"`
- RunUser string `form:"run_user" binding:"Required"`
- Domain string `form:"domain" binding:"Required"`
- AppUrl string `form:"app_url" binding:"Required"`
- 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"`
- AdminName string `form:"admin_name" binding:"Required;AlphaDashDot;MaxSize(30)"`
- AdminPasswd string `form:"admin_pwd" binding:"Required;MinSize(6);MaxSize(255)"`
- ConfirmPasswd string `form:"confirm_passwd" binding:"Required;MinSize(6);MaxSize(255)"`
- AdminEmail string `form:"admin_email" binding:"Required;Email;MaxSize(50)"`
+ DbType string `binding:"Required"`
+ DbHost string
+ DbUser string
+ DbPasswd string
+ DbName string
+ SSLMode string
+ DbPath string
+ RepoRootPath string `binding:"Required"`
+ RunUser string `binding:"Required"`
+ Domain string `binding:"Required"`
+ HTTPPort string `binding:"Required"`
+ AppUrl string `binding:"Required"`
+ SMTPHost string
+ SMTPEmail string
+ SMTPPasswd string
+ RegisterConfirm string
+ MailNotify string
+ AdminName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
+ AdminPasswd string `binding:"Required;MinSize(6);MaxSize(255)"`
+ AdminConfirmPasswd string `binding:"Required;MinSize(6);MaxSize(255)"`
+ AdminEmail string `binding:"Required;Email;MaxSize(50)"`
}
func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index bc9da3c63a..e7c44cdd4f 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -178,7 +178,7 @@ func NewConfigContext() {
log.Fatal(4, "Fail to load custom 'conf/app.ini': %v", err)
}
} else {
- log.Warn("No custom 'conf/app.ini' found, please go to '/install'")
+ log.Warn("No custom 'conf/app.ini' found, ignore this if you're running first time")
}
Cfg.NameMapper = ini.AllCapsUnderscore