From: James Moger Date: Sat, 7 Mar 2015 16:17:27 +0000 (-0500) Subject: Expose the DiffComparator choice as an url parameter (?w=1) X-Git-Tag: v1.7.0~1^2~78^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dd661a1091b2a59af513fc846293b6530e73f613;p=gitblit.git Expose the DiffComparator choice as an url parameter (?w=1) --- diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index 9a40931d..0684be30 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -48,6 +48,7 @@ import com.gitblit.IStoredSettings; import com.gitblit.Keys; import com.gitblit.models.FederationModel; import com.gitblit.models.Metric; +import com.gitblit.utils.DiffUtils.DiffComparator; import com.gitblit.utils.HttpUtils; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; @@ -61,7 +62,7 @@ public class WicketUtils { public static void addCssClass(Component container, String value) { container.add(new AttributeAppender("class", new Model(value), " ")); } - + public static void setCssStyle(Component container, String value) { container.add(new SimpleAttributeModifier("style", value)); } @@ -494,6 +495,11 @@ public class WicketUtils { return params.getString("st", null); } + public static DiffComparator getDiffComparator(PageParameters params) { + int ordinal = params.getInt("w", 0); + return DiffComparator.values()[ordinal]; + } + public static int getPage(PageParameters params) { // index from 1 return params.getInt("pg", 1); diff --git a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java index f74e8cb3..bf84fad9 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java @@ -43,7 +43,7 @@ public class BlobDiffPage extends RepositoryPage { final String blobPath = WicketUtils.getPath(params); final String baseObjectId = WicketUtils.getBaseObjectId(params); - final DiffComparator diffComparator = DiffComparator.WS_IGNORE_ALL; + final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); Repository r = getRepository(); RevCommit commit = getCommit(); @@ -67,7 +67,7 @@ public class BlobDiffPage extends RepositoryPage { RevCommit baseCommit = JGitUtils.getCommit(r, baseObjectId); ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, baseCommit.getName(), commit.getName(), imageExtensions); - diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, DiffComparator.WS_IGNORE_ALL, DiffOutputType.HTML, handler).content; + diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, diffComparator, DiffOutputType.HTML, handler).content; if (handler.getImgDiffCount() > 0) { addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs } diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java index 9b3d693b..2ec829ee 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java @@ -86,7 +86,7 @@ public class CommitDiffPage extends RepositoryPage { final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, parents.isEmpty() ? null : parents.get(0), commit.getName(), imageExtensions); - final DiffComparator diffComparator = DiffComparator.WS_IGNORE_ALL; + final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, diffComparator, DiffOutputType.HTML, handler); if (handler.getImgDiffCount() > 0) { addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs diff --git a/src/main/java/com/gitblit/wicket/pages/ComparePage.java b/src/main/java/com/gitblit/wicket/pages/ComparePage.java index 68e904b9..76bf1c50 100644 --- a/src/main/java/com/gitblit/wicket/pages/ComparePage.java +++ b/src/main/java/com/gitblit/wicket/pages/ComparePage.java @@ -117,7 +117,7 @@ public class ComparePage extends RepositoryPage { final ImageDiffHandler handler = new ImageDiffHandler(this, repositoryName, fromCommit.getName(), toCommit.getName(), imageExtensions); - final DiffComparator diffComparator = DiffComparator.WS_IGNORE_ALL; + final DiffComparator diffComparator = WicketUtils.getDiffComparator(params); final DiffOutput diff = DiffUtils.getDiff(r, fromCommit, toCommit, diffComparator, DiffOutputType.HTML, handler); if (handler.getImgDiffCount() > 0) { addBottomScript("scripts/imgdiff.js"); // Tiny support script for image diffs