1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 21:59:42 +02:00

separate templates, continue to mangle data to new form

This commit is contained in:
Elliott Stoneham 2016-08-22 14:15:17 +01:00
parent cc52106e20
commit 7c72b72bae
9 changed files with 374 additions and 216 deletions

View file

@ -59,74 +59,49 @@ func (s asToSort) Less(i, j int) bool {
return s[i].CommitCount > s[j].CommitCount
}
const tagCommitsData = "commitsData"
// sort branches in order that that should be presented.
type branchByID []githubBranch
func init() {
reports[tagCommitsData] = report{refreshCommits, renderCommits, `
<h3>Contributor activity since {{.Config.Since}}{{.Config.DateMessage}}</h3>
<div class="section-github-render">
<table style="width:80%">
<tr>
<th></th>
    <th>Author</th>
<th>Open Issues</th>
<th>Closed Issues</th>
    <th>#commits</th>
    <th>Branches</th>
  </tr>
{{range $stats := .AuthorStats}}
<tr>
<td>
<div class="github-avatar">
<img alt="@{{$stats.Author}}" src="{{$stats.Avatar}}" height="36" width="36">
</div>
</td>
<td>{{$stats.Author}}</td>
<td>{{$stats.OpenIssues}}</td>
<td>{{$stats.ClosedIssues}}</td>
<td>{{$stats.CommitCount}}</td>
<td>
{{range $repo := $stats.Repos}}
{{$repo}}
{{end}}
</td>
</tr>
{{end}}
</table>
{{range $branch := .BranchCommits}}
<h4>
There are {{ $branch.CommitCount }} commits for branch <a href="{{$branch.URL}}">{{$branch.Name}}</a>.
</h4>
<div class="github-board">
{{range $data := $branch.Days}}
<div class="github-group-title">
Commits on {{ $data.Day }}
</div>
<ul class="github-list">
{{range $commit := $data.Commits}}
<li class="github-commit-item">
<a class="link" href="{{$commit.URL}}">
<div class="github-avatar">
<img alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" height="36" width="36">
</div>
<div class="github-commit-body">
<div class="github-commit-title">{{$commit.Message}}</div>
<div class="github-commit-meta">{{$commit.Name}} committed on {{$commit.Date}}</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
{{end}}
</div>
{{end}}
</div>
`}
func (s branchByID) Len() int { return len(s) }
func (s branchByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s branchByID) Less(i, j int) bool {
return s[i].ID < s[j].ID
}
const tagCommitsData = "commitsData"
func getCommits(client *gogithub.Client, config *githubConfig) ([]githubBranchCommits, []githubAuthorStats, error) {
// first make sure we've got all the branches
for _, orb := range config.Lists {
if orb.Included {
branches, _, err := client.Repositories.ListBranches(orb.Owner, orb.Repo,
&gogithub.ListOptions{PerPage: 100})
if err == nil {
render := make([]githubBranch, len(branches))
for kc, vb := range branches {
for _, existing := range config.Lists {
if orb.Owner == existing.Owner && orb.Repo == existing.Repo && orb.Name == *vb.Name {
goto found
}
}
render[kc] = githubBranch{
Owner: orb.Owner,
Repo: orb.Repo,
Name: *vb.Name,
ID: fmt.Sprintf("%s:%s:%s", orb.Owner, orb.Repo, *vb.Name),
Included: true,
URL: "https://github.com/" + orb.Owner + "/" + orb.Repo + "/tree/" + *vb.Name,
}
found:
}
config.Lists = append(config.Lists, render...)
}
}
}
sort.Stable(branchByID(config.Lists))
authorStats := make(map[string]githubAuthorStats)
contribBranch := make(map[string]map[string]struct{})
@ -298,3 +273,10 @@ func renderCommits(payload *githubRender, c *githubConfig) error {
return nil
}
// TODO(elliott5) - move to templates.go once working
// COMMITS
func init() {
reports[tagCommitsData] = report{refreshCommits, renderCommits, commitsTemplate}
}

View file

@ -0,0 +1,74 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package github
const commitsTemplate = `
<h3>Contributor activity since {{.Config.Since}}{{.Config.DateMessage}}</h3>
<div class="section-github-render">
<table style="width:80%">
<tr>
<th></th>
    <th>Author</th>
<th>Open Issues</th>
<th>Closed Issues</th>
    <th>#commits</th>
    <th>Branches</th>
  </tr>
{{range $stats := .AuthorStats}}
<tr>
<td>
<div class="github-avatar">
<img alt="@{{$stats.Author}}" src="{{$stats.Avatar}}" height="36" width="36">
</div>
</td>
<td>{{$stats.Author}}</td>
<td>{{$stats.OpenIssues}}</td>
<td>{{$stats.ClosedIssues}}</td>
<td>{{$stats.CommitCount}}</td>
<td>
{{range $repo := $stats.Repos}}
{{$repo}}<br>
{{end}}
</td>
</tr>
{{end}}
</table>
{{range $branch := .BranchCommits}}
<h4>
There are {{ $branch.CommitCount }} commits for branch <a href="{{$branch.URL}}">{{$branch.Name}}</a>.
</h4>
<div class="github-board">
{{range $data := $branch.Days}}
<div class="github-group-title">
Commits on {{ $data.Day }}
</div>
<ul class="github-list">
{{range $commit := $data.Commits}}
<li class="github-commit-item">
<a class="link" href="{{$commit.URL}}">
<div class="github-avatar">
<img alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" height="36" width="36">
</div>
<div class="github-commit-body">
<div class="github-commit-title">{{$commit.Message}}</div>
<div class="github-commit-meta">{{$commit.Name}} committed on {{$commit.Date}}</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
{{end}}
</div>
{{end}}
</div>
`

View file

@ -36,12 +36,28 @@ type githubIssue struct {
Milestone string `json:"milestone"`
}
type githubSharedLabel struct {
Name string `json:"name"`
Count int `json:"count"`
Repos template.HTML `json:"Repos"`
}
// sort issues in order that that should be presented - by date updated.
type issuesToSort []githubIssue
func (s issuesToSort) Len() int { return len(s) }
func (s issuesToSort) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s issuesToSort) Less(i, j int) bool {
if s[i].Milestone != noMilestone && s[j].Milestone == noMilestone {
return true
}
if s[i].Milestone == noMilestone && s[j].Milestone != noMilestone {
return false
}
if s[i].Milestone != s[j].Milestone {
// TODO should this order be by milestone completion?
return s[i].Milestone < s[j].Milestone
}
if !s[i].IsOpen && s[j].IsOpen {
return true
}
@ -56,62 +72,20 @@ func (s issuesToSort) Less(i, j int) bool {
return iDate.Before(jDate)
}
// sort shared labels alphabetically
type sharedLabelsSort []githubSharedLabel
func (s sharedLabelsSort) Len() int { return len(s) }
func (s sharedLabelsSort) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s sharedLabelsSort) Less(i, j int) bool { return s[i].Name < s[j].Name }
const (
tagIssuesData = "issuesData"
issuesTimeFormat = "January 2 2006, 15:04"
openIsvg = `
<span title="Open issue">
<svg height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
</span>
`
closedIsvg = `
<span title="Closed issue">
<svg height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
</span>
`
)
func init() {
reports[tagIssuesData] = report{refreshIssues, renderIssues, `
<div class="section-github-render">
<h3>Issues: {{.ClosedIssues}} closed, {{.OpenIssues}} open</h3>
<p>
{{if .ShowList}}
Including issues labelled
{{range $label := .List}}
{{if $label.Included}}
<span class="github-issue-label" style="background-color:#{{$label.Color}}">{{$label.Name}}</span>
{{end}}
{{end}}
{{end}}
</p>
<div class="github-board">
<ul class="github-list">
{{range $data := .Issues}}
<li class="github-commit-item">
<a class="link" href="{{$data.URL}}">
<div class="issue-avatar">
{{if $data.IsOpen}}
` + openIsvg + `
{{else}}
` + closedIsvg + `
{{end}}
</div>
<div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Message}}</span> :{{$data.Milestone}}: {{$data.Labels}}</div>
<div class="github-commit-meta">
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
</div>
</div>
`}
reports[tagIssuesData] = report{refreshIssues, renderIssues, issuesTemplate}
}
func wrapLabels(labels []gogithub.Label) (l string, labelNames []string) {
@ -186,7 +160,7 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
LabelNames: ln,
ID: *v.Number,
IsOpen: *v.State == "open",
Repo: rName,
Repo: repoName(rName),
Milestone: ms,
})
}
@ -224,21 +198,23 @@ func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Clie
}
}
gr.SharedLabels = make([]template.HTML, 0, len(sharedLabels)) // will usually be too big
gr.SharedLabels = make([]githubSharedLabel, 0, len(sharedLabels)) // will usually be too big
for name, repos := range sharedLabels {
if len(repos) > 1 {
lab := name + ":["
thisLab := githubSharedLabel{Name: name, Count: len(repos)}
show := ""
for i, r := range repos {
if i > 0 {
lab += " "
show += ", "
}
lab += "<a href='https://github.com/" + r +
show += "<a href='https://github.com/" + config.Owner + "/" + r +
"/issues?q=is%3Aissue+label%3A" + name + "'>" + r + "</a>"
}
lab += "] "
gr.SharedLabels = append(gr.SharedLabels, template.HTML(lab))
thisLab.Repos = template.HTML(show)
gr.SharedLabels = append(gr.SharedLabels, thisLab)
}
}
sort.Stable(sharedLabelsSort(gr.SharedLabels))
return nil
}

