Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: milo/appengine/common/funcs.go

Issue 2835193006: Milo: Add timestamp name and tooltip (Closed)
Patch Set: Review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 "parseRFC3339": parseRFC3339, 23 "parseRFC3339": parseRFC3339,
24 "linkify": linkify, 24 "linkify": linkify,
25 "linkifySet": linkifySet, 25 "linkifySet": linkifySet,
26 "obfuscateEmail": obfuscateEmail, 26 "obfuscateEmail": obfuscateEmail,
27 "localTime": localTime, 27 "localTime": localTime,
28 "shortHash": shortHash, 28 "shortHash": shortHash,
29 "startswith": strings.HasPrefix, 29 "startswith": strings.HasPrefix,
30 "sub": sub, 30 "sub": sub,
31 "consoleHeader": consoleHeader, 31 "consoleHeader": consoleHeader,
32 "pagedURL": pagedURL, 32 "pagedURL": pagedURL,
33 "formatTime": formatTime,
33 } 34 }
34 35
35 // localTime returns a <span> element with t in human format 36 // localTime returns a <span> element with t in human format
36 // that will be converted to local timezone in the browser. 37 // that will be converted to local timezone in the browser.
37 // Recommended usage: {{ .Date | localTime "N/A" }} 38 // Recommended usage: {{ .Date | localTime "N/A" }}
38 func localTime(ifZero string, t time.Time) template.HTML { 39 func localTime(ifZero string, t time.Time) template.HTML {
39 if t.IsZero() { 40 if t.IsZero() {
40 return template.HTML(template.HTMLEscapeString(ifZero)) 41 return template.HTML(template.HTMLEscapeString(ifZero))
41 } 42 }
42 milliseconds := t.UnixNano() / 1e6 43 milliseconds := t.UnixNano() / 1e6
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if err == nil { 152 if err == nil {
152 return t 153 return t
153 } 154 }
154 t, err = time.Parse(time.RFC3339Nano, s) 155 t, err = time.Parse(time.RFC3339Nano, s)
155 if err == nil { 156 if err == nil {
156 return t 157 return t
157 } 158 }
158 return time.Time{} 159 return time.Time{}
159 } 160 }
160 161
162 // formatTime takes a time object and returns a formatted RFC3339 string.
163 func formatTime(t time.Time) string {
164 return t.Format(time.RFC3339)
165 }
166
161 // linkifyTemplate is the template used in "linkify". Because the template, 167 // linkifyTemplate is the template used in "linkify". Because the template,
162 // itself recursively invokes "linkify", we will initialize it in explicitly 168 // itself recursively invokes "linkify", we will initialize it in explicitly
163 // in "init()". 169 // in "init()".
164 // 170 //
165 // linkifySetTemplate is the template used in "linkifySet". 171 // linkifySetTemplate is the template used in "linkifySet".
166 var linkifyTemplate, linkifySetTemplate *template.Template 172 var linkifyTemplate, linkifySetTemplate *template.Template
167 173
168 // linkify turns a resp.LinkSet struct into a canonical link. 174 // linkify turns a resp.LinkSet struct into a canonical link.
169 func linkify(link *resp.Link) template.HTML { 175 func linkify(link *resp.Link) template.HTML {
170 if link == nil { 176 if link == nil {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 258
253 linkifyTemplate = template.Must( 259 linkifyTemplate = template.Must(
254 template.New("linkify"). 260 template.New("linkify").
255 Parse( 261 Parse(
256 `<a href="{{.URL}}">` + 262 `<a href="{{.URL}}">` +
257 `{{if .Img}}<img src="{{.Img}}"{{if .Alt }} alt="{{.Alt}}"{{end}}>` + 263 `{{if .Img}}<img src="{{.Img}}"{{if .Alt }} alt="{{.Alt}}"{{end}}>` +
258 `{{else if .Alias}}[{{.Label}}]` + 264 `{{else if .Alias}}[{{.Label}}]` +
259 `{{else}}{{.Label}}{{end}}` + 265 `{{else}}{{.Label}}{{end}}` +
260 `</a>`)) 266 `</a>`))
261 } 267 }
OLDNEW
« no previous file with comments | « no previous file | milo/appengine/frontend/expectations/buildbot.build-Debug_page-_CrWinGoma_30608.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698