aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/action.go31
-rw-r--r--routers/user/user.go17
-rw-r--r--web.go7
3 files changed, 16 insertions, 39 deletions
diff --git a/models/action.go b/models/action.go
index cae093ecbe..810f24b656 100644
--- a/models/action.go
+++ b/models/action.go
@@ -5,7 +5,6 @@
package models
import (
- "encoding/json"
"time"
)
@@ -21,30 +20,24 @@ const (
// An Action represents
type Action struct {
- Id int64
- UserId int64
- OpType int
- RepoId int64
- Content string
- Created time.Time `xorm:"created"`
-}
-
-type NewRepoContent struct {
+ Id int64
+ UserId int64
UserName string
+ OpType int
+ RepoId int64
RepoName string
+ Content string
+ Created time.Time `xorm:"created"`
}
// NewRepoAction inserts action for create repository.
func NewRepoAction(user *User, repo *Repository) error {
- content, err := json.Marshal(&NewRepoContent{user.Name, repo.Name})
- if err != nil {
- return err
- }
- _, err = orm.InsertOne(&Action{
- UserId: user.Id,
- OpType: OP_CREATE_REPO,
- RepoId: repo.Id,
- Content: string(content),
+ _, err := orm.InsertOne(&Action{
+ UserId: user.Id,
+ UserName: user.Name,
+ OpType: OP_CREATE_REPO,
+ RepoId: repo.Id,
+ RepoName: repo.Name,
})
return err
}
diff --git a/routers/user/user.go b/routers/user/user.go
index ae9dd90290..59177a47b9 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -5,7 +5,6 @@
package user
import (
- "bytes"
"net/http"
"github.com/codegangsta/martini"
@@ -167,20 +166,10 @@ func Delete(data base.TmplData, req *http.Request, session sessions.Session, r r
r.HTML(200, "user/delete", data)
}
-func Feeds(form auth.FeedsForm, r render.Render) string {
+func Feeds(form auth.FeedsForm, r render.Render) {
actions, err := models.GetFeeds(form.UserId, form.Offset)
if err != nil {
- return err.Error()
+ r.JSON(500, err)
}
-
- length := len(actions)
- buf := bytes.NewBuffer([]byte("["))
- for i, action := range actions {
- buf.WriteString(action.Content)
- if i < length-1 {
- buf.WriteString(",")
- }
- }
- buf.WriteString("]")
- return buf.String()
+ r.JSON(200, actions)
}
diff --git a/web.go b/web.go
index 8e5bbaef0f..9b7eff883d 100644
--- a/web.go
+++ b/web.go
@@ -30,10 +30,7 @@ var CmdWeb = cli.Command{
Description: `
gogs web`,
Action: runWeb,
- Flags: []cli.Flag{
- //cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"},
- //cli.BoolFlag{"verbose, v", "show process details"},
- },
+ Flags: []cli.Flag{},
}
var AppHelpers template.FuncMap = map[string]interface{}{
@@ -78,8 +75,6 @@ func runWeb(*cli.Context) {
//m.Get("/:username/:reponame", repo.Repo)
- //m.Get("/:username/:reponame", repo.Repo)
-
listenAddr := fmt.Sprintf("%s:%s",
base.Cfg.MustValue("server", "HTTP_ADDR"),
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))