View file

@ -0,0 +1,64 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package github
const (
openIsvg = `
<span title="Open issue">
<svg height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
</span>
`
closedIsvg = `
<span title="Closed issue">
<svg height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
</span>
`
issuesTemplate = `
<div class="section-github-render">
<h3>Issues: {{.ClosedIssues}} closed, {{.OpenIssues}} open</h3>
<p>
{{if .ShowList}}
Including issues labelled
{{range $label := .List}}
{{if $label.Included}}
<span class="github-issue-label" style="background-color:#{{$label.Color}}">{{$label.Name}}</span>
{{end}}
{{end}}
{{end}}
</p>
<div class="github-board">
<ul class="github-list">
{{range $data := .Issues}}
<li class="github-commit-item">
<a class="link" href="{{$data.URL}}">
<div class="issue-avatar">
{{if $data.IsOpen}}
` + openIsvg + `
{{else}}
` + closedIsvg + `
{{end}}
</div>
<div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Message}}</span> :{{$data.Milestone}}: {{$data.Labels}}</div>
<div class="github-commit-meta">
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
</div>
</div>
`
)

View file

@ -31,6 +31,7 @@ type githubMilestone struct {
DueDate string `json:"dueDate"`
UpdatedAt string `json:"updatedAt"`
Progress uint `json:"progress"`
IsMilestone bool `json:"isMilestone"`
}
// sort milestones in order that that should be presented.
@ -52,6 +53,12 @@ func (s milestonesToSort) Less(i, j int) bool {
if s[i].IsOpen && !s[j].IsOpen {
return false
}
if s[i].Name != noMilestone && s[j].Name == noMilestone {
return true
}
if s[i].Name == noMilestone && s[j].Name != noMilestone {
return false
}
if s[i].Progress == s[j].Progress { // order equal progress milestones
return s[i].Name < s[j].Name
}
@ -62,57 +69,10 @@ const (
tagMilestonesData = "milestonesData"
milestonesTimeFormat = "January 2 2006"
noMilestone = "no milestone"
rawMSsvg = `<path d="M8 2H6V0h2v2zm4 5H2c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h10l2 2-2 2zM8 4H6v2h2V4zM6 16h2V8H6v8z"></path>`
openMSsvg = `
<span title="Open milestone">
<svg height="16" width="14" version="1.1" viewBox="0 0 14 16">
` + rawMSsvg + `
</svg>
</span>
`
closedMSsvg = `
<span title="Closed milestone">
<svg height="8" width="7" version="1.1" viewBox="0 0 14 16">
` + rawMSsvg + `
</svg>
</span>
`
)
func init() {
reports[tagMilestonesData] = report{refreshMilestones, renderMilestones, `
<div class="section-github-render">
<h3>Milestones: {{.ClosedMS}} closed, {{.OpenMS}} open</h3>
<div class="github-board">
<ul class="github-list">
{{range $data := .Milestones}}
<li class="github-commit-item">
<a class="link" href="{{$data.URL}}">
<div class="issue-avatar">
{{if $data.IsOpen}}
` + openMSsvg + `
{{else}}
` + closedMSsvg + `
{{end}}
</div>
<div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Name}}</span>
<progress value="{{$data.Progress}}" max="100">
</div>
<div class="github-commit-meta">
{{$data.DueDate}} Last updated {{$data.UpdatedAt}}.
{{$data.CompleteMsg}} complete {{$data.OpenIssues}} open {{$data.ClosedIssues}} closed
</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
</div>
</div>
`}
reports[tagMilestonesData] = report{refreshMilestones, renderMilestones, milestonesTemplate}
}
func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMilestone, error) {
@ -163,7 +123,7 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
progress := float64(*v.ClosedIssues*100) / float64(*v.OpenIssues+*v.ClosedIssues)
ret = append(ret, githubMilestone{
Repo: rName,
Repo: repoName(rName),
Name: *v.Title,
URL: *v.HTMLURL,
IsOpen: *v.State == "open",
@ -173,6 +133,7 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles
DueDate: dd,
UpdatedAt: up,
Progress: uint(progress),
IsMilestone: true,
})
}
}
@ -209,19 +170,14 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.
}
func renderMilestones(payload *githubRender, c *githubConfig) error {
fmt.Println("DEBUG renderMilestones list", payload.List)
hadRepo := make(map[string]bool)
for _, orb := range payload.List {
fmt.Println("DEBUG branch", orb)
rName := orb.Owner + "/" + orb.Repo
if !hadRepo[rName] {
fmt.Println("DEBUG found repo", rName)
issuesOpen, issuesClosed := 0, 0
for _, iss := range payload.Issues {
fmt.Println("DEBUG issue", iss)
if iss.Repo == rName {
fmt.Println("DEBUG Found issue", iss)
if iss.Repo == repoName(rName) {
if iss.Milestone == noMilestone {
if iss.IsOpen {
issuesOpen++
@ -231,9 +187,12 @@ func renderMilestones(payload *githubRender, c *githubConfig) error {
}
}
}
payload.Milestones = append(payload.Milestones, githubMilestone{
Repo: rName, Name: noMilestone, OpenIssues: issuesOpen, ClosedIssues: issuesClosed,
})
if issuesClosed+issuesOpen > 0 {
payload.Milestones = append(payload.Milestones, githubMilestone{
Repo: rName, Name: noMilestone, IsOpen: true,
OpenIssues: issuesOpen, ClosedIssues: issuesClosed,
})
}
hadRepo[rName] = true
}

View file

@ -0,0 +1,64 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package github
const (
rawMSsvg = `<path d="M8 2H6V0h2v2zm4 5H2c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h10l2 2-2 2zM8 4H6v2h2V4zM6 16h2V8H6v8z"></path>`
openMSsvg = `
<span title="Open milestone">
<svg height="16" width="14" version="1.1" viewBox="0 0 14 16">
` + rawMSsvg + `
</svg>
</span>
`
closedMSsvg = `
<span title="Closed milestone">
<svg height="8" width="7" version="1.1" viewBox="0 0 14 16">
` + rawMSsvg + `
</svg>
</span>
`
milestonesTemplate = `
<div class="section-github-render">
<h3>Milestones: {{.ClosedMS}} closed, {{.OpenMS}} open</h3>
<div class="github-board">
<ul class="github-list">
{{range $data := .Milestones}}
<li class="github-commit-item">
<a class="link" href="{{$data.URL}}">
<div class="issue-avatar">
{{if $data.IsOpen}}
` + openMSsvg + `
{{else}}
` + closedMSsvg + `
{{end}}
</div>
<div class="github-commit-body">
<div class="github-commit-title"><span class="label-name">{{$data.Repo}} - {{$data.Name}}</span>
{{if $data.IsMilestone}}
<progress value="{{$data.Progress}}" max="100">
{{end}}
</div>
<div class="github-commit-meta">
{{$data.DueDate}} Last updated {{$data.UpdatedAt}}.
{{$data.CompleteMsg}} complete {{$data.OpenIssues}} open {{$data.ClosedIssues}} closed
</div>
</div>
</a>
<div class="clearfix" />
</li>
{{end}}
</ul>
</div>
</div>
`
)

View file

@ -13,7 +13,8 @@ package github
import (
"fmt"
"html/template"
"sort"
"strings"
"time"
"github.com/documize/community/core/log"
@ -30,7 +31,7 @@ type githubRender struct {
BranchCommits []githubBranchCommits `json:"branchCommits"`
CommitCount int `json:"commitCount"`
Issues []githubIssue `json:"issues"`
SharedLabels []template.HTML `json:"sharedLabels"`
SharedLabels []githubSharedLabel `json:"sharedLabels"`
OpenIssues int `json:"openIssues"`
ClosedIssues int `json:"closedIssues"`
Limit int `json:"limit"`
@ -79,6 +80,7 @@ type githubBranch struct {
Included bool `json:"included"`
URL string `json:"url"`
Color string `json:"color,omitempty"`
Comma bool `json:"comma"`
}
type githubLabel struct {
@ -148,24 +150,51 @@ func (c *githubConfig) Clean() {
c.Since = (*c.SincePtr).Format(issuesTimeFormat)
// TEST DATA INSERTION DEBUG ONLY!
debugList := []string{"community", "enterprise", "test-data"}
c.Lists = make([]githubBranch, 0, len(debugList))
for rid, repo := range debugList {
c.Lists = append(c.Lists, githubBranch{
ID: fmt.Sprintf("%d", rid+1),
Owner: "documize",
Repo: repo,
Name: "master",
Included: true,
URL: "https://github.com/documize/" + repo + "/tree/master",
Color: "",
})
debugList := map[string][]string{
"community": []string{"master"},
"enterprise": []string{"master"},
"test-data": []string{"master"},
}
c.Lists = make([]githubBranch, 0, len(debugList)*3)
for repo, branches := range debugList {
render := make([]githubBranch, len(branches))
for kc, vb := range branches {
render[kc] = githubBranch{
Owner: "documize",
Repo: repo,
Name: vb,
ID: fmt.Sprintf("%s:%s:%s", "documize", repo, vb),
Included: true,
URL: "https://github.com/" + "documize" + "/" + repo + "/tree/" + vb,
}
}
c.Lists = append(c.Lists, render...)
}
c.Owner = "documize"
c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData /*, tagPullRequestData*/, tagCommitsData}
c.BranchLines = 100 // overide js default of 30 with maximum allowable in one call
sort.Stable(branchesToSort(c.Lists)) // get the configured branches in a sensible order for printing
for i := range c.Lists {
if i != len(c.Lists)-1 {
c.Lists[i].Comma = true // put the commas in the right places
}
}
}
type githubCallbackT struct {
AccessToken string `json:"access_token"`
}
func repoName(branchName string) string {
bits := strings.Split(branchName, "/")
if len(bits) != 2 {
return branchName + "?repo"
}
pieces := strings.Split(bits[1], ":")
if len(pieces) == 0 {
return branchName + "?repo:?branch"
}
return pieces[0]
}

View file

@ -12,8 +12,6 @@
package github
import (
"sort"
gogithub "github.com/google/go-github/github"
)
@ -32,27 +30,7 @@ func (s branchesToSort) Less(i, j int) bool {
}
func init() {
reports[tagSummaryData] = report{refreshSummary, renderSummary, `
<div class="section-github-render">
<h3>
Activity since {{.Config.Since}}{{.Config.DateMessage}} for repository branches [
{{range $data := .Config.Lists}}
{{if $data.Included}}
<a class="link" href="{{$data.URL}}">
{{$data.Owner}}/{{$data.Repo}}:{{$data.Name}}
</a>
{{end}}
{{end}}
]
</h3>
<h3>
Shared Tags:
{{range $slabel := .SharedLabels}}
{{$slabel}}
{{end}}
</h3>
</div>
`}
reports[tagSummaryData] = report{refreshSummary, renderSummary, summaryTemplate}
}
func refreshSummary(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) {
@ -60,6 +38,5 @@ func refreshSummary(gr *githubRender, config *githubConfig, client *gogithub.Cli
}
func renderSummary(payload *githubRender, c *githubConfig) error {
sort.Stable(branchesToSort(c.Lists)) // get the configured branches in a sensible order before printing
return nil
}

View file

@ -0,0 +1,33 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package github
const summaryTemplate = `
<div class="section-github-render">
<h3>
Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repositories:
{{range $data := .Config.Lists}}
{{if $data.Included}}
<a class="link" href="{{$data.URL}}">
{{$data.Repo}}{{if $data.Comma}},{{end}}
</a>
{{end}}
{{end}}
</h3>
<h3>
Common Labels: <br>
{{range $slabel := .SharedLabels}}
{{$slabel.Name}} {{$slabel.Count}} {{$slabel.Repos}} <br>
{{end}}
</h3>
</div>
`