Permalink
Browse files

Refactor : moving gravatar compute into user type

  • Loading branch information...
1 parent bd1fe60 commit 7db1f0777ebd02c1cc961ca29961ccd8e2bea93e @trecloux trecloux committed Sep 19, 2011
Showing with 6 additions and 1 deletion.
  1. +1 −1 app/controllers/Home.java
  2. +5 −0 app/models/User.java
@@ -15,7 +15,7 @@
public static void home() {
if(Security.isConnected()) {
User user = User.findByEmail(Security.connected());
- String gravatar = "http://www.gravatar.com/avatar/" + Codec.hexMD5(user.email) + "?s=20";
+ String gravatar = user.gravatar(20);
render("Home/connected.html", user, gravatar);
} else {
render("Home/anonymous.html");
View
@@ -20,6 +20,7 @@
import play.data.validation.Password;
import play.data.validation.Required;
import play.db.jpa.Model;
+import play.libs.Codec;
import play.libs.Crypto;
@Entity
@@ -84,4 +85,8 @@ public void generateConfirmationToken() {
}
+ public String gravatar(int size) {
+ return "http://www.gravatar.com/avatar/" + Codec.hexMD5(email) + "?s=" + size;
+ }
+
}

0 comments on commit 7db1f07

Please sign in to comment.