From 11f54b142699b59a74b9babc195e712414a3c78a Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 11 Apr 2014 12:14:11 -0400 Subject: [PATCH] Mirror bug fix --- modules/base/template.go | 3 + modules/middleware/context.go | 2 +- routers/user/user.go | 14 +- templates/repo/diff.tmpl | 330 +--------------------------------- 4 files changed, 13 insertions(+), 336 deletions(-) diff --git a/modules/base/template.go b/modules/base/template.go index 5a42107c..62414979 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -67,6 +67,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "TimeSince": TimeSince, "FileSize": FileSize, "Subtract": Subtract, + "Add": func(a, b int) int { + return a + b + }, "ActionIcon": ActionIcon, "ActionDesc": ActionDesc, "DateFormat": DateFormat, diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 6ee94b96..e7f962c3 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -103,7 +103,7 @@ func (ctx *Context) RenderWithErr(msg, tpl string, form auth.Form) { func (ctx *Context) Handle(status int, title string, err error) { log.Error("%s: %v", title, err) if martini.Dev == martini.Prod { - ctx.HTML(500, "status/500") + ctx.HTML(200, "status/500") return } diff --git a/routers/user/user.go b/routers/user/user.go index 37c6baa9..39dfa462 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -24,14 +24,14 @@ func Dashboard(ctx *middleware.Context) { ctx.Data["PageIsUserDashboard"] = true repos, err := models.GetRepositories(&models.User{Id: ctx.User.Id}) if err != nil { - ctx.Handle(200, "user.Dashboard", err) + ctx.Handle(500, "user.Dashboard", err) return } ctx.Data["MyRepos"] = repos feeds, err := models.GetFeeds(ctx.User.Id, 0, false) if err != nil { - ctx.Handle(200, "user.Dashboard", err) + ctx.Handle(500, "user.Dashboard", err) return } ctx.Data["Feeds"] = feeds @@ -44,7 +44,7 @@ func Profile(ctx *middleware.Context, params martini.Params) { // TODO: Need to check view self or others. user, err := models.GetUserByName(params["username"]) if err != nil { - ctx.Handle(200, "user.Profile", err) + ctx.Handle(500, "user.Profile", err) return } @@ -57,14 +57,14 @@ func Profile(ctx *middleware.Context, params martini.Params) { case "activity": feeds, err := models.GetFeeds(user.Id, 0, true) if err != nil { - ctx.Handle(200, "user.Profile", err) + ctx.Handle(500, "user.Profile", err) return } ctx.Data["Feeds"] = feeds default: repos, err := models.GetRepositories(user) if err != nil { - ctx.Handle(200, "user.Profile", err) + ctx.Handle(500, "user.Profile", err) return } ctx.Data["Repos"] = repos @@ -100,14 +100,14 @@ func SignIn(ctx *middleware.Context) { user, err := models.GetUserByName(userName) if err != nil { - ctx.HTML(200, "user/signin") + ctx.HTML(500, "user/signin") return } secret := base.EncodeMd5(user.Rands + user.Passwd) value, _ := ctx.GetSecureCookie(secret, base.CookieRememberName) if value != user.Name { - ctx.HTML(200, "user/signin") + ctx.HTML(500, "user/signin") return } diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 396aa795..a041284d 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -30,7 +30,7 @@ {{range .Diff.Files}}
  • - {{if Subtract .Addition .Deletion}} + {{if Add .Addition .Deletion}} {{.Addition}} @@ -53,7 +53,7 @@
    - {{if Subtract .Addition .Deletion}} + {{if Add .Addition .Deletion}} + {{.Addition}} @@ -91,338 +91,12 @@ {{end}} {{end}} - {{end}}
    {{end}} - -
    {{template "base/footer" .}}