Browse Source

Merge branch 'master' of github.com:gogits/gogs

Conflicts:
	routers/user/user.go
	web.go
pull/31/head
slene 11 years ago
parent
commit
a33d03f008
  1. 2
      README.md
  2. 1
      models/action.go
  3. 4
      models/repo2.go
  4. 2
      modules/auth/user.go
  5. 23
      routers/user/user.go
  6. 8
      templates/repo/created.tmpl
  7. 12
      templates/user/dashboard.tmpl
  8. 2
      templates/user/profile.tmpl
  9. 2
      web.go

2
README.md

@ -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. 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 ## Purpose

1
models/action.go

@ -56,6 +56,7 @@ func NewRepoAction(user *User, repo *Repository) error {
return err return err
} }
// GetFeeds returns action list of given user in given context.
func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) { func GetFeeds(userid, offset int64, isProfile bool) ([]Action, error) {
actions := make([]Action, 0, 20) actions := make([]Action, 0, 20)
sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid) sess := orm.Limit(20, int(offset)).Desc("id").Where("user_id=?", userid)

4
models/repo2.go

@ -1,3 +1,7 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package models package models
import ( import (

2
modules/auth/user.go

@ -63,7 +63,7 @@ func IsSignedIn(session sessions.Session) bool {
type FeedsForm struct { type FeedsForm struct {
UserId int64 `form:"userid" binding:"Required"` UserId int64 `form:"userid" binding:"Required"`
Offset int64 `form:"offset"` Page int64 `form:"p"`
} }
type UpdateProfileForm struct { type UpdateProfileForm struct {

23
routers/user/user.go

@ -5,6 +5,7 @@
package user package user
import ( import (
"fmt"
"net/http" "net/http"
"github.com/codegangsta/martini" "github.com/codegangsta/martini"
@ -27,6 +28,13 @@ func Dashboard(r render.Render, data base.TmplData, session sessions.Session) {
return return
} }
data["MyRepos"] = repos 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) r.HTML(200, "user/dashboard", data)
} }
@ -172,10 +180,21 @@ func Delete(data base.TmplData, req *http.Request, session sessions.Session, r r
r.HTML(200, "user/delete", data) 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) { 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 { if err != nil {
r.JSON(500, err) 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)
} }

8
templates/repo/created.tmpl

@ -1,8 +0,0 @@
{{template "base/head" .}}
{{template "base/navbar" .}}
<div class="container" id="gogs-body">
<div class="col-md-offset-4 col-md-3">
Created successfully!
</div>
</div>
{{template "base/footer" .}}

12
templates/user/dashboard.tmpl

@ -14,7 +14,17 @@
<div id="gogs-body" class="container"> <div id="gogs-body" class="container">
{{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}} {{if .HasInfo}}<div class="alert alert-info">{{.InfoMsg}}</div>{{end}}
<div id="gogs-feed-left" class="col-md-8"> <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>
<div id="gogs-feed-right" class="col-md-4"> <div id="gogs-feed-right" class="col-md-4">
<div class="panel panel-default repo-panel"> <div class="panel panel-default repo-panel">

2
templates/user/profile.tmpl

@ -39,7 +39,7 @@
<span class="clearfix"></span> <span class="clearfix"></span>
</li> </li>
{{else}} {{else}}
<li>Not found any activity</li> <li>Not any public activity yet.</li>
{{end}} {{end}}
</ul> </ul>
</div> </div>

2
web.go

@ -49,7 +49,7 @@ func runWeb(*cli.Context) {
m.Use(middleware.InitContext()) m.Use(middleware.InitContext())
// Routers. // Routers.
m.Get("/", middleware.SignInRequire(false), routers.Home) m.Get("/", middleware.SignInRequire(true), routers.Home)
m.Any("/user/login", middleware.SignOutRequire(), binding.BindIgnErr(auth.LogInForm{}), user.SignIn) m.Any("/user/login", middleware.SignOutRequire(), binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
m.Any("/user/logout", middleware.SignInRequire(true), user.SignOut) m.Any("/user/logout", middleware.SignInRequire(true), user.SignOut)
m.Any("/user/sign_up", middleware.SignOutRequire(), binding.BindIgnErr(auth.RegisterForm{}), user.SignUp) m.Any("/user/sign_up", middleware.SignOutRequire(), binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)

Loading…
Cancel
Save