From 91aad771ac411b317139bab1b862e9d9cfd4e59d Mon Sep 17 00:00:00 2001
From: Paul Martin <paul@paulsputer.com>
Date: Thu, 07 Apr 2016 19:01:14 -0400
Subject: [PATCH] Fixes #1028 - FilestorePage now pages and filters
---
src/main/java/com/gitblit/wicket/pages/BlamePage.java | 58 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
index c2280a2..2fcca0a 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
@@ -32,6 +32,7 @@
import org.apache.wicket.behavior.SimpleAttributeModifier;
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.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -93,9 +94,34 @@
final BlameType activeBlameType = BlameType.get(blameTypeParam);
RevCommit commit = getCommit();
-
- add(new BookmarkablePageLink<Void>("blobLink", BlobPage.class,
- WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
+
+ PathModel pathModel = null;
+
+ List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit);
+ for (PathModel path : paths) {
+ if (path.path.equals(blobPath)) {
+ pathModel = path;
+ break;
+ }
+ }
+
+ if (pathModel == null) {
+ final String notFound = MessageFormat.format("Blame page failed to find {0} in {1} @ {2}",
+ blobPath, repositoryName, objectId);
+ logger.error(notFound);
+ add(new Label("annotation").setVisible(false));
+ add(new Label("missingBlob", missingBlob(blobPath, commit)).setEscapeModelStrings(false));
+ return;
+ }
+
+ if (pathModel.isFilestoreItem()) {
+ String rawUrl = JGitUtils.getLfsRepositoryUrl(getContextUrl(), repositoryName, pathModel.getFilestoreOid());
+ add(new ExternalLink("blobLink", rawUrl));
+ } else {
+ add(new BookmarkablePageLink<Void>("blobLink", BlobPage.class,
+ WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
+ }
+
add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class,
WicketUtils.newObjectParameter(repositoryName, objectId)));
add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,
@@ -134,26 +160,13 @@
final DateFormat df = new SimpleDateFormat(format);
df.setTimeZone(getTimeZone());
- PathModel pathModel = null;
- List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit);
- for (PathModel path : paths) {
- if (path.path.equals(blobPath)) {
- pathModel = path;
- break;
- }
- }
+
- if (pathModel == null) {
- final String notFound = MessageFormat.format("Blame page failed to find {0} in {1} @ {2}",
- blobPath, repositoryName, objectId);
- logger.error(notFound);
- add(new Label("annotation").setVisible(false));
- add(new Label("missingBlob", missingBlob(blobPath, commit)).setEscapeModelStrings(false));
- return;
- }
+
add(new Label("missingBlob").setVisible(false));
+ final int tabLength = app().settings().getInteger(Keys.web.tabLength, 4);
List<AnnotatedLine> lines = DiffUtils.blame(getRepository(), blobPath, objectId);
final Map<?, String> colorMap = initializeColors(activeBlameType, lines);
ListDataProvider<AnnotatedLine> blameDp = new ListDataProvider<AnnotatedLine>(lines);
@@ -212,7 +225,7 @@
color = colorMap.get(entry.commitId);
break;
}
- Component data = new Label("data", StringUtils.escapeForHtml(entry.data, true)).setEscapeModelStrings(false);
+ Component data = new Label("data", StringUtils.escapeForHtml(entry.data, true, tabLength)).setEscapeModelStrings(false);
data.add(new SimpleAttributeModifier("style", "background-color: " + color + ";"));
item.add(data);
}
@@ -235,6 +248,11 @@
}
@Override
+ protected boolean isCommitPage() {
+ return true;
+ }
+
+ @Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
--
Gitblit v1.9.1