}
// Used cached version of front page, if available.
- if page == 0 {
+ if page == 0 && r.Host == "build.golang.org" {
t, err := memcache.Get(c, uiCacheKey)
if err == nil {
w.Write(t.Value)
}
// Cache the front page.
- if page == 0 {
+ if page == 0 && r.Host == "build.golang.org" {
t := &memcache.Item{
Key: uiCacheKey,
Value: buf.Bytes(),
)
var tmplFuncs = template.FuncMap{
- "builderTitle": builderTitle,
- "repoURL": repoURL,
- "shortDesc": shortDesc,
- "shortHash": shortHash,
- "shortUser": shortUser,
- "tail": tail,
+ "builderOS": builderOS,
+ "builderArch": builderArch,
+ "builderArchShort": builderArchShort,
+ "builderArchChar": builderArchChar,
+ "builderTitle": builderTitle,
+ "builderSpans": builderSpans,
+ "repoURL": repoURL,
+ "shortDesc": shortDesc,
+ "shortHash": shortHash,
+ "shortUser": shortUser,
+ "tail": tail,
+}
+
+func splitDash(s string) (string, string) {
+ i := strings.Index(s, "-")
+ if i >= 0 {
+ return s[:i], s[i+1:]
+ }
+ return s, ""
+}
+
+// builderOS returns the os tag for a builder string
+func builderOS(s string) string {
+ os, _ := splitDash(s)
+ return os
+}
+
+// builderArch returns the arch tag for a builder string
+func builderArch(s string) string {
+ _, arch := splitDash(s)
+ arch, _ = splitDash(arch) // chop third part
+ return arch
+}
+
+// builderArchShort returns a short arch tag for a builder string
+func builderArchShort(s string) string {
+ arch := builderArch(s)
+ switch arch {
+ case "amd64":
+ return "x64"
+ }
+ return arch
+}
+
+// builderArchChar returns the architecture letter for a builder string
+func builderArchChar(s string) string {
+ arch := builderArch(s)
+ switch arch {
+ case "386":
+ return "8"
+ case "amd64":
+ return "6"
+ case "arm":
+ return "5"
+ }
+ return arch
+}
+
+type builderSpan struct {
+ N int
+ OS string
+}
+
+// builderSpans creates a list of tags showing
+// the builder's operating system names, spanning
+// the appropriate number of columns.
+func builderSpans(s []string) []builderSpan {
+ var sp []builderSpan
+ for len(s) > 0 {
+ i := 1
+ os := builderOS(s[0])
+ for i < len(s) && builderOS(s[i]) == os {
+ i++
+ }
+ sp = append(sp, builderSpan{i, os})
+ s = s[i:]
+ }
+ return sp
}
// builderTitle formats "linux-amd64-foo" as "linux amd64 foo".
// 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 {
+ if i, j := strings.Index(user, "<"), strings.Index(user, ">"); 0 <= i && i < j {
user = user[i+1 : j]
- if k := strings.Index(user, "@golang.org"); k != -1 {
- user = user[:k]
- }
+ }
+ if i := strings.Index(user, "@"); i >= 0 {
+ return user[:i]
}
return user
}
}
.build .result {
text-align: center;
- width: 50px;
+ width: 2em;
+ }
+ .col-hash, .col-result {
+ border-right: solid 1px #ccc;
+ }
+ .build .arch {
+ font-size: 66%;
+ font-weight: normal;
}
.build .time {
color: #666;
}
+ .build .ok {
+ font-size: 83%;
+ }
.build .desc, .build .time, .build .user {
white-space: nowrap;
}
{{if $.Commits}}
<table class="build">
+ <colgroup class="col-hash"></colgroup>
+ {{range $.Builders | builderSpans}}
+ <colgroup class="col-result" span="{{.N}}"></colgroup>
+ {{end}}
+ <colgroup class="col-user"></colgroup>
+ <colgroup class="col-time"></colgroup>
+ <colgroup class="col-desc"></colgroup>
+ <tr>
+ <!-- extra row to make alternating colors use dark for first result -->
+ </tr>
+ <tr>
+ <th> </th>
+ {{range $.Builders | builderSpans}}
+ <th colspan="{{.N}}">{{.OS}}</th>
+ {{end}}
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
<tr>
<th> </th>
{{range $.Builders}}
- <th class="result">{{builderTitle .}}</th>
+ <th class="result arch" title="{{.}}">{{builderArchShort .}}</th>
{{end}}
</tr>
{{range $c := $.Commits}}
{{end}}
</td>
{{end}}
- <td class="user">{{shortUser .User}}</td>
+ <td class="user" title="{{.User}}">{{shortUser .User}}</td>
<td class="time">{{.Time.Time.Format "Mon 02 Jan 15:04"}}</td>
- <td class="desc">{{shortDesc .Desc}}</td>
+ <td class="desc" title="{{.Desc}}">{{shortDesc .Desc}}</td>
</tr>
{{end}}
</table>