From ddec289815d4bd0e77d07b965b05b6a639f2c80d Mon Sep 17 00:00:00 2001
From: Guillaume Sauthier <guillaume.sauthier@peergreen.com>
Date: Mon, 05 Nov 2012 12:13:32 -0500
Subject: [PATCH] Fixes and reuse Bootstrap CSS in HTML sendmail (pull request #52)

---
 groovy/sendmail-html.groovy |  111 +++++++++++++------------------------------------------
 1 files changed, 27 insertions(+), 84 deletions(-)

diff --git a/groovy/sendmail-html.groovy b/groovy/sendmail-html.groovy
index fb89a14..d0a8612 100644
--- a/groovy/sendmail-html.groovy
+++ b/groovy/sendmail-html.groovy
@@ -158,92 +158,32 @@
 
     def writeStyle() {
         builder.style(type:"text/css", '''
-    th, td {  
-        padding: 2px;  
-    }
-    thead {
-        text-align: left;
-        font-weight: bold; 
-    }
-    thead tr {
-        border-bottom: 1px dotted #000; 
-    }
     a {
         text-decoration: none;
     }
-    .commits-table {
-        border-collapse: collapse;
-        font-family: sans-serif; 
-        width: 100%; 
-    }
-    .label-commit {
-        border-radius:4px;
-        background-color: #3A87AD;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
-    }
-    .label-add {
-        border-radius:4px;
-        background-color: green;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
-    }
-    .label-delete {
-        border-radius:4px;
-        background-color: grey;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
-    }
-    .label-rename {
-        border-radius:4px;
-        background-color: blue;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
-    }
-    .label-modify {
-        border-radius:4px;
-        background-color: orange;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
-    }
-    .label-copy {
-        border-radius:4px;
-        background-color: teal;
-        padding: 2px 4px;
-        color: white;
-        vertical-align: baseline; 
-        font-weight: bold; 
-        font-family: monospace; 
+    .table td {
+        vertical-align: middle;
     }
     .gravatar-column {
         width: 5%; 
     }
     .author-column {
-        width: 10%; 
+        width: 20%; 
     }
     .commit-column {
         width: 5%; 
     }
     .status-column {
         width: 10%;
-        padding-bottom: 5px; 
-        padding-top: 5px; 
     }
+.table-disable-hover.table tbody tr:hover td,
+.table-disable-hover.table tbody tr:hover th {
+    background-color: inherit;
+}
+.table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,
+.table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {
+  background-color: #f9f9f9;
+}
     ''')
     }
 
@@ -287,7 +227,7 @@
 
     def writeCommitTable(commits) {
         // Write commits table
-        builder.table('class':"commits-table") {
+        builder.table('class':"table table-disable-hover") {
             thead {
                 tr {
                     th(colspan:2, "Author")
@@ -303,8 +243,8 @@
 
                     // Write detail on that particular commit
                     tr {
-                        td (colspan:3)
-                        td { writeStatusTable(commit) }
+                        td (colspan:2)
+                        td (colspan:2) { writeStatusTable(commit) }
                     }
                 }
             }
@@ -318,12 +258,12 @@
         def message = commit.shortMessage
         builder.tr {
             td('class':"gravatar-column") {
-                img(src:gravatarUrl(email))
+                img(src:gravatarUrl(email), 'class':"img-rounded")
             }
-            td('class':"author-column") { p(author) }
+            td('class':"author-column", author)
             td('class':"commit-column") {
                 a(href:commitUrl(commit)) {
-                    span('class':"label-commit",  abbreviated )
+                    span('class':"label label-info",  abbreviated )
                 }
             }
             td {
@@ -334,12 +274,12 @@
     }
 
     def writeStatusLabel(style, label) {
-        builder.span('class' : style,  label )
+        builder.span('class' : "label " + style,  label )
     }
 
     def writeAddStatusLine(ObjectId id, FileHeader header) {
         builder.td('class':"status-column") {
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-add", "add") }
+            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-success", "add") }
         }
         builder.td {
             span(style:'font-family: monospace;', header.newPath)
@@ -348,7 +288,7 @@
 
     def writeCopyStatusLine(ObjectId id, FileHeader header) {
         builder.td('class':"status-column") {
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-copy", "copy") }
+            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-warning", "copy") }
         }
         builder.td() {
             span(style : "font-family: monospace; ", header.oldPath + " copied to " + header.newPath)
@@ -357,7 +297,7 @@
 
     def writeDeleteStatusLine(ObjectId id, FileHeader header) {
         builder.td('class':"status-column") {
-            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("label-delete", "delete") }
+            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("label-important", "delete") }
         }
         builder.td() {
             span(style : "font-family: monospace; ", header.oldPath)
@@ -366,7 +306,7 @@
 
     def writeModifyStatusLine(ObjectId id, FileHeader header) {
         builder.td('class':"status-column") {
-            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("label-modify", "modify") }
+            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("", "modify") }
         }
         builder.td() {
             span(style : "font-family: monospace; ", header.oldPath)
@@ -375,7 +315,7 @@
 
     def writeRenameStatusLine(ObjectId id, FileHeader header) {
         builder.td('class':"status-column") {
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-rename", "rename") }
+            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-info", "rename") }
         }
         builder.td() {
             span(style : "font-family: monospace; ", header.olPath + " -> " + header.newPath)
@@ -420,7 +360,7 @@
                                    new CanonicalTreeParser(null, rw.objectReader, commit.tree))
         }
         // Write status table
-        builder.table('class':"commits-table") {
+        builder.table('class':"table table-condensed table-bordered table-disable-hover") {
             tbody() {
                 for (DiffEntry entry in diffs) {
                     FileHeader header = formatter.toFileHeader(entry)
@@ -473,6 +413,8 @@
 
                 writeNavbar()
 
+				div('class':"container") {
+
                 for (command in commands) {
                     def ref = command.refName
                     def refType = 'Branch'
@@ -516,6 +458,7 @@
                             break
                     }
                 }
+                }
             }
         }
         writer.toString()

--
Gitblit v1.9.1