template.New("ui").
Funcs(template.FuncMap{
"builderTitle": builderTitle,
+ "shortDesc": shortDesc,
"shortHash": shortHash,
+ "shortUser": shortUser,
"repoURL": repoURL,
}).
ParseFile("build/ui.html"),
return strings.Replace(s, "-", " ", -1)
}
-// shortHash returns a the short version of a hash.
+// shortDesc returns the first line of a description.
+func shortDesc(desc string) string {
+ if i := strings.Index(desc, "\n"); i != -1 {
+ desc = desc[:i]
+ }
+ return desc
+}
+
+// shortHash returns a short version of a hash.
func shortHash(hash string) string {
if len(hash) > 12 {
hash = hash[:12]
return hash
}
+// shortUser returns a shortened version of a user string.
+func shortUser(user string) string {
+ if i, j := strings.Index(user, "<"), strings.Index(user, ">"); i != -1 && j > i {
+ user = user[i+1 : j]
+ if k := strings.Index(user, "@golang.org"); k != -1 {
+ user = user[:k]
+ }
+ }
+ return user
+}
+
// repoRe matches Google Code repositories and subrepositories (without paths).
var repoRe = regexp.MustCompile(`^code\.google\.com/p/([a-z0-9\-]+)(\.[a-z0-9\-]+)?$`)
.build tr:nth-child(2n) {
background-color: #f0f0f0;
}
+ .build .hash {
+ font-family: monospace;
+ }
.build .result {
text-align: center;
width: 50px;
}
.build .time {
+ font-family: monospace;
color: #666;
}
.build .descr, .build .time, .build .user {
{{end}}
</td>
{{end}}
- <td class="user">{{.User}}</td>
- <td class="time">{{.Time.Time}}</td>
- <td class="desc">{{.Desc}}</td>
+ <td class="user">{{shortUser .User}}</td>
+ <td class="time">{{.Time.Time.Format "02 Jan 2006 15:04"}}</td>
+ <td class="desc">{{shortDesc .Desc}}</td>
</tr>
{{end}}
</table>