]> source.dussan.org Git - gitblit.git/commitdiff
Added optional Gravatar support
authorJames Moger <james.moger@gitblit.com>
Mon, 14 Nov 2011 22:24:16 +0000 (17:24 -0500)
committerJames Moger <james.moger@gitblit.com>
Mon, 14 Nov 2011 22:24:16 +0000 (17:24 -0500)
distrib/gitblit.properties
docs/04_releases.mkd
src/com/gitblit/wicket/GravatarImage.java [new file with mode: 0644]
src/com/gitblit/wicket/pages/CommitPage.html
src/com/gitblit/wicket/pages/CommitPage.java

index 0048e55573c0efb4e2f6ac90dcf0392c643be097..083a658e2a0166b49f7ab43077736753dd414af8 100644 (file)
@@ -110,6 +110,11 @@ web.enableRpcManagement = false
 # SINCE 0.7.0 \r
 web.enableRpcAdministration = false\r
 \r
+# Allow Gravatar images to be displayed in Gitblit pages.\r
+#\r
+# SINCE 0.8.0\r
+web.allowGravatar = true\r
+\r
 # Allow dynamic zip downloads.\r
 #\r
 # SINCE 0.5.0   \r
index 90f4f502d28812d2c8e905a97d6070dd82d655f5..5719b1915c5ba6d72ee888bb1452746bc72a2c06 100644 (file)
@@ -3,6 +3,13 @@
 ### Current Release\r
 **%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*\r
 \r
+- added: optional Gravatar integration  \r
+    **New:** *web.allowGravatar = true*   \r
+\r
+### Older Releases\r
+\r
+**0.7.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.7.0.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.7.0.war) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=fedclient-0.7.0.zip) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=manager-0.7.0.zip) | [api](http://code.google.com/p/gitblit/downloads/detail?name=gbapi-0.7.0.zip)) based on [JGit 1.1.0 (201109151100-r)][jgit] &nbsp; *released 2011-11-11*\r
+\r
 - **security**: fixed security hole when cloning clone-restricted repository with TortoiseGit (issue 28)\r
 - improved: updated ui with Twitter's Bootstrap CSS toolkit  \r
     **New:** *web.loginMessage = gitblit*\r
@@ -35,8 +42,6 @@
 - updated: MarkdownPapers 1.2.5\r
 - updated: Wicket 1.4.19\r
 \r
-### Older Releases\r
-\r
 **0.6.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.war) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=fedclient-0.6.0.zip)) based on [JGit 1.1.0 (201109151100-r)][jgit] &nbsp; *released 2011-09-27*\r
 \r
 - added: federation feature to allow gitblit instances (or gitblit federation clients) to pull repositories and, optionally, settings and accounts from other gitblit instances.  This is something like [svn-sync](http://svnbook.red-bean.com/en/1.5/svn.ref.svnsync.html) for gitblit.  \r
diff --git a/src/com/gitblit/wicket/GravatarImage.java b/src/com/gitblit/wicket/GravatarImage.java
new file mode 100644 (file)
index 0000000..ff26fc0
--- /dev/null
@@ -0,0 +1,61 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.wicket;\r
+\r
+import java.text.MessageFormat;\r
+\r
+import org.apache.wicket.AttributeModifier;\r
+import org.apache.wicket.markup.ComponentTag;\r
+import org.apache.wicket.markup.html.WebComponent;\r
+import org.apache.wicket.model.Model;\r
+import org.eclipse.jgit.lib.PersonIdent;\r
+\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+import com.gitblit.utils.StringUtils;\r
+\r
+/**\r
+ * Represents a Gravatar image.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class GravatarImage extends WebComponent {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       public GravatarImage(String id, PersonIdent person) {\r
+               this(id, person, 0);\r
+       }\r
+       \r
+       public GravatarImage(String id, PersonIdent person, int width) {\r
+               super(id);\r
+               if (width <= 0) {\r
+                       width = 60;\r
+               }\r
+               String authorhash = StringUtils.getMD5(person.getEmailAddress().toLowerCase());\r
+               String url = MessageFormat.format("http://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", authorhash, width);\r
+               add(new AttributeModifier("src", true, new Model<String>(url)));\r
+               setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));\r
+       }\r
+\r
+       @Override\r
+       protected void onComponentTag(ComponentTag tag) {\r
+               super.onComponentTag(tag);\r
+               checkComponentTag(tag, "img");\r
+       }\r
+\r
+}
\ No newline at end of file
index f2d328e059d95de5534b7d9e761de89dfee0e9ce..2af05e114642c918b3f0223915940f307fcf088c 100644 (file)
@@ -15,6 +15,9 @@
        <!-- commit header -->\r
        <div wicket:id="commitHeader">[commit header]</div>\r
        \r
+       <!--  Author Gravatar -->\r
+       <img style="float:right;vertical-align: top;" wicket:id="authorAvatar" />\r
+       \r
        <!-- commit info -->\r
        <table class="plain">\r
                <tr><th><wicket:message key="gb.refs">refs</wicket:message></th><td><div wicket:id="refsPanel">[references]</div></td></tr>\r
@@ -53,6 +56,8 @@
                                        <tr><td><span class="sha1" wicket:id="authorName"></span></td></tr>\r
                                        <tr><td><span class="sha1" wicket:id="authorDate"></span></td></tr>\r
                                </table>\r
+                               <!--  Note Author Gravatar -->\r
+                               <img style="vertical-align: top;" wicket:id="noteAuthorAvatar" />                               \r
                        </td>\r
                        <td class="message"><span class="sha1" wicket:id="noteContent"></span></td>\r
                </tr>\r
index dd3decbe5e4f01b83894f69f5a4f0c663a5680c5..bfe03f12d572dacb653ff87f944a271f159590b4 100644 (file)
@@ -38,6 +38,7 @@ import com.gitblit.Keys;
 import com.gitblit.models.GitNote;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.wicket.GravatarImage;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.CommitHeaderPanel;\r
 import com.gitblit.wicket.panels.CommitLegendPanel;\r
@@ -81,7 +82,8 @@ public class CommitPage extends RepositoryPage {
                add(createPersonPanel("commitAuthor", c.getAuthorIdent(), Constants.SearchType.AUTHOR));\r
                add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(),\r
                                getTimeZone()));\r
-\r
+               add(new GravatarImage("authorAvatar", c.getAuthorIdent()));\r
+               \r
                // committer\r
                add(createPersonPanel("commitCommitter", c.getCommitterIdent(), Constants.SearchType.COMMITTER));\r
                add(WicketUtils.createTimestampLabel("commitCommitterDate",\r
@@ -126,6 +128,7 @@ public class CommitPage extends RepositoryPage {
                                item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));\r
                                item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(),\r
                                                Constants.SearchType.AUTHOR));\r
+                               item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));\r
                                item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef\r
                                                .getAuthorIdent().getWhen(), getTimeZone()));\r
                                item.add(new Label("noteContent", GitBlit.self().processCommitMessage(\r