From 6bb3b233c8a73d4fe4e5024794029fdc75a9f1bb Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 14 Sep 2012 09:36:46 -0400
Subject: [PATCH] Expose ReceivePack to Groovy hooks (issue 125)
---
src/com/gitblit/wicket/pages/BlobPage.java | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java
index 3c5c8e0..e2683ae 100644
--- a/src/com/gitblit/wicket/pages/BlobPage.java
+++ b/src/com/gitblit/wicket/pages/BlobPage.java
@@ -21,6 +21,7 @@
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
@@ -30,6 +31,7 @@
import com.gitblit.Keys;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
+import com.gitblit.wicket.ExternalImage;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.CommitHeaderPanel;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
@@ -41,18 +43,21 @@
Repository r = getRepository();
final String blobPath = WicketUtils.getPath(params);
-
+ String [] encodings = GitBlit.getEncodings();
+
if (StringUtils.isEmpty(blobPath)) {
// blob by objectid
- add(new Label("blameLink", getString("gb.blame")).setEnabled(false));
+ add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
+ WicketUtils.newPathParameter(repositoryName, objectId, blobPath))
+ .setEnabled(false));
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class).setEnabled(false));
add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
add(new BookmarkablePageLink<Void>("headLink", BlobPage.class).setEnabled(false));
add(new CommitHeaderPanel("commitHeader", objectId));
add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));
- Component c = new Label("blobText", JGitUtils.getStringContent(r, objectId));
+ Component c = new Label("blobText", JGitUtils.getStringContent(r, objectId, encodings));
WicketUtils.setCssClass(c, "plainprint");
add(c);
} else {
@@ -74,7 +79,8 @@
RevCommit commit = JGitUtils.getCommit(r, objectId);
// blob page links
- add(new Label("blameLink", getString("gb.blame")));
+ add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
+ WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,
@@ -104,34 +110,41 @@
type = map.get(extension);
}
Component c = null;
+ Component i = null;
switch (type) {
case 1:
// PrettyPrint blob text
c = new Label("blobText", JGitUtils.getStringContent(r, commit.getTree(),
- blobPath));
+ blobPath, encodings));
WicketUtils.setCssClass(c, "prettyprint linenums");
+ i = new Image("blobImage").setVisible(false);
break;
case 2:
- // TODO image blobs
- c = new Label("blobText", "Image File");
+ // image blobs
+ c = new Label("blobText").setVisible(false);
+ i = new ExternalImage("blobImage", urlFor(RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, blobPath)).toString());
break;
case 3:
- // TODO binary blobs
+ // binary blobs
c = new Label("blobText", "Binary File");
+ i = new Image("blobImage").setVisible(false);
break;
default:
// plain text
c = new Label("blobText", JGitUtils.getStringContent(r, commit.getTree(),
- blobPath));
+ blobPath, encodings));
WicketUtils.setCssClass(c, "plainprint");
+ i = new Image("blobImage").setVisible(false);
}
add(c);
+ add(i);
} else {
// plain text
Label blobLabel = new Label("blobText", JGitUtils.getStringContent(r,
- commit.getTree(), blobPath));
+ commit.getTree(), blobPath, encodings));
WicketUtils.setCssClass(blobLabel, "plainprint");
add(blobLabel);
+ add(new Image("blobImage").setVisible(false));
}
}
}
--
Gitblit v1.9.1