From 932e93f555b0740a449350db6125ad52a4b395c8 Mon Sep 17 00:00:00 2001
From: Paul Martin <paul@paulsputer.com>
Date: Sat, 26 Mar 2016 11:40:04 -0400
Subject: [PATCH] Fix for #1031 to display error message
---
src/main/java/com/gitblit/wicket/pages/TreePage.java | 57 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java
index df6507f..f138214 100644
--- a/src/main/java/com/gitblit/wicket/pages/TreePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java
@@ -20,17 +20,18 @@
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;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
-import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.models.PathModel;
import com.gitblit.models.SubmoduleModel;
+import com.gitblit.servlet.RawServlet;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
@@ -51,13 +52,11 @@
Repository r = getRepository();
RevCommit commit = getCommit();
- List<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);
+ List<PathModel> paths = JGitUtils.getFilesInPath2(r, path, commit);
// tree page links
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, objectId, path)));
- add(new BookmarkablePageLink<Void>("headLink", TreePage.class,
- WicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));
add(new CompressedDownloadsPanel("compressedLinks", getRequest()
.getRelativePathPrefixToContextRoot(), repositoryName, objectId, path));
@@ -71,12 +70,13 @@
if (path.lastIndexOf('/') > -1) {
parentPath = path.substring(0, path.lastIndexOf('/'));
}
- PathModel model = new PathModel("..", parentPath, 0, FileMode.TREE.getBits(), null, objectId);
+ PathModel model = new PathModel("..", parentPath, null, 0, FileMode.TREE.getBits(), null, objectId);
model.isParentPath = true;
paths.add(0, model);
}
final String id = getBestCommitId(commit);
+
final ByteFormat byteFormat = new ByteFormat();
final String baseUrl = WicketUtils.getGitblitURL(getRequest());
@@ -89,7 +89,9 @@
@Override
public void populateItem(final Item<PathModel> item) {
PathModel entry = item.getModelObject();
+
item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
+
if (entry.isParentPath) {
// parent .. path
item.add(WicketUtils.newBlankImage("pathIcon"));
@@ -97,6 +99,7 @@
item.add(new LinkPanel("pathName", null, entry.name, TreePage.class,
WicketUtils
.newPathParameter(repositoryName, id, entry.path)));
+ item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
item.add(new Label("pathLinks", ""));
} else {
if (entry.isTree()) {
@@ -106,6 +109,8 @@
item.add(new LinkPanel("pathName", "list", entry.name, TreePage.class,
WicketUtils.newPathParameter(repositoryName, id,
entry.path)));
+
+ item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
// links
Fragment links = new Fragment("pathLinks", "treeLinks", this);
@@ -134,6 +139,8 @@
getShortObjectId(submoduleId), TreePage.class,
WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
+ item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
+
Fragment links = new Fragment("pathLinks", "submoduleLinks", this);
links.add(new BookmarkablePageLink<Void>("view", SummaryPage.class,
WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));
@@ -156,17 +163,33 @@
}
item.add(WicketUtils.getFileImage("pathIcon", entry.name));
item.add(new Label("pathSize", byteFormat.format(entry.size)));
- item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
- WicketUtils.newPathParameter(repositoryName, id,
- path)));
-
+
// links
Fragment links = new Fragment("pathLinks", "blobLinks", this);
- links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
- WicketUtils.newPathParameter(repositoryName, id,
- path)));
- links.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
- .newPathParameter(repositoryName, id, path)));
+
+ if (entry.isFilestoreItem()) {
+ item.add(new Label("filestore", getString("gb.filestore")).setVisible(true));
+
+ final String filestoreItemUrl = JGitUtils.getLfsRepositoryUrl(getContextUrl(), repositoryName, entry.getFilestoreOid());
+
+ item.add(new LinkPanel("pathName", "list", displayPath, filestoreItemUrl));
+ links.add(new ExternalLink("view", filestoreItemUrl));
+ links.add(new ExternalLink("raw", filestoreItemUrl));
+
+ } else {
+ item.add(new Label("filestore", getString("gb.filestore")).setVisible(false));
+
+ item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
+ WicketUtils.newPathParameter(repositoryName, id,
+ path)));
+
+ links.add(new BookmarkablePageLink<Void>("view", BlobPage.class,
+ WicketUtils.newPathParameter(repositoryName, id,
+ path)));
+ String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, path);
+ links.add(new ExternalLink("raw", rawUrl));
+ }
+
links.add(new BookmarkablePageLink<Void>("blame", BlamePage.class,
WicketUtils.newPathParameter(repositoryName, id,
path)));
@@ -187,4 +210,10 @@
protected String getPageName() {
return getString("gb.tree");
}
+
+ @Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
}
--
Gitblit v1.9.1