Commit 0b702937 authored by Russ Cox's avatar Russ Cox

dashboard: horizontal crunch

* group builders in to columns by OS
* drop builder suffix (moved to hover title)
* cut all domain names from email (full name+email in hover title)
* make ok smaller

This should easily give us room for netbsd and plan9,
even on small laptop screens.

Running at http://build-rsc.golang.org/.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5501064
parent 550856c5
......@@ -37,7 +37,7 @@ func uiHandler(w http.ResponseWriter, r *http.Request) {
}
// 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)
......@@ -78,7 +78,7 @@ func uiHandler(w http.ResponseWriter, r *http.Request) {
}
// Cache the front page.
if page == 0 {
if page == 0 && r.Host == "build.golang.org" {
t := &memcache.Item{
Key: uiCacheKey,
Value: buf.Bytes(),
......@@ -179,7 +179,12 @@ var uiTemplate = template.Must(
)
var tmplFuncs = template.FuncMap{
"builderOS": builderOS,
"builderArch": builderArch,
"builderArchShort": builderArchShort,
"builderArchChar": builderArchChar,
"builderTitle": builderTitle,
"builderSpans": builderSpans,
"repoURL": repoURL,
"shortDesc": shortDesc,
"shortHash": shortHash,
......@@ -187,6 +192,73 @@ var tmplFuncs = template.FuncMap{
"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".
func builderTitle(s string) string {
return strings.Replace(s, "-", " ", -1)
......@@ -210,11 +282,11 @@ func shortHash(hash string) string {
// 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
}
......
......@@ -35,11 +35,21 @@
}
.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;
}
......@@ -66,10 +76,29 @@
{{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>&nbsp;</th>
{{range $.Builders | builderSpans}}
<th colspan="{{.N}}">{{.OS}}</th>
{{end}}
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<th>&nbsp;</th>
{{range $.Builders}}
<th class="result">{{builderTitle .}}</th>
<th class="result arch" title="{{.}}">{{builderArchShort .}}</th>
{{end}}
</tr>
{{range $c := $.Commits}}
......@@ -88,9 +117,9 @@
{{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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment