func Install(ctx *middleware.Context) { form := auth.InstallForm{} // Database settings form.DbHost = models.DbCfg.Host form.DbUser = models.DbCfg.User form.DbName = models.DbCfg.Name form.DbPath = models.DbCfg.Path ctx.Data["CurDbOption"] = "MySQL" switch models.DbCfg.Type { case "postgres": ctx.Data["CurDbOption"] = "PostgreSQL" case "sqlite3": if models.EnableSQLite3 { ctx.Data["CurDbOption"] = "SQLite3" } case "tidb": if models.EnableTidb { ctx.Data["CurDbOption"] = "TiDB" } } // Application general settings form.AppName = setting.AppName form.RepoRootPath = setting.RepoRootPath // Note(unknwon): it's hard for Windows users change a running user, // so just use current one if config says default. if setting.IsWindows && setting.RunUser == "git" { form.RunUser = user.CurrentUsername() } else { form.RunUser = setting.RunUser } form.Domain = setting.Domain form.SSHPort = setting.SSHPort form.HTTPPort = setting.HttpPort form.AppUrl = setting.AppUrl // E-mail service settings if setting.MailService != nil { form.SMTPHost = setting.MailService.Host form.SMTPFrom = setting.MailService.From form.SMTPEmail = setting.MailService.User } form.RegisterConfirm = setting.Service.RegisterEmailConfirm form.MailNotify = setting.Service.EnableNotifyMail // Server and other services settings form.OfflineMode = setting.OfflineMode form.DisableGravatar = setting.DisableGravatar form.DisableRegistration = setting.Service.DisableRegistration form.EnableCaptcha = setting.Service.EnableCaptcha form.RequireSignInView = setting.Service.RequireSignInView auth.AssignForm(form, ctx.Data) ctx.HTML(200, INSTALL) }
// RenderWithErr used for page has form validation but need to prompt error to users. func (ctx *Context) RenderWithErr(msg string, tpl base.TplName, form interface{}) { if form != nil { auth.AssignForm(form, ctx.Data) } ctx.Flash.ErrorMsg = msg ctx.Data["Flash"] = ctx.Flash ctx.HTML(200, tpl) }