From ec65be79f0337b11c01121eae9fd54fe49bee830 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 16 Mar 2014 12:07:35 -0400 Subject: [PATCH] Fix commit feed ui --- gogs.go | 2 +- modules/base/tool.go | 17 ++++++++++------- public/css/gogs.css | 6 ++++++ routers/user/user.go | 2 +- templates/user/profile.tmpl | 3 ++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/gogs.go b/gogs.go index 9d1f2032d6..2d5283f3af 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.0.8.0316.1" +const APP_VER = "0.0.9.0316.1" func init() { base.AppVer = APP_VER diff --git a/modules/base/tool.go b/modules/base/tool.go index 5746cc8fb2..10b3fee375 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -5,6 +5,7 @@ package base import ( + "bytes" "crypto/md5" "encoding/hex" "encoding/json" @@ -253,16 +254,14 @@ func ActionIcon(opType int) string { } const ( - TPL_CREATE_REPO = `%s created repository %s` - TPL_COMMIT_REPO = `%s pushed to %s at %s/%s -` + TPL_CREATE_REPO = `%s created repository %s` + TPL_COMMIT_REPO = `%s pushed to %s at %s/%s%s` + TPL_COMMIT_REPO_LI = `
user-avatar %s %s
` ) // ActionDesc accepts int that represents action operation type // and returns the description. -func ActionDesc(act Actioner) string { +func ActionDesc(act Actioner, avatarLink string) string { actUserName := act.GetActUserName() repoName := act.GetRepoName() content := act.GetContent() @@ -274,8 +273,12 @@ func ActionDesc(act Actioner) string { if err := json.Unmarshal([]byte(content), &commits); err != nil { return err.Error() } + buf := bytes.NewBuffer([]byte("\n")) + for _, commit := range commits { + buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n") + } return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, "master", "master", actUserName, repoName, actUserName, repoName, - actUserName, repoName, commits[0][0], commits[0][0][:7], commits[0][1]) + buf.String()) default: return "invalid type" } diff --git a/public/css/gogs.css b/public/css/gogs.css index 89da6055b8..45ce5d21d5 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -228,6 +228,12 @@ html, body { border-radius: 6px; } +#gogs-user-avatar-commit { + width: 16px; + height: 16px; + border-radius: 2px; +} + #gogs-user-name { margin-top: 20px; font-size: 1.6em; diff --git a/routers/user/user.go b/routers/user/user.go index 0ff5058dcc..c43cf84a24 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -195,7 +195,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) { feeds := make([]string, len(actions)) for i := range actions { feeds[i] = fmt.Sprintf(feedTpl, base.ActionIcon(actions[i].OpType), - base.TimeSince(actions[i].Created), base.ActionDesc(actions[i])) + base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink())) } ctx.Render.JSON(200, &feeds) } diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 84d3b13c92..24ae76fef8 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -32,10 +32,11 @@ {{if eq .TabName "activity"}}