]> source.dussan.org Git - gitblit.git/commitdiff
Fixes and reuse Bootstrap CSS in HTML sendmail (pull request #52)
authorGuillaume Sauthier <guillaume.sauthier@peergreen.com>
Mon, 5 Nov 2012 17:13:32 +0000 (12:13 -0500)
committerJames Moger <james.moger@gitblit.com>
Mon, 5 Nov 2012 17:13:32 +0000 (12:13 -0500)
groovy/sendmail-html.groovy

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