summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-16 11:30:35 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-16 11:30:35 -0400
commit48b2425c1d49560094b2935e6451d55cd5aa1f1a (patch)
treea5db88b66e2490902c964288a1552303417ec682
parent015174484a3aa430e30801e0c3c5ce0bdc4a5bf5 (diff)
downloadgitea-48b2425c1d49560094b2935e6451d55cd5aa1f1a.tar.gz
gitea-48b2425c1d49560094b2935e6451d55cd5aa1f1a.zip
Push feed
-rw-r--r--models/action.go4
-rw-r--r--modules/base/tool.go20
2 files changed, 22 insertions, 2 deletions
diff --git a/models/action.go b/models/action.go
index ceee9997a4..978e805c88 100644
--- a/models/action.go
+++ b/models/action.go
@@ -44,6 +44,10 @@ func (a Action) GetRepoName() string {
return a.RepoName
}
+func (a Action) GetContent() string {
+ return a.Content
+}
+
// CommitRepoAction records action for commit repository.
func CommitRepoAction(userId int64, userName string,
repoId int64, repoName string, commits [][]string) error {
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 3f8b8ffa84..5746cc8fb2 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -7,6 +7,7 @@ package base
import (
"crypto/md5"
"encoding/hex"
+ "encoding/json"
"fmt"
"math"
"strings"
@@ -235,6 +236,7 @@ type Actioner interface {
GetOpType() int
GetActUserName() string
GetRepoName() string
+ GetContent() string
}
// ActionIcon accepts a int that represents action operation type
@@ -243,13 +245,19 @@ func ActionIcon(opType int) string {
switch opType {
case 1: // Create repository.
return "plus-circle"
+ case 5: // Commit repository.
+ return "arrow-circle-o-right"
default:
return "invalid type"
}
}
const (
- CreateRepoTpl = `<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>
+<ul>
+ <li><a href="/%s/%s/commit/%s">%s</a> %s</li>
+</ul>`
)
// ActionDesc accepts int that represents action operation type
@@ -257,9 +265,17 @@ const (
func ActionDesc(act Actioner) string {
actUserName := act.GetActUserName()
repoName := act.GetRepoName()
+ content := act.GetContent()
switch act.GetOpType() {
case 1: // Create repository.
- return fmt.Sprintf(CreateRepoTpl, actUserName, actUserName, actUserName, repoName, repoName)
+ return fmt.Sprintf(TPL_CREATE_REPO, actUserName, actUserName, actUserName, repoName, repoName)
+ case 5: // Commit repository.
+ var commits [][]string
+ if err := json.Unmarshal([]byte(content), &commits); err != nil {
+ return err.Error()
+ }
+ 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])
default:
return "invalid type"
}