mirror of
https://github.com/documize/community.git
synced 2025-07-22 06:39:43 +02:00
add github summary report, tidy SVG constant handling
This commit is contained in:
parent
a7ae6d7503
commit
e33d6715aa
6 changed files with 391 additions and 256 deletions
|
@ -21,11 +21,6 @@ import (
|
|||
gogithub "github.com/google/go-github/github"
|
||||
)
|
||||
|
||||
const (
|
||||
tagIssuesData = "issuesData"
|
||||
issuesTimeFormat = "January 2 2006, 15:04"
|
||||
)
|
||||
|
||||
type githubIssue struct {
|
||||
ID int `json:"id"`
|
||||
Date string `json:"date"`
|
||||
|
@ -59,14 +54,29 @@ func (s issuesToSort) Less(i, j int) bool {
|
|||
return iDate.Before(jDate)
|
||||
}
|
||||
|
||||
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</h3>
|
||||
<p>
|
||||
During the period since {{.Config.Since}}{{.Config.DateMessage}}, {{.ClosedIssues}} issues were closed, while {{.OpenIssues}} remain open.
|
||||
{{if .ShowList}}
|
||||
Labelled
|
||||
Including issues labelled
|
||||
{{range $label := .List}}
|
||||
{{if $label.Included}}
|
||||
<span class="github-issue-label" style="background-color:#{{$label.Color}}">{{$label.Name}}</span>
|
||||
|
@ -81,13 +91,9 @@ func init() {
|
|||
<a class="link" href="{{$data.URL}}">
|
||||
<div class="issue-avatar">
|
||||
{{if $data.IsOpen}}
|
||||
<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>
|
||||
` + openIsvg + `
|
||||
{{else}}
|
||||
<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>
|
||||
` + closedIsvg + `
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="github-commit-body">
|
||||
|
@ -121,60 +127,62 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er
|
|||
hadRepo := make(map[string]bool)
|
||||
|
||||
for _, orb := range config.Lists {
|
||||
if orb.Included {
|
||||
|
||||
rName := orb.Owner + "/" + orb.Repo
|
||||
rName := orb.Owner + "/" + orb.Repo
|
||||
|
||||
if !hadRepo[rName] {
|
||||
if !hadRepo[rName] {
|
||||
|
||||
for _, state := range []string{"open", "closed"} {
|
||||
for _, state := range []string{"open", "closed"} {
|
||||
|
||||
opts := &gogithub.IssueListByRepoOptions{
|
||||
Sort: "updated",
|
||||
State: state,
|
||||
ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}}
|
||||
opts := &gogithub.IssueListByRepoOptions{
|
||||
Sort: "updated",
|
||||
State: state,
|
||||
ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}}
|
||||
|
||||
if config.SincePtr != nil && state == "closed" /* we want all the open ones */ {
|
||||
opts.Since = *config.SincePtr
|
||||
}
|
||||
|
||||
/* TODO refactor to select certain lables
|
||||
for _, lab := range config.Lists {
|
||||
if lab.Included {
|
||||
opts.Labels = append(opts.Labels, lab.Name)
|
||||
if config.SincePtr != nil && state == "closed" /* we want all the open ones */ {
|
||||
opts.Since = *config.SincePtr
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
guff, _, err := client.Issues.ListByRepo(orb.Owner, orb.Repo, opts)
|
||||
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, v := range guff {
|
||||
n := ""
|
||||
ptr := v.User
|
||||
if ptr != nil {
|
||||
if ptr.Login != nil {
|
||||
n = *ptr.Login
|
||||
/* TODO refactor to select certain lables
|
||||
for _, lab := range config.Lists {
|
||||
if lab.Included {
|
||||
opts.Labels = append(opts.Labels, lab.Name)
|
||||
}
|
||||
}
|
||||
l := wrapLabels(v.Labels)
|
||||
ret = append(ret, githubIssue{
|
||||
Name: n,
|
||||
Message: *v.Title,
|
||||
Date: v.CreatedAt.Format(issuesTimeFormat),
|
||||
Updated: v.UpdatedAt.Format(issuesTimeFormat),
|
||||
URL: template.URL(*v.HTMLURL),
|
||||
Labels: template.HTML(l),
|
||||
ID: *v.Number,
|
||||
IsOpen: *v.State == "open",
|
||||
Repo: rName,
|
||||
})
|
||||
*/
|
||||
|
||||
guff, _, err := client.Issues.ListByRepo(orb.Owner, orb.Repo, opts)
|
||||
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
for _, v := range guff {
|
||||
n := ""
|
||||
ptr := v.User
|
||||
if ptr != nil {
|
||||
if ptr.Login != nil {
|
||||
n = *ptr.Login
|
||||
}
|
||||
}
|
||||
l := wrapLabels(v.Labels)
|
||||
ret = append(ret, githubIssue{
|
||||
Name: n,
|
||||
Message: *v.Title,
|
||||
Date: v.CreatedAt.Format(issuesTimeFormat),
|
||||
Updated: v.UpdatedAt.Format(issuesTimeFormat),
|
||||
URL: template.URL(*v.HTMLURL),
|
||||
Labels: template.HTML(l),
|
||||
ID: *v.Number,
|
||||
IsOpen: *v.State == "open",
|
||||
Repo: rName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
hadRepo[rName] = true
|
||||
}
|
||||
hadRepo[rName] = true
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue