]> Cypherpunks repositories - gostls13.git/commitdiff
dashboard: horizontal crunch
authorRuss Cox <rsc@golang.org>
Thu, 22 Dec 2011 15:22:38 +0000 (10:22 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 22 Dec 2011 15:22:38 +0000 (10:22 -0500)
* 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

misc/dashboard/app/build/ui.go
misc/dashboard/app/build/ui.html

index f2bd02b96854e5971a59fc265c1d431978c116a0..0b55aa239608f477d7229ce602e3231a13a4ffde 100644 (file)
@@ -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,12 +179,84 @@ var uiTemplate = template.Must(
 )
 
 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".
@@ -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
 }
index 429b6ff05701f6df126b7705a5d36f1baf5bff75..1fb7b2527449cc44436fe367c9bb6a807895291b 100644 (file)
       }
       .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>&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}}
       {{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>