]> source.dussan.org Git - gitblit.git/commitdiff
UI tweaks, respect gravatar settings, and forward-slash settings
authorJames Moger <james.moger@gitblit.com>
Mon, 5 Nov 2012 21:55:46 +0000 (16:55 -0500)
committerJames Moger <james.moger@gitblit.com>
Mon, 5 Nov 2012 21:55:46 +0000 (16:55 -0500)
groovy/sendmail-html.groovy

index d0a8612d394706ef68cefe66c6938af834ebd128..2c2da9384ddd036950767af87be2f3eb90189a8a 100644 (file)
@@ -135,9 +135,10 @@ def summaryUrl = url + "/summary?r=$repo"
 def baseCommitUrl = url + "/commit?r=$repo&h="\r
 def baseBlobDiffUrl = url + "/blobdiff/?r=$repo&h="\r
 def baseCommitDiffUrl = url + "/commitdiff/?r=$repo&h="\r
+def forwardSlashChar = gitblit.getString(Keys.web.forwardSlashCharacter, '/')\r
 \r
 if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
-    repo = repo.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/')).replace('/', '%2F')\r
+    repo = repo.replace('/', forwardSlashChar).replace('/', '%2F')\r
     summaryUrl = url + "/summary/$repo"\r
     baseCommitUrl = url + "/commit/$repo/"\r
     baseBlobDiffUrl = url + "/blobdiff/$repo/"\r
