@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();
     }
   }
 }
  @Override
  protected void addDropDownMenus(List<PageRegistration> pages) {
    PageParameters params = getPageParameters();

    DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", ProjectPage.class);
    // preserve time filter option on repository choices
    menu.menuItems.addAll(getRepositoryFilterItems(params));

    // preserve repository filter option on time choices
    menu.menuItems.addAll(getTimeFilterItems(params));

    if (menu.menuItems.size() > 0) {
      // Reset Filter
      menu.menuItems.add(
          new DropDownMenuItem(getString("gb.reset"), "p", WicketUtils.getProjectName(params)));
    }

    pages.add(menu);

    DropDownMenuRegistration projects =
        new DropDownMenuRegistration("gb.projects", ProjectPage.class);
    projects.menuItems.addAll(getProjectsMenu());
    pages.add(projects);
  }
  private void setup(PageParameters params) {
    setupPage("", "");
    // check to see if we should display a login message
    boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);
    if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {
      authenticationError("Please login");
      return;
    }

    String projectName = WicketUtils.getProjectName(params);
    if (StringUtils.isEmpty(projectName)) {
      throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
    }

    ProjectModel project = getProjectModel(projectName);
    if (project == null) {
      throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
    }

    add(new Label("projectTitle", project.getDisplayName()));
    add(new Label("projectDescription", project.description));

    String feedLink =
        SyndicationServlet.asLink(
            getRequest().getRelativePathPrefixToContextRoot(), projectName, null, 0);
    add(new ExternalLink("syndication", feedLink));

    add(
        WicketUtils.syndicationDiscoveryLink(
            SyndicationServlet.getTitle(project.getDisplayName(), null), feedLink));

    // project markdown message
    String pmessage = transformMarkdown(project.projectMarkdown);
    Component projectMessage =
        new Label("projectMessage", pmessage)
            .setEscapeModelStrings(false)
            .setVisible(pmessage.length() > 0);
    add(projectMessage);

    // markdown message above repositories list
    String rmessage = transformMarkdown(project.repositoriesMarkdown);
    Component repositoriesMessage =
        new Label("repositoriesMessage", rmessage)
            .setEscapeModelStrings(false)
            .setVisible(rmessage.length() > 0);
    add(repositoriesMessage);

    UserModel user = GitBlitWebSession.get().getUser();
    if (user == null) {
      user = UserModel.ANONYMOUS;
    }
    int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
    if (daysBack < 1) {
      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.remove("db");

    List<RepositoryModel> repositories = getRepositories(params);
    Collections.sort(
        repositories,
        new Comparator<RepositoryModel>() {
          @Override
          public int compare(RepositoryModel o1, RepositoryModel o2) {
            // reverse-chronological sort
            return o2.lastChange.compareTo(o1.lastChange);
          }
        });

    addActivity(user, repositories, getString("gb.recentActivity"), daysBack);

    if (repositories.isEmpty()) {
      add(new Label("repositoryList").setVisible(false));
    } else {
      FilterableRepositoryList repoList =
          new FilterableRepositoryList("repositoryList", repositories);
      repoList.setAllowCreate(user.canCreate(project.name + "/"));
      add(repoList);
    }
  }