From 16e4747d3cb2c2a53a6bef554bca306d8594a080 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 14 Sep 2012 17:51:04 -0400
Subject: [PATCH] Mostly complete blob view line links feature, DOM offset bug remains (issue 130)

---
 src/com/gitblit/wicket/pages/CommitDiffPage.java |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/src/com/gitblit/wicket/pages/CommitDiffPage.java b/src/com/gitblit/wicket/pages/CommitDiffPage.java
index c6c9fd7..dbf981b 100644
--- a/src/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -31,6 +31,7 @@
 import com.gitblit.GitBlit;
 import com.gitblit.Keys;
 import com.gitblit.models.PathModel.PathChangeModel;
+import com.gitblit.models.SubmoduleModel;
 import com.gitblit.utils.DiffUtils;
 import com.gitblit.utils.DiffUtils.DiffOutputType;
 import com.gitblit.utils.JGitUtils;
@@ -59,7 +60,7 @@
 
 		// commit page links
 		if (parents.size() == 0) {
-			add(new Label("parentLink", "none"));
+			add(new Label("parentLink", getString("gb.none")));
 		} else {
 			add(new LinkPanel("parentLink", null, parents.get(0).substring(0, 8),
 					CommitDiffPage.class, newCommitParameter(parents.get(0))));
@@ -86,26 +87,55 @@
 				setChangeTypeTooltip(changeType, entry.changeType);
 				item.add(changeType);
 
+				boolean hasSubmodule = false;
+				String submodulePath = null;
 				if (entry.isTree()) {
+					// tree
 					item.add(new LinkPanel("pathName", null, entry.path, TreePage.class,
 							WicketUtils
 									.newPathParameter(repositoryName, entry.commitId, entry.path)));
+				} else if (entry.isSubmodule()) {
+					// submodule
+					String submoduleId = entry.objectId;						
+					SubmoduleModel submodule = getSubmodule(entry.path);
+					submodulePath = submodule.gitblitPath;
+					hasSubmodule = submodule.hasSubmodule;
+					
+					item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
+							getShortObjectId(submoduleId), TreePage.class,
+							WicketUtils
+									.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
 				} else {
+					// blob
 					item.add(new LinkPanel("pathName", "list", entry.path, BlobPage.class,
 							WicketUtils
 									.newPathParameter(repositoryName, entry.commitId, entry.path)));
 				}
 
-				item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, WicketUtils
-						.newPathParameter(repositoryName, entry.commitId, entry.path)));
-				item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils
-						.newPathParameter(repositoryName, entry.commitId, entry.path)));
-				item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
-						.newPathParameter(repositoryName, entry.commitId, entry.path)));
-				item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
-						.newPathParameter(repositoryName, entry.commitId, entry.path))
-						.setEnabled(!entry.changeType.equals(ChangeType.ADD)));
-
+				// quick links
+				if (entry.isSubmodule()) {
+					// submodule					
+					item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, WicketUtils
+							.newPathParameter(submodulePath, entry.objectId, entry.path)).setEnabled(false));
+					item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils
+							.newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule));
+					item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
+							.newPathParameter(submodulePath, entry.objectId, entry.path)).setEnabled(false));
+					item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
+							.newPathParameter(submodulePath, entry.objectId, entry.path))
+							.setEnabled(hasSubmodule));
+				} else {
+					// tree or blob
+					item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, WicketUtils
+							.newPathParameter(repositoryName, entry.commitId, entry.path)));
+					item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils
+							.newPathParameter(repositoryName, entry.commitId, entry.path)));
+					item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
+							.newPathParameter(repositoryName, entry.commitId, entry.path)));
+					item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
+							.newPathParameter(repositoryName, entry.commitId, entry.path))
+							.setEnabled(!entry.changeType.equals(ChangeType.ADD)));
+				}
 				WicketUtils.setAlternatingBackground(item, counter);
 				counter++;
 			}

--
Gitblit v1.9.1