1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-09 07:25:23 +02:00

un-escape html elements

This commit is contained in:
Elliott Stoneham 2016-06-29 16:54:33 +01:00
parent 2c865a7a5c
commit 8e342d0c2a
2 changed files with 30 additions and 29 deletions

View file

@ -308,18 +308,18 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
ret = append(ret, githubIssueActivity{
Name: n,
Event: "TITLE",
Message: *issue.Title, // TODO move?
Message: template.HTML(*issue.Title),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a,
URL: *issue.HTMLURL,
URL: template.URL(*issue.HTMLURL),
})
ret = append(ret, githubIssueActivity{
Name: n,
Event: "DESCRIPTION",
Message: *issue.Body,
Message: template.HTML(*issue.Body),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a,
URL: *issue.HTMLURL,
URL: template.URL(*issue.HTMLURL),
})
} else {
return ret, err
@ -372,10 +372,10 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
ret = append(ret, githubIssueActivity{
Name: n,
Event: *v.Event,
Message: m,
Message: template.HTML(m),
Date: v.CreatedAt.Format("January 2 2006, 15:04"),
Avatar: a,
URL: u,
URL: template.URL(u),
})
}
}
@ -421,15 +421,15 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith
}
l := ""
for _, ll := range v.Labels {
l += `<span style="color:#` + *ll.Color + `">` + *ll.Name + `</span> `
l += `<span style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
}
ret = append(ret, githubIssue{
Name: n,
Message: *v.Title,
Date: v.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a,
URL: *v.HTMLURL,
Labels: l,
URL: template.URL(*v.HTMLURL),
Labels: template.HTML(l),
})
}
@ -507,7 +507,7 @@ func (*Provider) getCommits(client *gogithub.Client, config githubConfig) ([]git
Message: m,
Date: d,
Avatar: a,
URL: u,
URL: template.URL(u),
})
}
@ -610,11 +610,11 @@ func (p *Provider) Render(config, data string) string {
client := p.githubClient(c)
for k, v := range raw {
if v.Event == "commented" {
output, _, err := client.Markdown(v.Message, opt)
output, _, err := client.Markdown(string(v.Message), opt)
if err != nil {
log.Error("convert commented text to markdown", err)
} else {
raw[k].Message = output
raw[k].Message = template.HTML(output)
}
}
}

View file

@ -12,6 +12,7 @@
package github
import (
"html/template"
"strings"
"time"
@ -164,29 +165,29 @@ type githubBranchCommits struct {
}
type githubCommit struct {
Date string `json:"date"`
Message string `json:"message"`
URL string `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Date string `json:"date"`
Message string `json:"message"`
URL template.URL `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
}
type githubIssue struct {
Date string `json:"date"`
Message string `json:"message"`
URL string `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Labels string `json:"labels"`
Date string `json:"date"`
Message string `json:"message"`
URL template.URL `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Labels template.HTML `json:"labels"`
}
type githubIssueActivity struct {
Date string `json:"date"`
Event string `json:"event"`
Message string `json:"message"`
URL string `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
Date string `json:"date"`
Event string `json:"event"`
Message template.HTML `json:"message"`
URL template.URL `json:"url"`
Name string `json:"name"`
Avatar string `json:"avatar"`
}
type githubConfig struct {