James Moger
2013-06-18 0457984cef51c24f08d32fd802eb7d3c8a204920
src/main/java/com/gitblit/utils/ActivityUtils.java
@@ -27,7 +27,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -35,6 +37,7 @@
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Activity;
import com.gitblit.models.GravatarProfile;
import com.gitblit.models.RefModel;
@@ -78,10 +81,19 @@
      df.setTimeZone(timezone);
      Calendar cal = Calendar.getInstance();
      cal.setTimeZone(timezone);
      // aggregate author exclusions
      Set<String> authorExclusions = new TreeSet<String>();
      authorExclusions.addAll(GitBlit.getStrings(Keys.web.metricAuthorExclusions));
      for (RepositoryModel model : models) {
         if (!ArrayUtils.isEmpty(model.metricAuthorExclusions)) {
            authorExclusions.addAll(model.metricAuthorExclusions);
         }
      }
      Map<String, Activity> activity = new HashMap<String, Activity>();
      for (RepositoryModel model : models) {
         if (model.maxActivityCommits == -1) {
         if (!model.isShowActivity()) {
            // skip this repository
            continue;
         }
@@ -124,7 +136,9 @@
                     cal.set(Calendar.MINUTE, 0);
                     cal.set(Calendar.SECOND, 0);
                     cal.set(Calendar.MILLISECOND, 0);
                     activity.put(dateStr, new Activity(cal.getTime()));
                     Activity a = new Activity(cal.getTime());
                     a.excludeAuthors(authorExclusions);
                     activity.put(dateStr, a);
                  }
                  RepositoryCommit commitModel = activity.get(dateStr)
                        .addCommit(model.name, shortName, commit);
@@ -165,7 +179,7 @@
    *            size of thumbnail. if width <= 0, the default of 50 is used.
    * @return
    */
   public static String getGravatarThumbnailUrl(String email, int width) {
   public static String getGravatarIdenticonUrl(String email, int width) {
      if (width <= 0) {
         width = 50;
      }
@@ -174,6 +188,25 @@
            "https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
      return url;
   }
   /**
    * Creates a Gravatar thumbnail url from the specified email address.
    *
    * @param email
    *            address to query Gravatar
    * @param width
    *            size of thumbnail. if width <= 0, the default of 50 is used.
    * @return
    */
   public static String getGravatarThumbnailUrl(String email, int width) {
      if (width <= 0) {
         width = 50;
      }
      String emailHash = StringUtils.getMD5(email);
      String url = MessageFormat.format(
            "https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=mm", emailHash, width);
      return url;
   }
   /**
    * Returns the Gravatar profile, if available, for the specified hashcode.