@@ -151,6 +152,8 @@ class HtmlMailWriter {
     def baseCommitDiffUrl\r
     def baseBlobDiffUrl\r
     def mountParameters\r
+       def forwardSlashChar\r
+       def includeGravatar\r
     def commitCount = 0\r
     def commands\r
     def writer = new StringWriter();\r
@@ -158,9 +161,6 @@ class HtmlMailWriter {
 \r
     def writeStyle() {\r
         builder.style(type:"text/css", '''\r
-    a {\r
-        text-decoration: none;\r
-    }\r
     .table td {\r
         vertical-align: middle;\r
     }\r
@@ -188,19 +188,23 @@ class HtmlMailWriter {
     }\r
 \r
     def writeBranchTitle(type, name, action, number) {\r
-        builder.h2 {\r
-            mkp.yield "$type "\r
-            span(style:"font-family: monospace;", name )\r
-            mkp.yield " $action ($number commits)"\r
+        builder.div('class' : 'pageTitle') {\r
+                       builder.span('class':'project') {\r
+                               mkp.yield "$type "\r
+                               span('class': 'repository', name )\r
+                               mkp.yield " $action ($number commits)"\r
+                       }\r
         }\r
     }\r
 \r
     def writeBranchDeletedTitle(type, name) {\r
-        builder.h2 {\r
-            mkp.yield "$type "\r
-            span(style:"font-family: monospace;", name )\r
-            mkp.yield " deleted"\r
-        }\r
+               builder.div('class' : 'pageTitle', 'style':'color:red') {\r
+                       builder.span('class':'project') {\r
+                               mkp.yield "$type "\r
+                               span('class': 'repository', name )\r
+                               mkp.yield " deleted"\r
+                       }\r
+               }\r
     }\r
 \r
     def commitUrl(RevCommit commit) {\r
@@ -212,7 +216,7 @@ class HtmlMailWriter {
     }\r
 \r
     def encoded(String path) {\r
-        path.replace('/', '!')\r
+        path.replace('/', forwardSlashChar).replace('/', '%2F')\r
     }\r
 \r
     def blobDiffUrl(objectId, path) {\r
@@ -230,7 +234,7 @@ class HtmlMailWriter {
         builder.table('class':"table table-disable-hover") {\r
             thead {\r
                 tr {\r
-                    th(colspan:2, "Author")\r
+                                       th(colspan: includeGravatar ? 2 : 1, "Author")\r
                     th( "Commit" )\r
                     th( "Message" )\r
                 }\r
@@ -243,7 +247,7 @@ class HtmlMailWriter {
 \r
                     // Write detail on that particular commit\r
                     tr {\r
-                        td (colspan:2)\r
+                        td (colspan: includeGravatar ? 3 : 2)\r
                         td (colspan:2) { writeStatusTable(commit) }\r
                     }\r
                 }\r
@@ -252,14 +256,16 @@ class HtmlMailWriter {
     }\r
 \r
     def writeCommit(commit) {\r
-        def abbreviated = repository.newObjectReader().abbreviate(commit.id, 6).name()\r
+        def abbreviated = repository.newObjectReader().abbreviate(commit.id, 8).name()\r
         def author = commit.authorIdent.name\r
         def email = commit.authorIdent.emailAddress\r
         def message = commit.shortMessage\r
         builder.tr {\r
-            td('class':"gravatar-column") {\r
-                img(src:gravatarUrl(email), 'class':"img-rounded")\r
-            }\r
+                       if (includeGravatar) {\r
+                               td('class':"gravatar-column") {\r
+                                       img(src:gravatarUrl(email), 'class':"gravatar")\r
+                               }\r
+                       }\r
             td('class':"author-column", author)\r
             td('class':"commit-column") {\r
                 a(href:commitUrl(commit)) {\r
@@ -268,57 +274,57 @@ class HtmlMailWriter {
             }\r
             td {\r
                 mkp.yield message\r
-                a(href:commitDiffUrl(commit), " [commitdiff]" )\r
+                a('class':'link', href:commitDiffUrl(commit), " [commitdiff]" )\r
             }\r
         }\r
     }\r
 \r
-    def writeStatusLabel(style, label) {\r
-        builder.span('class' : "label " + style,  label )\r
+    def writeStatusLabel(style, tooltip) {\r
+        builder.span('class' : style,  'title' : tooltip )\r
     }\r
 \r
-    def writeAddStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':"status-column") {\r
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-success", "add") }\r
+    def writeAddStatusLine(ObjectId id, FileHeader header) {           \r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("addition", "addition")\r
         }\r
         builder.td {\r
-            span(style:'font-family: monospace;', header.newPath)\r
+            a(href:blobDiffUrl(id, header.newPath)) { span(style:'font-family: monospace;', header.newPath) }\r
         }\r
     }\r
 \r
     def writeCopyStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':"status-column") {\r
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-warning", "copy") }\r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("rename", "rename")\r
         }\r
         builder.td() {\r
-            span(style : "font-family: monospace; ", header.oldPath + " copied to " + header.newPath)\r
+            a(href:blobDiffUrl(id, header.newPath)) { span(style : "font-family: monospace; ", header.oldPath + " copied to " + header.newPath) }\r
         }\r
     }\r
 \r
     def writeDeleteStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':"status-column") {\r
-            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("label-important", "delete") }\r
+        builder.td('class':'changeType') {\r
+            writeStatusLabel("deletion", "deletion")\r
         }\r
         builder.td() {\r
-            span(style : "font-family: monospace; ", header.oldPath)\r
+            a(href:blobDiffUrl(id, header.oldPath)) { span(style : "font-family: monospace; ", header.oldPath) }\r
         }\r
     }\r
 \r
     def writeModifyStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':"status-column") {\r
-            a(href:blobDiffUrl(id, header.oldPath)) { writeStatusLabel("", "modify") }\r
+        builder.td('class':'changeType') {\r
+                       writeStatusLabel("modification", "modification")\r
         }\r
         builder.td() {\r
-            span(style : "font-family: monospace; ", header.oldPath)\r
+            a(href:blobDiffUrl(id, header.oldPath)) { span(style : "font-family: monospace; ", header.oldPath) }\r
         }\r
     }\r
 \r
     def writeRenameStatusLine(ObjectId id, FileHeader header) {\r
-        builder.td('class':"status-column") {\r
-            a(href:blobDiffUrl(id, header.newPath)) { writeStatusLabel("label-info", "rename") }\r
+        builder.td('class':'changeType') {\r
+             writeStatusLabel("rename", "rename")\r
         }\r
         builder.td() {\r
-            span(style : "font-family: monospace; ", header.olPath + " -> " + header.newPath)\r
+            a(href:blobDiffUrl(id, header.newPath)) { span(style : "font-family: monospace; ", header.olPath + " -> " + header.newPath) }\r
         }\r
     }\r
 \r
@@ -360,7 +366,7 @@ class HtmlMailWriter {
                                    new CanonicalTreeParser(null, rw.objectReader, commit.tree))\r
         }\r
         // Write status table\r
-        builder.table('class':"table table-condensed table-bordered table-disable-hover") {\r
+        builder.table('class':"plain") {\r
             tbody() {\r
                 for (DiffEntry entry in diffs) {\r
                     FileHeader header = formatter.toFileHeader(entry)\r
@@ -471,9 +477,11 @@ mailWriter.repository = r
 mailWriter.baseCommitUrl = baseCommitUrl\r
 mailWriter.baseBlobDiffUrl = baseBlobDiffUrl\r
 mailWriter.baseCommitDiffUrl = baseCommitDiffUrl\r
+mailWriter.forwardSlashChar = forwardSlashChar\r
 mailWriter.commands = commands\r
 mailWriter.url = url\r
 mailWriter.mountParameters = gitblit.getBoolean(Keys.web.mountParameters, true)\r
+mailWriter.includeGravatar = gitblit.getBoolean(Keys.web.allowGravatar, true)\r
 \r
 def content = mailWriter.write()\r
 \r
@@ -482,6 +490,6 @@ r.close()
 \r
 // tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
 def repositoryName = repository.name.substring(0, repository.name.length() - 4)\r
-gitblit.sendHtmlMail("${emailprefix}[$repositoryName] ${userModel.displayName} pushed ${mailWriter.commitCount} commits",\r
+gitblit.sendHtmlMail("${emailprefix} ${userModel.displayName} pushed ${mailWriter.commitCount} commits => $repositoryName",\r
                      content,\r
                      toAddresses)\r