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

Side by Side Diff: appengine/cmd/milo/settings/funcs.go

Issue 2134673003: milo: buildbucket builer view (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased and regenerated expectations Created 4 years, 5 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 | « appengine/cmd/milo/frontend/testdata/buildbucket ('k') | appengine/cmd/milo/swarming/build.go » ('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 settings 5 package settings
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "html/template" 10 "html/template"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return time.Time{} 106 return time.Time{}
107 } 107 }
108 108
109 var linkifyTemplate = template.Must( 109 var linkifyTemplate = template.Must(
110 template.New("linkify").Parse(`<a href="{{.URL}}"> 110 template.New("linkify").Parse(`<a href="{{.URL}}">
111 {{if .Img}}<img src="{{.Img}}"{{if .Alt}} alt="{{.Alt}}"{{end}}> 111 {{if .Img}}<img src="{{.Img}}"{{if .Alt}} alt="{{.Alt}}"{{end}}>
112 {{else}}{{.Label}}{{end}}</a>`)) 112 {{else}}{{.Label}}{{end}}</a>`))
113 113
114 // linkify turns a resp.Link struct into a canonical link. 114 // linkify turns a resp.Link struct into a canonical link.
115 func linkify(link *resp.Link) template.HTML { 115 func linkify(link *resp.Link) template.HTML {
116 if link == nil {
117 return ""
118 }
116 buf := bytes.Buffer{} 119 buf := bytes.Buffer{}
117 » linkifyTemplate.Execute(&buf, link) 120 » if err := linkifyTemplate.Execute(&buf, link); err != nil {
121 » » panic(err)
122 » }
118 return template.HTML(buf.Bytes()) 123 return template.HTML(buf.Bytes())
119 } 124 }
120 125
121 // sub subtracts one number from another, because apparently go templates aren't 126 // sub subtracts one number from another, because apparently go templates aren't
122 // smart enough to do that. 127 // smart enough to do that.
123 func sub(a, b int) int { 128 func sub(a, b int) int {
124 return a - b 129 return a - b
125 } 130 }
126 131
127 // shortHash abbriviates a git hash into 6 characters. 132 // shortHash abbriviates a git hash into 6 characters.
128 func shortHash(s string) string { 133 func shortHash(s string) string {
129 if len(s) > 6 { 134 if len(s) > 6 {
130 return s[0:6] 135 return s[0:6]
131 } 136 }
132 return s 137 return s
133 } 138 }
OLDNEW
« no previous file with comments | « appengine/cmd/milo/frontend/testdata/buildbucket ('k') | appengine/cmd/milo/swarming/build.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698