1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 23:15:29 +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{ ret = append(ret, githubIssueActivity{
Name: n, Name: n,
Event: "TITLE", Event: "TITLE",
Message: *issue.Title, // TODO move? Message: template.HTML(*issue.Title),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: *issue.HTMLURL, URL: template.URL(*issue.HTMLURL),
}) })
ret = append(ret, githubIssueActivity{ ret = append(ret, githubIssueActivity{
Name: n, Name: n,
Event: "DESCRIPTION", Event: "DESCRIPTION",
Message: *issue.Body, Message: template.HTML(*issue.Body),
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: *issue.HTMLURL, URL: template.URL(*issue.HTMLURL),
}) })
} else { } else {
return ret, err return ret, err
@ -372,10 +372,10 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
ret = append(ret, githubIssueActivity{ ret = append(ret, githubIssueActivity{
Name: n, Name: n,
Event: *v.Event, Event: *v.Event,
Message: m, Message: template.HTML(m),
Date: v.CreatedAt.Format("January 2 2006, 15:04"), Date: v.CreatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: u, URL: template.URL(u),
}) })
} }
} }
@ -421,15 +421,15 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith
} }
l := "" l := ""
for _, ll := range v.Labels { 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{ ret = append(ret, githubIssue{
Name: n, Name: n,
Message: *v.Title, Message: *v.Title,
Date: v.UpdatedAt.Format("January 2 2006, 15:04"), Date: v.UpdatedAt.Format("January 2 2006, 15:04"),
Avatar: a, Avatar: a,
URL: *v.HTMLURL, URL: template.URL(*v.HTMLURL),
Labels: l, Labels: template.HTML(l),
}) })
} }
@ -507,7 +507,7 @@ func (*Provider) getCommits(client *gogithub.Client, config githubConfig) ([]git
Message: m, Message: m,
Date: d, Date: d,
Avatar: a, Avatar: a,
URL: u, URL: template.URL(u),
}) })
} }
@ -610,11 +610,11 @@ func (p *Provider) Render(config, data string) string {
client := p.githubClient(c) client := p.githubClient(c)
for k, v := range raw { for k, v := range raw {
if v.Event == "commented" { if v.Event == "commented" {
output, _, err := client.Markdown(v.Message, opt) output, _, err := client.Markdown(string(v.Message), opt)
if err != nil { if err != nil {
log.Error("convert commented text to markdown", err) log.Error("convert commented text to markdown", err)
} else { } else {
raw[k].Message = output raw[k].Message = template.HTML(output)
} }
} }
} }

View file

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