Add release tmpl
This commit is contained in:
parent
97b133bbee
commit
db66b8da72
8 changed files with 59 additions and 8 deletions
|
@ -56,6 +56,25 @@ func GetBranches(userName, repoName string) ([]string, error) {
|
|||
return brs, nil
|
||||
}
|
||||
|
||||
// GetTags returns all tags of given repository.
|
||||
func GetTags(userName, repoName string) ([]string, error) {
|
||||
repo, err := git.OpenRepository(RepoPath(userName, repoName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
refs, err := repo.AllTags()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tags := make([]string, len(refs))
|
||||
for i, ref := range refs {
|
||||
tags[i] = ref.Name
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func IsBranchExist(userName, repoName, branchName string) bool {
|
||||
repo, err := git.OpenRepository(RepoPath(userName, repoName))
|
||||
if err != nil {
|
||||
|
|
|
@ -74,6 +74,7 @@ type Repository struct {
|
|||
NumStars int
|
||||
NumForks int
|
||||
NumIssues int
|
||||
NumReleases int `xorm:"NOT NULL"`
|
||||
NumClosedIssues int
|
||||
NumOpenIssues int `xorm:"-"`
|
||||
IsPrivate bool
|
||||
|
|
|
@ -79,6 +79,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
|
|||
ctx.Handle(404, "RepoAssignment", err)
|
||||
return
|
||||
}
|
||||
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
|
||||
ctx.Repo.Repository = repo
|
||||
|
||||
ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
|
||||
|
|
|
@ -74,7 +74,7 @@ func Issues(ctx *middleware.Context) {
|
|||
|
||||
ctx.Data["Issues"] = showIssues
|
||||
ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues
|
||||
ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues
|
||||
ctx.Data["OpenCount"] = ctx.Repo.Repository.NumOpenIssues
|
||||
ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues
|
||||
ctx.Data["IssueCreatedCount"] = createdByCount
|
||||
ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed"
|
||||
|
|
22
routers/repo/release.go
Normal file
22
routers/repo/release.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
// 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/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Releases(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Releases"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
tags, err := models.GetTags(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Releases(GetTags)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Releases"] = tags
|
||||
ctx.HTML(200, "release/list")
|
||||
}
|
10
templates/release/list.tmpl
Normal file
10
templates/release/list.tmpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
{{template "repo/nav" .}}
|
||||
{{template "repo/toolbar" .}}
|
||||
<div id="body" class="container">
|
||||
{{range .Releases}}
|
||||
{{.}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
|
@ -8,18 +8,15 @@
|
|||
<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="{{.RepoLink}}/commits/{{if .BranchName}}{{.BranchName}}{{else}}master{{end}}">Commits</a></li>
|
||||
<!-- <li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="{{.RepoLink}}/branches">Branches</a></li> -->
|
||||
<!-- <li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="{{.RepoLink}}/pulls">Pull Requests</a></li> -->
|
||||
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="{{.RepoLink}}/issues">Issues <!--<span class="badge">42</span>--></a></li>
|
||||
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="{{.RepoLink}}/issues">{{if .Repository.NumOpenIssues}}<span class="badge">{{.Repository.NumOpenIssues}}</span> {{end}}Issues <!--<span class="badge">42</span>--></a></li>
|
||||
{{if .IsRepoToolbarIssues}}
|
||||
<li class="tmp">{{if .IsRepoToolbarIssuesList}}<a href="{{.RepoLink}}/issues/new">
|
||||
<button class="btn btn-primary btn-sm">New Issue</button>
|
||||
</a>{{else}}<a href="{{.RepoLink}}/issues">
|
||||
<button class="btn btn-primary btn-sm">Issues List</button>
|
||||
</a>{{end}}</li>
|
||||
<li class="tmp">{{if .IsRepoToolbarIssuesList}}<a href="{{.RepoLink}}/issues/new"><button class="btn btn-primary btn-sm">New Issue</button>
|
||||
</a>{{else}}<a href="{{.RepoLink}}/issues"><button class="btn btn-primary btn-sm">Issues List</button></a>{{end}}</li>
|
||||
{{end}}
|
||||
<li class="{{if .IsRepoToolbarReleases}}active{{end}}"><a href="{{.RepoLink}}/releases">{{if .Repository.NumReleases}}<span class="badge">{{.Repository.NumReleases}}</span> {{end}}Releases</a></li>
|
||||
<!-- <li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{.RepoLink}}/release">Release</a></li>
|
||||
<li><a href="{{.RepoLink}}/wiki">Wiki</a></li>
|
||||
</ul>
|
||||
</li> -->{{end}}
|
||||
|
|
1
web.go
1
web.go
|
@ -147,6 +147,7 @@ func runWeb(*cli.Context) {
|
|||
m.Group("/:username/:reponame", func(r martini.Router) {
|
||||
r.Get("/issues", repo.Issues)
|
||||
r.Get("/issues/:index", repo.ViewIssue)
|
||||
r.Get("/releases", repo.Releases)
|
||||
r.Get("/pulls", repo.Pulls)
|
||||
r.Get("/branches", repo.Branches)
|
||||
}, ignSignIn, middleware.RepoAssignment(true))
|
||||
|
|
Loading…
Reference in a new issue