Florian Zschocke
2013-08-15 69007029f122c3f77db044e879188cc12be3c2f6
src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -19,6 +19,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -60,9 +61,10 @@
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.DeepCopier;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.PushLogUtils;
import com.gitblit.utils.RefLogUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TicgitUtils;
import com.gitblit.wicket.CacheControl;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.PageRegistration;
import com.gitblit.wicket.PageRegistration.OtherPageLink;
@@ -187,12 +189,12 @@
      RepositoryModel model = getRepositoryModel();
      // standard links
      if (PushLogUtils.getPushLogBranch(r) == null) {
      if (RefLogUtils.getRefLogBranch(r) == null) {
         pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
      } else {
         pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));
//         pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));
         pages.put("pushes", new PageRegistration("gb.pushes", PushesPage.class, params));
         pages.put("reflog", new PageRegistration("gb.reflog", ReflogPage.class, params));
      }      
      pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));
      pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));
@@ -226,9 +228,6 @@
      isOwner = GitBlitWebSession.get().isLoggedIn()
            && (model.isOwner(GitBlitWebSession.get()
                  .getUsername()));
      if (showAdmin || isOwner) {
         pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params));
      }
      return pages;
   }
   
@@ -336,6 +335,13 @@
         }
      }
      
      if (showAdmin || isOwner) {
         String url = getRequestCycle().urlFor(EditRepositoryPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();
         add(new ExternalLink("editLink", url));
      } else {
         add(new Label("editLink").setVisible(false));
      }
      super.setupPage(repositoryName, pageName);
   }
   
@@ -390,7 +396,8 @@
      RevCommit commit = JGitUtils.getCommit(r, objectId);
      if (commit == null) {
         error(MessageFormat.format(getString("gb.failedToFindCommit"),
               objectId, repositoryName, getPageName()), true);
               objectId, repositoryName, getPageName()), null, LogPage.class,
               WicketUtils.newRepositoryParameter(repositoryName));
      }
      getSubmodules(commit);
      return commit;
@@ -441,7 +448,7 @@
         if (submoduleName.lastIndexOf('/') > -1) {
            String name = submoduleName.substring(submoduleName.lastIndexOf('/') + 1);
            candidates.add(currentPath + StringUtils.stripDotGit(name));
            candidates.add(currentPath + candidates.get(candidates.size() - 1) + ".git");
            candidates.add(candidates.get(candidates.size() - 1) + ".git");
         }
         // absolute
@@ -567,6 +574,30 @@
      setupPage(repositoryName, "/ " + getPageName());
      super.onBeforeRender();
   }
   @Override
   protected void setLastModified() {
      if (getClass().isAnnotationPresent(CacheControl.class)) {
         CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);
         switch (cacheControl.value()) {
         case REPOSITORY:
            RepositoryModel repository = getRepositoryModel();
            if (repository != null) {
               setLastModified(repository.lastChange);
            }
            break;
         case COMMIT:
            RevCommit commit = getCommit();
            if (commit != null) {
               Date commitDate = JGitUtils.getCommitDate(commit);
               setLastModified(commitDate);
            }
            break;
         default:
            super.setLastModified();
         }
      }
   }
   protected PageParameters newRepositoryParameter() {
      return WicketUtils.newRepositoryParameter(repositoryName);