James Moger
2013-11-26 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174
src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
@@ -28,6 +28,7 @@
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.PersonIdent;
import com.gitblit.Constants;
import com.gitblit.GitBlit;
@@ -42,14 +43,13 @@
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TagPage;
import com.gitblit.wicket.pages.TreePage;
import com.gitblit.wicket.pages.UserPage;
public class DigestsPanel extends BasePanel {
   private static final long serialVersionUID = 1L;
   private final boolean hasChanges;
   private boolean hasMore;
   public DigestsPanel(String wicketId, List<DailyLogEntry> digests) {
@@ -63,11 +63,12 @@
      final DateFormat df = new SimpleDateFormat(dateFormat);
      df.setTimeZone(timezone);
      final Calendar cal = Calendar.getInstance(timezone);
      ListDataProvider<DailyLogEntry> dp = new ListDataProvider<DailyLogEntry>(digests);
      DataView<DailyLogEntry> pushView = new DataView<DailyLogEntry>("change", dp) {
         private static final long serialVersionUID = 1L;
         @Override
         public void populateItem(final Item<DailyLogEntry> logItem) {
            final DailyLogEntry change = logItem.getModelObject();
            String fullRefName = change.getChangedRefs().get(0);
@@ -79,7 +80,7 @@
               shortRefName = shortRefName.substring(Constants.R_TAGS.length());
               isTag = true;
            }
            String fuzzydate;
            TimeUtils tu = getTimeUtils();
            Date pushDate = change.date;
@@ -111,19 +112,18 @@
            }
            logItem.add(changeIcon);
                if (!isTag) {
                   logItem.add(new Label("whoChanged").setVisible(false));
                } else {
                   if (change.user.username.equals(change.user.emailAddress) && change.user.emailAddress.indexOf('@') > -1) {
                      // username is an email address can not link - 1.2.1 push log bug
                      logItem.add(new Label("whoChanged", change.user.getDisplayName()));
                if (isTag) {
                   // tags are special
                   PersonIdent ident = change.getCommits().get(0).getAuthorIdent();
                   if (!StringUtils.isEmpty(ident.getName())) {
                      logItem.add(new Label("whoChanged", ident.getName()));
                   } else {
                      // link to user account page
                      logItem.add(new LinkPanel("whoChanged", null, change.user.getDisplayName(),
                            UserPage.class, WicketUtils.newUsernameParameter(change.user.username)));
                      logItem.add(new Label("whoChanged", ident.getEmailAddress()));
                   }
                } else {
                   logItem.add(new Label("whoChanged").setVisible(false));
                }
            String preposition = "gb.of";
            boolean isDelete = false;
            String what;
@@ -151,17 +151,17 @@
               break;
            default:
               what = MessageFormat.format(change.getCommitCount() > 1 ? getString("gb.commitsTo") : getString("gb.oneCommitTo"), change.getCommitCount());
               if (change.getAuthorCount() == 1) {
                  by = MessageFormat.format(getString("gb.byOneAuthor"), change.getAuthorIdent().getName());
               } else {
                  by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
                  by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
               }
               break;
            }
            logItem.add(new Label("whatChanged", what));
            logItem.add(new Label("byAuthors", by).setVisible(!StringUtils.isEmpty(by)));
            if (isDelete) {
               // can't link to deleted ref
               logItem.add(new Label("refChanged", shortRefName));
@@ -174,19 +174,19 @@
               logItem.add(new LinkPanel("refChanged", null, shortRefName,
                  TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
            }
            // to/from/etc
            logItem.add(new Label("repoPreposition", getString(preposition)));
            String repoName = StringUtils.stripDotGit(change.repository);
            logItem.add(new LinkPanel("repoChanged", null, repoName,
                  SummaryPage.class, WicketUtils.newRepositoryParameter(change.repository)));
            int maxCommitCount = 5;
            List<RepositoryCommit> commits = change.getCommits();
            if (commits.size() > maxCommitCount) {
               commits = new ArrayList<RepositoryCommit>(commits.subList(0,  maxCommitCount));
               commits = new ArrayList<RepositoryCommit>(commits.subList(0,  maxCommitCount));
            }
            // compare link
            String compareLinkText = null;
            if ((change.getCommitCount() <= maxCommitCount) && (change.getCommitCount() > 1)) {
@@ -202,20 +202,21 @@
               String startRangeId = change.getOldId(fullRefName);
               logItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));
            }
            final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);
            ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
            DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
               private static final long serialVersionUID = 1L;
               @Override
               public void populateItem(final Item<RepositoryCommit> commitItem) {
                  final RepositoryCommit commit = commitItem.getModelObject();
                  // author gravatar
                  commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent().getName(),
                        commit.getAuthorIdent().getEmailAddress(), null, 16, false, false));
                  // merge icon
                  if (commit.getParentCount() > 1) {
                     commitItem.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
@@ -246,7 +247,7 @@
                  WicketUtils.setCssClass(commitHash, "shortsha1");
                  WicketUtils.setHtmlTooltip(commitHash, commit.getName());
                  commitItem.add(commitHash);
                  if (showSwatch) {
                     // set repository color
                     String color = StringUtils.getColor(StringUtils.stripDotGit(change.repository));
@@ -258,14 +259,14 @@
            logItem.add(commitsView);
         }
      };
      add(pushView);
   }
   public boolean hasMore() {
      return hasMore;
   }
   public boolean hideIfEmpty() {
      setVisible(hasChanges);
      return hasChanges;