summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
diff options
context:
space:
mode:
authorTom <tw201207@gmail.com>2014-11-11 07:52:15 +0100
committerTom <tw201207@gmail.com>2014-11-11 08:00:30 +0100
commit7dd99fe7474604f314c01bcd4123eb7cbacfb583 (patch)
tree84f3b0da388cdc79c2b31e6fab5619fc1617e455 /src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
parent8cd4feca58b55f311a543c744777e930c4f4b34a (diff)
downloadgitblit-7dd99fe7474604f314c01bcd4123eb7cbacfb583.tar.gz
gitblit-7dd99fe7474604f314c01bcd4123eb7cbacfb583.zip
Image diffs
Ticket 88: https://dev.gitblit.com/tickets/gitblit.git/88 Based on Lea Verou's pure CSS slider: http://lea.verou.me/2014/07/image-comparison-slider-with-pure-css/ * Add a callback interface, pass it through DiffUtils to the GitBlitDiffFormatter. Is needed because the rendering needs access to the repositoryName and other things that are known only at higher levels. * New class ImageDiffHandler responsible for rendering an image diff. Called for all binary diffs, doesn't do anything if it's not an image. HTML is generated via JSoup: no worries about forgetting to close a tag, not about HTML escaping, nor about XSS. * The 3 diff pages set up such an ImageDIffHandler and pass it along. * CSS changes: from Lea Verou, with some minor improvements. I think in the long run there'll be no way around rewriting the HTML diff formatter from scratch, not using the standard JGit DiffFormatter at all.
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
index 34ff5a29..77d5ccf3 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -31,6 +31,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.Constants;
+import com.gitblit.Keys;
import com.gitblit.models.GitNote;
import com.gitblit.models.PathModel.PathChangeModel;
import com.gitblit.models.SubmoduleModel;
@@ -59,8 +60,6 @@ public class CommitDiffPage extends RepositoryPage {
RevCommit commit = getCommit();
- final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, DiffOutputType.HTML);
-
List<String> parents = new ArrayList<String>();
if (commit.getParentCount() > 0) {
for (RevCommit parent : commit.getParents()) {
@@ -82,6 +81,11 @@ public class CommitDiffPage extends RepositoryPage {
add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
+ final List<String> imageExtensions = app().settings().getStrings(Keys.web.imageExtensions);
+ final ImageDiffHandler handler = new ImageDiffHandler(getContextUrl(), repositoryName,
+ parents.isEmpty() ? null : parents.get(0), commit.getName(), imageExtensions);
+ final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, DiffOutputType.HTML, handler);
+
// add commit diffstat
int insertions = 0;
int deletions = 0;