mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 07:47:52 +01:00
Fix commit feed ui
This commit is contained in:
parent
c97a435d73
commit
ec65be79f0
2
gogs.go
2
gogs.go
@ -20,7 +20,7 @@ import (
|
|||||||
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
|
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
|
||||||
const go11tag = true
|
const go11tag = true
|
||||||
|
|
||||||
const APP_VER = "0.0.8.0316.1"
|
const APP_VER = "0.0.9.0316.1"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
base.AppVer = APP_VER
|
base.AppVer = APP_VER
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -253,16 +254,14 @@ func ActionIcon(opType int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s/%s">%s</a>`
|
TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s/%s">%s</a>`
|
||||||
TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/%s/tree/%s">%s</a> at <a href="/%s/%s">%s/%s</a>
|
TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/%s/tree/%s">%s</a> at <a href="/%s/%s">%s/%s</a>%s`
|
||||||
<ul>
|
TPL_COMMIT_REPO_LI = `<div><img id="gogs-user-avatar-commit" src="%s?s=16" alt="user-avatar" title="username"/> <a href="/%s/%s/commit/%s">%s</a> %s</div>`
|
||||||
<li><a href="/%s/%s/commit/%s">%s</a> %s</li>
|
|
||||||
</ul>`
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ActionDesc accepts int that represents action operation type
|
// ActionDesc accepts int that represents action operation type
|
||||||
// and returns the description.
|
// and returns the description.
|
||||||
func ActionDesc(act Actioner) string {
|
func ActionDesc(act Actioner, avatarLink string) string {
|
||||||
actUserName := act.GetActUserName()
|
actUserName := act.GetActUserName()
|
||||||
repoName := act.GetRepoName()
|
repoName := act.GetRepoName()
|
||||||
content := act.GetContent()
|
content := act.GetContent()
|
||||||
@ -274,8 +273,12 @@ func ActionDesc(act Actioner) string {
|
|||||||
if err := json.Unmarshal([]byte(content), &commits); err != nil {
|
if err := json.Unmarshal([]byte(content), &commits); err != nil {
|
||||||
return err.Error()
|
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,
|
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:
|
default:
|
||||||
return "invalid type"
|
return "invalid type"
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,12 @@ html, body {
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gogs-user-avatar-commit {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
#gogs-user-name {
|
#gogs-user-name {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
|
@ -195,7 +195,7 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
|
|||||||
feeds := make([]string, len(actions))
|
feeds := make([]string, len(actions))
|
||||||
for i := range actions {
|
for i := range actions {
|
||||||
feeds[i] = fmt.Sprintf(feedTpl, base.ActionIcon(actions[i].OpType),
|
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)
|
ctx.Render.JSON(200, &feeds)
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,11 @@
|
|||||||
{{if eq .TabName "activity"}}
|
{{if eq .TabName "activity"}}
|
||||||
<div class="tab-pane active">
|
<div class="tab-pane active">
|
||||||
<ul class="list-unstyled activity-list">
|
<ul class="list-unstyled activity-list">
|
||||||
|
{{$avatarLink := .Owner.AvatarLink}}
|
||||||
{{range .Feeds}}
|
{{range .Feeds}}
|
||||||
<li>
|
<li>
|
||||||
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
||||||
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
|
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . $avatarLink | str2html}}</div>
|
||||||
<span class="clearfix"></span>
|
<span class="clearfix"></span>
|
||||||
</li>
|
</li>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
Loading…
Reference in New Issue
Block a user