1
0
Fork 0
mirror of https://github.com/Luzifer/badge-gen.git synced 2024-11-08 13:20:02 +00:00

add color-naming map

This commit is contained in:
Knut Ahlers 2016-07-05 16:41:48 +02:00
parent 9df7c301bb
commit ccd923a6ce
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

18
app.go
View file

@ -42,6 +42,20 @@ var (
serviceHandlers = map[string]serviceHandler{}
version = "dev"
colorList = map[string]string{
"brightgreen": "4c1",
"green": "97CA00",
"yellow": "dfb317",
"yellowgreen": "a4a61d",
"orange": "fe7d37",
"red": "e05d44",
"blue": "007ec6",
"grey": "555",
"gray": "555",
"lightgrey": "9f9f9f",
"lightgray": "9f9f9f",
}
cacheStore cache.Cache
configStore = configStorage{}
)
@ -184,6 +198,10 @@ func createBadge(title, text, color string) ([]byte, string) {
t, _ := Asset("assets/badgeTemplate.tpl")
tpl, _ := template.New("svg").Parse(string(t))
if c, ok := colorList[color]; ok {
color = c
}
tpl.Execute(&buf, map[string]interface{}{
"Width": width,
"TitleWidth": titleW + 2*xSpacing,