James Moger
2013-02-25 9effe1630d97039b3e01cd9b58ed07e75be1d63c
src/com/gitblit/wicket/pages/TreePage.java
@@ -20,7 +20,6 @@
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
@@ -30,15 +29,13 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.DownloadZipServlet;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.PathModel;
import com.gitblit.models.SubmoduleModel;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.CommitHeaderPanel;
import com.gitblit.wicket.panels.CompressedDownloadsPanel;
import com.gitblit.wicket.panels.LinkPanel;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
@@ -58,9 +55,8 @@
            WicketUtils.newPathParameter(repositoryName, objectId, path)));
      add(new BookmarkablePageLink<Void>("headLink", TreePage.class,
            WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));
      add(new ExternalLink("zipLink", DownloadZipServlet.asLink(getRequest()
            .getRelativePathPrefixToContextRoot(), repositoryName, objectId, path))
            .setVisible(GitBlit.getBoolean(Keys.web.allowZipDownloads, true)));
      add(new CompressedDownloadsPanel("compressedLinks", getRequest()
            .getRelativePathPrefixToContextRoot(), repositoryName, objectId, path));
      add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
@@ -114,10 +110,10 @@
                              entry.path)));
                  links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                  links.add(new ExternalLink("zip", DownloadZipServlet.asLink(baseUrl,
                        repositoryName, objectId, entry.path)).setVisible(GitBlit
                        .getBoolean(Keys.web.allowZipDownloads, true)));
                              entry.path)));
                  links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                        repositoryName, objectId, entry.path));
                  item.add(links);
               } else if (entry.isSubmodule()) {
                  // submodule
@@ -141,33 +137,38 @@
                        WicketUtils.newPathParameter(submodulePath, submoduleId,
                              "")).setEnabled(hasSubmodule));
                  links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                        WicketUtils.newPathParameter(submodulePath, submoduleId,
                              "")).setEnabled(hasSubmodule));
                  links.add(new ExternalLink("zip", DownloadZipServlet.asLink(baseUrl,
                        submodulePath, submoduleId, "")).setVisible(GitBlit
                        .getBoolean(Keys.web.allowZipDownloads, true)).setEnabled(hasSubmodule));
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                  links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
                        submodulePath, submoduleId, "").setEnabled(hasSubmodule));
                  item.add(links);                  
               } else {
                  // blob link
                  String displayPath = entry.name;
                  String path = entry.path;
                  if (entry.isSymlink()) {
                     path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
                     displayPath = entry.name + " -> " + path;
                  }
                  item.add(WicketUtils.getFileImage("pathIcon", entry.name));
                  item.add(new Label("pathSize", byteFormat.format(entry.size)));
                  item.add(new LinkPanel("pathName", "list", entry.name, BlobPage.class,
                  item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                              path)));
                  // links
                  Fragment links = new Fragment("pathLinks", "blobLinks", this);
                  links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                              path)));
                  links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
                        .newPathParameter(repositoryName, entry.commitId, entry.path)));
                        .newPathParameter(repositoryName, entry.commitId, path)));
                  links.add(new BookmarkablePageLink<Void>("blame", BlamePage.class,
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                              path)));
                  links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
                        WicketUtils.newPathParameter(repositoryName, entry.commitId,
                              entry.path)));
                              path)));
                  item.add(links);
               }
            }