From c8aa9c6cb1ed79398b825c6110b5a6a7002d1a35 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 1 Oct 2015 15:17:27 +0200 Subject: implemented #1721: see users who forked/starred/watched a repository --- cmd/web.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index e78cb13a..126a86a3 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -514,6 +514,9 @@ func runWeb(ctx *cli.Context) { m.Get("/labels/", repo.RetrieveLabels, repo.Labels) m.Get("/milestones", repo.Milestones) m.Get("/branches", repo.Branches) + m.Get("/stars/?:index", middleware.RepoRef(), repo.Stars) + m.Get("/watchers/?:index", middleware.RepoRef(), repo.Watchers) + m.Get("/forks", middleware.RepoRef(), repo.Forks) m.Get("/archive/*", repo.Download) m.Group("/pulls/:index", func() { -- cgit v1.2.3 From 5c39d3fa7dfcb81bdaed222a73c8a7d3dd807e36 Mon Sep 17 00:00:00 2001 From: kendaru Date: Fri, 2 Oct 2015 10:04:11 +0200 Subject: changed integrated page number to GET --- cmd/web.go | 4 ++-- models/repo.go | 2 +- routers/repo/stars.go | 6 +++--- routers/repo/watchers.go | 6 +++--- templates/repo/stars.tmpl | 6 +++--- templates/repo/watchers.tmpl | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 126a86a3..9881a76c 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -514,8 +514,8 @@ func runWeb(ctx *cli.Context) { m.Get("/labels/", repo.RetrieveLabels, repo.Labels) m.Get("/milestones", repo.Milestones) m.Get("/branches", repo.Branches) - m.Get("/stars/?:index", middleware.RepoRef(), repo.Stars) - m.Get("/watchers/?:index", middleware.RepoRef(), repo.Watchers) + m.Get("/stars", middleware.RepoRef(), repo.Stars) + m.Get("/watchers", middleware.RepoRef(), repo.Watchers) m.Get("/forks", middleware.RepoRef(), repo.Forks) m.Get("/archive/*", repo.Download) diff --git a/models/repo.go b/models/repo.go index fc155fa5..d70454fc 100644 --- a/models/repo.go +++ b/models/repo.go @@ -48,7 +48,7 @@ var ( Gitignores, Licenses, Readmes []string // Maximum items per page in forks, watchers and stars of a repo - ItemsPerPage = 3 + ItemsPerPage = 54 ) func LoadRepoConfig() { diff --git a/routers/repo/stars.go b/routers/repo/stars.go index ffccd176..93854886 100644 --- a/routers/repo/stars.go +++ b/routers/repo/stars.go @@ -19,21 +19,21 @@ const ( func Stars(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repos.stars") - page := ctx.ParamsInt(":index") + page := ctx.QueryInt("page") 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")) + stars, err := ctx.Repo.Repository.GetStars(ctx.QueryInt("page")) if err != nil { ctx.Handle(500, "GetStars", err) return } - if (ctx.ParamsInt(":index")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumStars { + if (ctx.QueryInt("page")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumStars { ctx.Handle(404, "ctx.Repo.Repository.NumStars", nil) return } diff --git a/routers/repo/watchers.go b/routers/repo/watchers.go index 8765b183..8626fa23 100644 --- a/routers/repo/watchers.go +++ b/routers/repo/watchers.go @@ -19,21 +19,21 @@ const ( func Watchers(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repos.watches") - page := ctx.ParamsInt(":index") + page := ctx.QueryInt("page") 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")) + watchers, err := ctx.Repo.Repository.GetWatchers(ctx.QueryInt("page")) if err != nil { ctx.Handle(500, "GetWatchers", err) return } - if (ctx.ParamsInt(":index")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumWatches { + if (ctx.QueryInt("page")-1)*models.ItemsPerPage > ctx.Repo.Repository.NumWatches { ctx.Handle(404, "ctx.Repo.Repository.NumWatches", nil) return } diff --git a/templates/repo/stars.tmpl b/templates/repo/stars.tmpl index 8ac67f5c..af3193dc 100644 --- a/templates/repo/stars.tmpl +++ b/templates/repo/stars.tmpl @@ -35,19 +35,19 @@ {{if gt .TotalPages 1}} {{end}} diff --git a/templates/repo/watchers.tmpl b/templates/repo/watchers.tmpl index f02b2013..03aba0e9 100644 --- a/templates/repo/watchers.tmpl +++ b/templates/repo/watchers.tmpl @@ -35,19 +35,19 @@ {{if gt .TotalPages 1}} {{end}} -- cgit v1.2.3 From b05c7b3faa54acd9b5722ee32d98f974d58b372d Mon Sep 17 00:00:00 2001 From: kendaru Date: Fri, 2 Oct 2015 10:48:31 +0200 Subject: moved routes to RouterRef group --- cmd/web.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 9881a76c..ec0e4cd7 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -514,9 +514,6 @@ func runWeb(ctx *cli.Context) { m.Get("/labels/", repo.RetrieveLabels, repo.Labels) m.Get("/milestones", repo.Milestones) m.Get("/branches", repo.Branches) - m.Get("/stars", middleware.RepoRef(), repo.Stars) - m.Get("/watchers", middleware.RepoRef(), repo.Watchers) - m.Get("/forks", middleware.RepoRef(), repo.Forks) m.Get("/archive/*", repo.Download) m.Group("/pulls/:index", func() { @@ -530,6 +527,9 @@ func runWeb(ctx *cli.Context) { m.Get("/raw/*", repo.SingleDownload) m.Get("/commits/*", repo.RefCommits) m.Get("/commit/*", repo.Diff) + m.Get("/stars", repo.Stars) + m.Get("/watchers", repo.Watchers) + m.Get("/forks", repo.Forks) }, middleware.RepoRef()) m.Get("/compare/:before([a-z0-9]{40})...:after([a-z0-9]{40})", repo.CompareDiff) -- cgit v1.2.3