Florian Zschocke
2013-08-15 69007029f122c3f77db044e879188cc12be3c2f6
src/main/java/com/gitblit/wicket/pages/ProjectPage.java
@@ -24,7 +24,6 @@
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.panel.Fragment;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
@@ -34,6 +33,8 @@
import com.gitblit.models.UserModel;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.GitblitRedirectException;
@@ -41,7 +42,9 @@
import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.FilterableRepositoryList;
@CacheControl(LastModified.PROJECT)
public class ProjectPage extends DashboardPage {
   
   List<ProjectModel> projectModels = new ArrayList<ProjectModel>();
@@ -60,6 +63,26 @@
      return RepositoriesPage.class;
   }
   @Override
   protected void setLastModified() {
      if (getClass().isAnnotationPresent(CacheControl.class)) {
         CacheControl cacheControl = getClass().getAnnotation(CacheControl.class);
         switch (cacheControl.value()) {
         case PROJECT:
            String projectName = WicketUtils.getProjectName(getPageParameters());
            if (!StringUtils.isEmpty(projectName)) {
               ProjectModel project = getProjectModel(projectName);
               if (project != null) {
                  setLastModified(project.lastChange);
               }
            }
            break;
         default:
            super.setLastModified();
         }
      }
   }
   private void setup(PageParameters params) {
      setupPage("", "");
      // check to see if we should display a login message
@@ -106,12 +129,12 @@
      }
      int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
      if (daysBack < 1) {
         daysBack = 7;
         daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
      }
      // reset the daysback parameter so that we have a complete project
      // repository list.  the recent activity will be built up by the
      // reflog utils.
      params.put("db", 0);
      params.remove("db");
      
      List<RepositoryModel> repositories = getRepositories(params);
      Collections.sort(repositories, new Comparator<RepositoryModel>() {
@@ -122,14 +145,14 @@
         }
      });
      addActivity(user, repositories, daysBack);
      addActivity(user, repositories, getString("gb.recentActivity"), daysBack);
      
      if (repositories.isEmpty()) {
         add(new Label("repositoryList").setVisible(false));
      } else {
         Fragment activeView = createNgList("repositoryList", "repositoryListFragment", "repositoryListCtrl", repositories);
         add(activeView);
         FilterableRepositoryList repoList = new FilterableRepositoryList("repositoryList", repositories);
         repoList.setAllowCreate(user.canCreate(project.name + "/"));
         add(repoList);
      }
   }