]> Cypherpunks repositories - gostls13.git/commitdiff
dashboard: improve formatting of build status page
authorAndrew Gerrand <adg@golang.org>
Mon, 19 Dec 2011 05:57:25 +0000 (16:57 +1100)
committerAndrew Gerrand <adg@golang.org>
Mon, 19 Dec 2011 05:57:25 +0000 (16:57 +1100)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5493077

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

index 918b53e5bd6bd79fdc5fe5ea917e8bafacc55f86..1e7ea876b43b05c06b0787b31751c75d07ed10f2 100644 (file)
@@ -148,7 +148,9 @@ var uiTemplate = template.Must(
        template.New("ui").
                Funcs(template.FuncMap{
                        "builderTitle": builderTitle,
+                       "shortDesc":    shortDesc,
                        "shortHash":    shortHash,
+                       "shortUser":    shortUser,
                        "repoURL":      repoURL,
                }).
                ParseFile("build/ui.html"),
@@ -159,7 +161,15 @@ func builderTitle(s string) string {
        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]
@@ -167,6 +177,17 @@ func shortHash(hash string) string {
        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\-]+)?$`)
 
index 684ae1333f91b8a0fb937d117ffea5c724bf6e86..80a924bfca41af8fa11d4e28746d523db600bbc8 100644 (file)
       .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 {
@@ -83,9 +87,9 @@
       {{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>