Finish feeds
This commit is contained in:
parent
06deed820d
commit
4b8e888437
6 changed files with 44 additions and 24 deletions
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0b
|
|||
|
||||
Gogs(Go Git Service) is a GitHub-like clone in the Go Programming Language, it currently supports Linux and Max OS X, but Windows has **NOT** supported yet due to installation problem with [libgit2](http://libgit2.github.com/) in Windows.
|
||||
|
||||
##### Current version: 0.0.7 Alpha
|
||||
##### Current version: 0.0.8 Alpha
|
||||
|
||||
## Purpose
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ func NewRepoAction(user *User, repo *Repository) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// GetFeeds returns action list of given user in given context.
|
||||
func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) {
|
||||
actions := make([]Action, 0, 20)
|
||||
sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid)
|
||||
|
|
|
@ -97,7 +97,7 @@ func SignOutRequire() martini.Handler {
|
|||
|
||||
type FeedsForm struct {
|
||||
UserId int64 `form:"userid" binding:"Required"`
|
||||
Offset int64 `form:"offset"`
|
||||
Page int64 `form:"p"`
|
||||
}
|
||||
|
||||
type UpdateProfileForm struct {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/codegangsta/martini"
|
||||
|
@ -26,10 +27,17 @@ func Dashboard(r render.Render, data base.TmplData, session sessions.Session) {
|
|||
return
|
||||
}
|
||||
data["MyRepos"] = repos
|
||||
|
||||
feeds, err := models.GetFeeds(auth.SignedInId(session), 0, false)
|
||||
if err != nil {
|
||||
log.Handle(200, "user.Dashboard", data, r, err)
|
||||
return
|
||||
}
|
||||
data["Feeds"] = feeds
|
||||
r.HTML(200, "user/dashboard", data)
|
||||
}
|
||||
|
||||
func Profile(params martini.Params, r render.Render, req *http.Request, data base.TmplData, session sessions.Session) {
|
||||
func Profile(params martini.Params, req *http.Request, r render.Render, data base.TmplData, session sessions.Session) {
|
||||
data["Title"] = "Profile"
|
||||
|
||||
// TODO: Need to check view self or others.
|
||||
|
@ -40,23 +48,13 @@ func Profile(params martini.Params, r render.Render, req *http.Request, data bas
|
|||
}
|
||||
|
||||
data["Owner"] = user
|
||||
|
||||
req.ParseForm()
|
||||
tab := req.Form.Get("tab")
|
||||
data["TabName"] = tab
|
||||
|
||||
switch tab {
|
||||
case "activity":
|
||||
data["TabName"] = req.FormValue("tab")
|
||||
feeds, err := models.GetFeeds(user.Id, 0, true)
|
||||
if err != nil {
|
||||
log.Handle(200, "user.Profile", data, r, err)
|
||||
return
|
||||
}
|
||||
data["Feeds"] = feeds
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
r.HTML(200, "user/profile", data)
|
||||
}
|
||||
|
||||
|
@ -172,10 +170,21 @@ func Delete(data base.TmplData, req *http.Request, session sessions.Session, r r
|
|||
r.HTML(200, "user/delete", data)
|
||||
}
|
||||
|
||||
const (
|
||||
feedTpl = `<i class="icon fa fa-%s"></i>
|
||||
<div class="info"><span class="meta">%s</span><br>%s</div>`
|
||||
)
|
||||
|
||||
func Feeds(form auth.FeedsForm, r render.Render) {
|
||||
actions, err := models.GetFeeds(form.UserId, form.Offset, false)
|
||||
actions, err := models.GetFeeds(form.UserId, form.Page*20, false)
|
||||
if err != nil {
|
||||
r.JSON(500, err)
|
||||
}
|
||||
r.JSON(200, actions)
|
||||
|
||||
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]))
|
||||
}
|
||||
r.JSON(200, &feeds)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,17 @@
|
|||
<div id="gogs-body" class="container">
|
||||
{{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
|
||||
<div id="gogs-feed-left" class="col-md-8">
|
||||
Website is still in the progress of building...please come back later! <strong>{{.SignedUserName}}</strong> is logged!
|
||||
<ul class="list-unstyled activity-list">
|
||||
{{range .Feeds}}
|
||||
<li>
|
||||
<i class="icon fa fa-{{ActionIcon .OpType}}"></i>
|
||||
<div class="info"><span class="meta">{{TimeSince .Created}}</span><br>{{ActionDesc . | str2html}}</div>
|
||||
<span class="clearfix"></span>
|
||||
</li>
|
||||
{{else}}
|
||||
<li>Not any activity yet.</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
<div id="gogs-feed-right" class="col-md-4">
|
||||
<div class="panel panel-default repo-panel">
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<span class="clearfix"></span>
|
||||
</li>
|
||||
{{else}}
|
||||
<li>Not found any activity</li>
|
||||
<li>Not any public activity yet.</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue