implemented #1721: see users who forked/starred/watched a repository
parent
e0a099ec11
commit
ecd59deb27
@ -0,0 +1,37 @@ |
||||
// 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 repo |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/gogits/gogs/modules/base" |
||||
"github.com/gogits/gogs/modules/middleware" |
||||
) |
||||
|
||||
const ( |
||||
FORKS base.TplName = "repo/forks" |
||||
) |
||||
|
||||
func Forks(ctx *middleware.Context) { |
||||
ctx.Data["Title"] = ctx.Tr("repos.forks") |
||||
|
||||
forks, err := ctx.Repo.Repository.GetForks() |
||||
|
||||
if err != nil { |
||||
ctx.Handle(500, "GetForks", err) |
||||
return |
||||
} |
||||
|
||||
for _, fork := range forks { |
||||
if err = fork.GetOwner(); err != nil { |
||||
ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", fork.ID, err)) |
||||
return |
||||
} |
||||
} |
||||
|
||||
ctx.Data["Forks"] = forks |
||||
|
||||
ctx.HTML(200, FORKS) |
||||
} |
@ -0,0 +1,44 @@ |
||||
// 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 repo |
||||
|
||||
import ( |
||||
"github.com/Unknwon/paginater" |
||||
|
||||
"github.com/gogits/gogs/models" |
||||
"github.com/gogits/gogs/modules/base" |
||||
"github.com/gogits/gogs/modules/middleware" |
||||
) |
||||
|
||||
const ( |
||||
STARS base.TplName = "repo/stars" |
||||
) |
||||
|
||||
func Stars(ctx *middleware.Context) { |
||||
ctx.Data["Title"] = ctx.Tr("repos.stars") |
||||
|
||||
page := ctx.ParamsInt(":index") |
||||
if page <= 0 { |
||||
page = 1 |
||||
} |
||||
|
||||
ctx.Data["Page"] = paginater.New(ctx.Repo.Repository.NumStars, models.ItemsPerPage, page, 5) |
||||
|
||||
stars, err := ctx.Repo.Repository.GetStars(ctx.ParamsInt(":index")) |
||||
|
||||
if err != nil { |
||||
ctx.Handle(500, "GetStars", err) |
||||
return |
||||
} |
||||
|
||||
if (ctx.ParamsInt(":index")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumStars { |
||||
ctx.Handle(404, "ctx.Repo.Repository.NumStars", nil) |
||||
return |
||||
} |
||||
|
||||
ctx.Data["Stars"] = stars |
||||
|
||||
ctx.HTML(200, STARS) |
||||
} |
@ -0,0 +1,44 @@ |
||||
// 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 repo |
||||
|
||||
import ( |
||||
"github.com/Unknwon/paginater" |
||||
|
||||
"github.com/gogits/gogs/models" |
||||
"github.com/gogits/gogs/modules/base" |
||||
"github.com/gogits/gogs/modules/middleware" |
||||
) |
||||
|
||||
const ( |
||||
WATCHERS base.TplName = "repo/watchers" |
||||
) |
||||
|
||||
func Watchers(ctx *middleware.Context) { |
||||
ctx.Data["Title"] = ctx.Tr("repos.watches") |
||||
|
||||
page := ctx.ParamsInt(":index") |
||||
if page <= 0 { |
||||
page = 1 |
||||
} |
||||
|
||||
ctx.Data["Page"] = paginater.New(ctx.Repo.Repository.NumWatches, models.ItemsPerPage, page, 5) |
||||
|
||||
watchers, err := ctx.Repo.Repository.GetWatchers(ctx.ParamsInt(":index")) |
||||
|
||||
if err != nil { |
||||
ctx.Handle(500, "GetWatchers", err) |
||||
return |
||||
} |
||||
|
||||
if (ctx.ParamsInt(":index")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumWatches { |
||||
ctx.Handle(404, "ctx.Repo.Repository.NumWatches", nil) |
||||
return |
||||
} |
||||
|
||||
ctx.Data["Watchers"] = watchers |
||||
|
||||
ctx.HTML(200, WATCHERS) |
||||
} |
@ -0,0 +1,27 @@ |
||||
{{template "ng/base/head" .}} |
||||
{{template "ng/base/header" .}} |
||||
<div id="repo-wrapper"> |
||||
{{template "repo/header_old" .}} |
||||
<div id="repo-content" class="clear container"> |
||||
<div id="repo-main" class="left grid-5-6"> |
||||
<div id="forks"> |
||||
<h4> |
||||
<strong>{{.i18n.Tr "repos.forks"}}</strong> |
||||
</h4> |
||||
|
||||
<ol> |
||||
{{range .Forks}} |
||||
<p> |
||||
<img class="avatar-small" src="{{.Owner.AvatarLink}}"> |
||||
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a> |
||||
/ |
||||
<a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">{{.Name}}</a> |
||||
</p> |
||||
{{end}} |
||||
</div> |
||||
</div> |
||||
|
||||
{{template "repo/sidebar" .}} |
||||
</div> |
||||
</div> |
||||
{{template "ng/base/footer" .}} |
@ -0,0 +1,61 @@ |
||||
{{template "ng/base/head" .}} |
||||
{{template "ng/base/header" .}} |
||||
<div id="repo-wrapper"> |
||||
{{template "repo/header_old" .}} |
||||
<div id="repo-content" class="clear container"> |
||||
<div id="repo-main" class="left grid-5-6"> |
||||
<div id="stars"> |
||||
<h4> |
||||
<strong>{{.i18n.Tr "repos.stars"}}</strong> |
||||
</h4> |
||||
|
||||
<ol> |
||||
{{range .Stars}} |
||||
<li> |
||||
<a href="{{AppSubUrl}}/{{.Name}}"> |
||||
<img class="avatar" src="{{.AvatarLink}}" title="{{.Name}}"/> |
||||
|
||||
<h3>{{.Name}}</h3> |
||||
</a> |
||||
|
||||
<p> |
||||
{{if .Website}} |
||||
<span class="octicon octicon-link"></span> <a href="{{.Website}}" target="_blank">{{.Website}}</a> |
||||
{{else if .Location}} |
||||
<span class="octicon octicon-location"></span> {{.Location}} |
||||
{{else}} |
||||
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}} |
||||
{{end}} |
||||
</p> |
||||
</li> |
||||
{{end}} |
||||
</ol> |
||||
|
||||
{{with .Page}} |
||||
{{if gt .TotalPages 1}} |
||||
<div class="pagination"> |
||||
{{if .HasPrevious}} |
||||
<a href="{{$.RepoLink}}/stars/{{.Previous}}">{{$.i18n.Tr "issues.previous"}}</a> |
||||
{{end}} |
||||
|
||||
{{range .Pages}} |
||||
{{if eq .Num -1}} |
||||
<a class="disabled item">...</a> |
||||
{{else}} |
||||
<a class="{{if .IsCurrent}}active{{end}} item" {{if not .IsCurrent}}href="{{$.RepoLink}}/stars/{{.Num}}"{{end}}>{{.Num}}</a> |
||||
{{end}} |
||||
{{end}} |
||||
|
||||
{{if .HasNext}} |
||||
<a href="{{$.RepoLink}}/stars/{{.Next}}">{{$.i18n.Tr "issues.next"}}</a> |
||||
{{end}} |
||||
</div> |
||||
{{end}} |
||||
{{end}} |
||||
</div> |
||||
</div> |
||||
|
||||
{{template "repo/sidebar" .}} |
||||
</div> |
||||
</div> |
||||
{{template "ng/base/footer" .}} |
@ -0,0 +1,61 @@ |
||||
{{template "ng/base/head" .}} |
||||
{{template "ng/base/header" .}} |
||||
<div id="repo-wrapper"> |
||||
{{template "repo/header_old" .}} |
||||
<div id="repo-content" class="clear container"> |
||||
<div id="repo-main" class="left grid-5-6"> |
||||
<div id="stars"> |
||||
<h4> |
||||
<strong>{{.i18n.Tr "repos.watches"}}</strong> |
||||
</h4> |
||||
|
||||
<ol> |
||||
{{range .Watchers}} |
||||
<li> |
||||
<a href="{{AppSubUrl}}/{{.Name}}"> |
||||
<img class="avatar" src="{{.AvatarLink}}" title="{{.Name}}"/> |
||||
|
||||
<h3>{{.Name}}</h3> |
||||
</a> |
||||
|
||||
<p> |
||||
{{if .Website}} |
||||
<span class="octicon octicon-link"></span> <a href="{{.Website}}" target="_blank">{{.Website}}</a> |
||||
{{else if .Location}} |
||||
<span class="octicon octicon-location"></span> {{.Location}} |
||||
{{else}} |
||||
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}} |
||||
{{end}} |
||||
</p> |
||||
</li> |
||||
{{end}} |
||||
</ol> |
||||
|
||||
{{with .Page}} |
||||
{{if gt .TotalPages 1}} |
||||
<div class="pagination"> |
||||
{{if .HasPrevious}} |
||||
<a href="{{$.RepoLink}}/watchers/{{.Previous}}">{{$.i18n.Tr "issues.previous"}}</a> |
||||
{{end}} |
||||
|
||||
{{range .Pages}} |
||||
{{if eq .Num -1}} |
||||
<a class="disabled item">...</a> |
||||
{{else}} |
||||
<a class="{{if .IsCurrent}}active{{end}} item" {{if not .IsCurrent}}href="{{$.RepoLink}}/watchers/{{.Num}}"{{end}}>{{.Num}}</a> |
||||
{{end}} |
||||
{{end}} |
||||
|
||||
{{if .HasNext}} |
||||
<a href="{{$.RepoLink}}/watchers/{{.Next}}">{{$.i18n.Tr "issues.next"}}</a> |
||||
{{end}} |
||||
</div> |
||||
{{end}} |
||||
{{end}} |
||||
</div> |
||||
</div> |
||||
|
||||
{{template "repo/sidebar" .}} |
||||
</div> |
||||
</div> |
||||
{{template "ng/base/footer" .}} |
Loading…
Reference in new issue