| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package common | 5 package common |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "html/template" | 10 "html/template" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 return fmt.Sprintf("%d secs", sec) | 127 return fmt.Sprintf("%d secs", sec) |
| 128 } | 128 } |
| 129 | 129 |
| 130 if d > time.Millisecond { | 130 if d > time.Millisecond { |
| 131 return fmt.Sprintf("%d ms", d/time.Millisecond) | 131 return fmt.Sprintf("%d ms", d/time.Millisecond) |
| 132 } | 132 } |
| 133 | 133 |
| 134 return "0" | 134 return "0" |
| 135 } | 135 } |
| 136 | 136 |
| 137 // obfuscateEmail converts an email@address.com into email<junk>@address.com | 137 // obfuscateEmail converts a string containing email adddress email@address.com |
| 138 // if it is an email. | 138 // into email<junk>@address.com. |
| 139 func obfuscateEmail(email string) template.HTML { | 139 func obfuscateEmail(email string) template.HTML { |
| 140 email = template.HTMLEscapeString(email) | 140 email = template.HTMLEscapeString(email) |
| 141 return template.HTML(strings.Replace( | 141 return template.HTML(strings.Replace( |
| 142 email, "@", "<span style=\"display:none\">ohnoyoudont</span>@",
-1)) | 142 email, "@", "<span style=\"display:none\">ohnoyoudont</span>@",
-1)) |
| 143 } | 143 } |
| 144 | 144 |
| 145 // parseRFC3339 parses time represented as a RFC3339 or RFC3339Nano string. | 145 // parseRFC3339 parses time represented as a RFC3339 or RFC3339Nano string. |
| 146 // If cannot parse, returns zero time. | 146 // If cannot parse, returns zero time. |
| 147 func parseRFC3339(s string) time.Time { | 147 func parseRFC3339(s string) time.Time { |
| 148 t, err := time.Parse(time.RFC3339, s) | 148 t, err := time.Parse(time.RFC3339, s) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 linkifyTemplate = template.Must( | 215 linkifyTemplate = template.Must( |
| 216 template.New("linkify"). | 216 template.New("linkify"). |
| 217 Parse( | 217 Parse( |
| 218 `<a href="{{.URL}}">` + | 218 `<a href="{{.URL}}">` + |
| 219 `{{if .Img}}<img src="{{.Img}}"{{if .Alt
}} alt="{{.Alt}}"{{end}}>` + | 219 `{{if .Img}}<img src="{{.Img}}"{{if .Alt
}} alt="{{.Alt}}"{{end}}>` + |
| 220 `{{else if .Alias}}[{{.Label}}]` + | 220 `{{else if .Alias}}[{{.Label}}]` + |
| 221 `{{else}}{{.Label}}{{end}}` + | 221 `{{else}}{{.Label}}{{end}}` + |
| 222 `</a>`)) | 222 `</a>`)) |
| 223 } | 223 } |
| OLD | NEW |