| @@ -43,8 +43,8 @@ There are two ways to install Gogs: | |||||
| ## Acknowledgments | ## Acknowledgments | ||||
| - Logo is inspired by [martini](https://github.com/martini-contrib). | - Logo is inspired by [martini](https://github.com/martini-contrib). | ||||
| - Mail Service is based on [WeTalk](https://github.com/beego/wetalk). | |||||
| - System Monitor Status is based on [GoBlog](https://github.com/fuxiaohei/goblog). | |||||
| - Mail Service, modules design is inspired by [WeTalk](https://github.com/beego/wetalk). | |||||
| - System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog). | |||||
| ## Contributors | ## Contributors | ||||
| @@ -107,7 +107,7 @@ SERVICE = server | |||||
| PATH = data/pictures | PATH = data/pictures | ||||
| [log] | [log] | ||||
| ; Either "console", "file", "conn" or "smtp", default is "console" | |||||
| ; Either "console", "file", "conn", "smtp" or "database", default is "console" | |||||
| MODE = console | MODE = console | ||||
| ; Buffer length of channel, keep it as it is if you don't know what it is. | ; Buffer length of channel, keep it as it is if you don't know what it is. | ||||
| BUFFER_LEN = 10000 | BUFFER_LEN = 10000 | ||||
| @@ -156,4 +156,10 @@ HOST = | |||||
| USER = | USER = | ||||
| PASSWD = | PASSWD = | ||||
| ; Receivers, can be one or more, e.g. ["1@example.com","2@example.com"] | ; Receivers, can be one or more, e.g. ["1@example.com","2@example.com"] | ||||
| RECEIVERS = | |||||
| RECEIVERS = | |||||
| ; For "database" mode only | |||||
| [log.database] | |||||
| LEVEL = | |||||
| Driver = | |||||
| CONN = | |||||
| @@ -143,6 +143,10 @@ func newLogService() { | |||||
| Cfg.MustValue(modeSec, "HOST", "127.0.0.1:25"), | Cfg.MustValue(modeSec, "HOST", "127.0.0.1:25"), | ||||
| Cfg.MustValue(modeSec, "RECEIVERS", "[]"), | Cfg.MustValue(modeSec, "RECEIVERS", "[]"), | ||||
| Cfg.MustValue(modeSec, "SUBJECT", "Diagnostic message from serve")) | Cfg.MustValue(modeSec, "SUBJECT", "Diagnostic message from serve")) | ||||
| case "database": | |||||
| LogConfig = fmt.Sprintf(`{"level":%s,"driver":%s,"conn":%s}`, level, | |||||
| Cfg.MustValue(modeSec, "Driver"), | |||||
| Cfg.MustValue(modeSec, "CONN")) | |||||
| } | } | ||||
| log.NewLogger(Cfg.MustInt64("log", "BUFFER_LEN", 10000), LogMode, LogConfig) | log.NewLogger(Cfg.MustInt64("log", "BUFFER_LEN", 10000), LogMode, LogConfig) | ||||
| @@ -5,6 +5,8 @@ | |||||
| package middleware | package middleware | ||||
| import ( | import ( | ||||
| "net/url" | |||||
| "github.com/codegangsta/martini" | "github.com/codegangsta/martini" | ||||
| "github.com/gogits/gogs/modules/base" | "github.com/gogits/gogs/modules/base" | ||||
| @@ -35,6 +37,7 @@ func Toggle(options *ToggleOptions) martini.Handler { | |||||
| if options.SignInRequire { | if options.SignInRequire { | ||||
| if !ctx.IsSigned { | if !ctx.IsSigned { | ||||
| ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI)) | |||||
| ctx.Redirect("/user/login") | ctx.Redirect("/user/login") | ||||
| return | return | ||||
| } else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm { | } else if !ctx.User.IsActive && base.Service.RegisterEmailConfirm { | ||||
| @@ -140,5 +140,5 @@ func DeleteUser(ctx *middleware.Context, params martini.Params) { | |||||
| log.Trace("%s User deleted by admin(%s): %s", ctx.Req.RequestURI, | log.Trace("%s User deleted by admin(%s): %s", ctx.Req.RequestURI, | ||||
| ctx.User.LowerName, ctx.User.LowerName) | ctx.User.LowerName, ctx.User.LowerName) | ||||
| ctx.Redirect("/admin/users", 302) | |||||
| ctx.Redirect("/admin/users") | |||||
| } | } | ||||
| @@ -56,7 +56,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat | |||||
| form.IssueName, form.Labels, form.Content, false) | form.IssueName, form.Labels, form.Content, false) | ||||
| if err == nil { | if err == nil { | ||||
| log.Trace("%s Issue created: %d", form.RepoId, issue.Id) | log.Trace("%s Issue created: %d", form.RepoId, issue.Id) | ||||
| ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index), 302) | |||||
| ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", params["username"], params["reponame"], issue.Index)) | |||||
| return | return | ||||
| } | } | ||||
| ctx.Handle(200, "issue.CreateIssue", err) | ctx.Handle(200, "issue.CreateIssue", err) | ||||
| @@ -40,7 +40,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) { | |||||
| form.Language, form.License, form.Visibility == "private", form.InitReadme == "on") | form.Language, form.License, form.Visibility == "private", form.InitReadme == "on") | ||||
| if err == nil { | if err == nil { | ||||
| log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, form.RepoName) | log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, form.RepoName) | ||||
| ctx.Redirect("/"+ctx.User.Name+"/"+form.RepoName, 302) | |||||
| ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName) | |||||
| return | return | ||||
| } else if err == models.ErrRepoAlreadyExist { | } else if err == models.ErrRepoAlreadyExist { | ||||
| ctx.RenderWithErr("Repository name has already been used", "repo/create", &form) | ctx.RenderWithErr("Repository name has already been used", "repo/create", &form) | ||||
| @@ -73,7 +73,7 @@ func SettingPost(ctx *middleware.Context) { | |||||
| } | } | ||||
| log.Trace("%s Repository deleted: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.Repo.Repository.LowerName) | log.Trace("%s Repository deleted: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.Repo.Repository.LowerName) | ||||
| ctx.Redirect("/", 302) | |||||
| ctx.Redirect("/") | |||||
| } | } | ||||
| func Branches(ctx *middleware.Context, params martini.Params) { | func Branches(ctx *middleware.Context, params martini.Params) { | ||||
| @@ -113,8 +113,8 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||
| treename := params["_1"] | treename := params["_1"] | ||||
| if len(treename) > 0 && treename[len(treename)-1] == '/' { | if len(treename) > 0 && treename[len(treename)-1] == '/' { | ||||
| ctx.Redirect("/"+ctx.Repo.Owner.LowerName+"/"+ | |||||
| ctx.Repo.Repository.Name+"/src/"+params["branchname"]+"/"+treename[:len(treename)-1], 302) | |||||
| ctx.Redirect("/" + ctx.Repo.Owner.LowerName + "/" + | |||||
| ctx.Repo.Repository.Name + "/src/" + params["branchname"] + "/" + treename[:len(treename)-1]) | |||||
| return | return | ||||
| } | } | ||||
| @@ -6,6 +6,7 @@ package user | |||||
| import ( | import ( | ||||
| "fmt" | "fmt" | ||||
| "net/url" | |||||
| "strings" | "strings" | ||||
| "github.com/codegangsta/martini" | "github.com/codegangsta/martini" | ||||
| @@ -109,7 +110,13 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { | |||||
| isSucceed = true | isSucceed = true | ||||
| ctx.Session.Set("userId", user.Id) | ctx.Session.Set("userId", user.Id) | ||||
| ctx.Session.Set("userName", user.Name) | ctx.Session.Set("userName", user.Name) | ||||
| ctx.Redirect("/") | |||||
| redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")) | |||||
| if len(redirectTo) > 0 { | |||||
| ctx.SetCookie("redirect_to", "", -1) | |||||
| ctx.Redirect(redirectTo) | |||||
| } else { | |||||
| ctx.Redirect("/") | |||||
| } | |||||
| return | return | ||||
| } | } | ||||
| @@ -139,12 +146,20 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { | |||||
| ctx.Session.Set("userId", user.Id) | ctx.Session.Set("userId", user.Id) | ||||
| ctx.Session.Set("userName", user.Name) | ctx.Session.Set("userName", user.Name) | ||||
| ctx.Redirect("/") | |||||
| redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")) | |||||
| if len(redirectTo) > 0 { | |||||
| ctx.SetCookie("redirect_to", "", -1) | |||||
| ctx.Redirect(redirectTo) | |||||
| } else { | |||||
| ctx.Redirect("/") | |||||
| } | |||||
| } | } | ||||
| func SignOut(ctx *middleware.Context) { | func SignOut(ctx *middleware.Context) { | ||||
| ctx.Session.Delete("userId") | ctx.Session.Delete("userId") | ||||
| ctx.Session.Delete("userName") | ctx.Session.Delete("userName") | ||||
| ctx.SetCookie(base.CookieUserName, "", -1) | |||||
| ctx.SetCookie(base.CookieRememberName, "", -1) | |||||
| ctx.Redirect("/") | ctx.Redirect("/") | ||||
| } | } | ||||
| @@ -314,7 +329,7 @@ func Activate(ctx *middleware.Context) { | |||||
| ctx.Session.Set("userId", user.Id) | ctx.Session.Set("userId", user.Id) | ||||
| ctx.Session.Set("userName", user.Name) | ctx.Session.Set("userName", user.Name) | ||||
| ctx.Redirect("/", 302) | |||||
| ctx.Redirect("/") | |||||
| return | return | ||||
| } | } | ||||