Browse Source

Add release tmpl

for-closed-social
Unknown 10 years ago
parent
commit
db66b8da72
8 changed files with 59 additions and 8 deletions
  1. +19
    -0
      models/git.go
  2. +1
    -0
      models/repo.go
  3. +1
    -0
      modules/middleware/repo.go
  4. +1
    -1
      routers/repo/issue.go
  5. +22
    -0
      routers/repo/release.go
  6. +10
    -0
      templates/release/list.tmpl
  7. +4
    -7
      templates/repo/toolbar.tmpl
  8. +1
    -0
      web.go

+ 19
- 0
models/git.go View File

@ -56,6 +56,25 @@ func GetBranches(userName, repoName string) ([]string, error) {
return brs, nil 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 { func IsBranchExist(userName, repoName, branchName string) bool {
repo, err := git.OpenRepository(RepoPath(userName, repoName)) repo, err := git.OpenRepository(RepoPath(userName, repoName))
if err != nil { if err != nil {

+ 1
- 0
models/repo.go View File

@ -74,6 +74,7 @@ type Repository struct {
NumStars int NumStars int
NumForks int NumForks int
NumIssues int NumIssues int
NumReleases int `xorm:"NOT NULL"`
NumClosedIssues int NumClosedIssues int
NumOpenIssues int `xorm:"-"` NumOpenIssues int `xorm:"-"`
IsPrivate bool IsPrivate bool

+ 1
- 0
modules/middleware/repo.go View File

@ -79,6 +79,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
ctx.Handle(404, "RepoAssignment", err) ctx.Handle(404, "RepoAssignment", err)
return return
} }
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
ctx.Repo.Repository = repo ctx.Repo.Repository = repo
ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare

+ 1
- 1
routers/repo/issue.go View File

@ -74,7 +74,7 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Issues"] = showIssues ctx.Data["Issues"] = showIssues
ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues 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["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues
ctx.Data["IssueCreatedCount"] = createdByCount ctx.Data["IssueCreatedCount"] = createdByCount
ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed" ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed"

+ 22
- 0
routers/repo/release.go View 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
- 0
templates/release/list.tmpl View 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" .}}

+ 4
- 7
templates/repo/toolbar.tmpl View File

@ -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 .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 .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 .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}} {{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}} {{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"> <!-- <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="{{.RepoLink}}/release">Release</a></li>
<li><a href="{{.RepoLink}}/wiki">Wiki</a></li> <li><a href="{{.RepoLink}}/wiki">Wiki</a></li>
</ul> </ul>
</li> -->{{end}} </li> -->{{end}}

+ 1
- 0
web.go View File

@ -147,6 +147,7 @@ func runWeb(*cli.Context) {
m.Group("/:username/:reponame", func(r martini.Router) { m.Group("/:username/:reponame", func(r martini.Router) {
r.Get("/issues", repo.Issues) r.Get("/issues", repo.Issues)
r.Get("/issues/:index", repo.ViewIssue) r.Get("/issues/:index", repo.ViewIssue)
r.Get("/releases", repo.Releases)
r.Get("/pulls", repo.Pulls) r.Get("/pulls", repo.Pulls)
r.Get("/branches", repo.Branches) r.Get("/branches", repo.Branches)
}, ignSignIn, middleware.RepoAssignment(true)) }, ignSignIn, middleware.RepoAssignment(true))

Loading…
Cancel
Save