The Unified and Autonomous Development Platform
Add permalink of selection.
robin shine4c3e875fef3f
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.jsindex e410dda571..6c57fbe4a4 100644--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.js+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/codemirror/codemirror.js@@ -9,7 +9,7 @@ gitplex.codemirror = {cursorTimer = undefined;var cursor = cm.getCursor();pmease.commons.history.setCursor(cursor);- $(".preserve-cm-state").each(function() {+ $("a.preserve-cm-state").each(function() {var clientState = $(this).data("client_state");if (!clientState)clientState = {};@@ -21,6 +21,21 @@ gitplex.codemirror = {uri.addSearch("client_state", JSON.stringify(clientState));$(this).attr("href", uri.href());});++ var $selectionPermalink = $(".selection-permalink");+ if (cm.somethingSelected()) {+ $selectionPermalink.show();+ var fromCursor = cm.getCursor("from");+ var toCursor = cm.getCursor("to");+ var highlight = (fromCursor.line+1) + "," + (fromCursor.ch+1) + "-"+ + (toCursor.line+1) + "," + (toCursor.ch+1);+ var uri = new URI($selectionPermalink[0]);+ uri.removeSearch("highlight");+ uri.addSearch("highlight", highlight);+ $selectionPermalink.attr("href", uri.href());+ } else {+ $selectionPermalink.hide();+ }}, 500);});@@ -39,7 +54,7 @@ gitplex.codemirror = {var scrollInfo = cm.getScrollInfo();var scroll = {left: scrollInfo.left, top: scrollInfo.top};pmease.commons.history.setScroll(scroll);- $(".preserve-cm-state").each(function() {+ $("a.preserve-cm-state").each(function() {var clientState = $(this).data("client_state");if (!clientState)clientState = {};diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.htmlindex bf5007db48..721689d93f 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.html@@ -9,13 +9,14 @@<span class="separator">|</span></wicket:enclosure><span wicket:id="size"></span>+ <wicket:container wicket:id="leftActions"></wicket:container></div><div class="pull-right actions"><div class="btn-group"><a wicket:id="raw" class="btn btn-default btn-xs"><i class="fa fa-file-o"></i> Raw</a><a wicket:id="blame" class="btn btn-default btn-xs blame-toggle preserve-cm-state"><i class="fa fa-user"></i> Blame</a><a wicket:id="history" class="btn btn-default btn-xs"><i class="fa fa-history"></i> History</a>- <wicket:container wicket:id="customActions"></wicket:container>+ <wicket:container wicket:id="rightActions"></wicket:container></div><div wicket:id="changeActions" class="btn-group"><a wicket:id="edit" class="btn btn-default btn-xs preserve-cm-state"><i class="fa fa-pencil"></i> <span wicket:id="label"></span></a>diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.javaindex 948c1c7fbf..8f88619976 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/BlobViewPanel.java@@ -91,6 +91,8 @@ public abstract class BlobViewPanel extends Panel {});add(new Label("size", FileUtils.byteCountToDisplaySize(getBlob().getSize())));++ add(newLeftActions("leftActions"));add(new ResourceLink<Void>("raw", new BlobResourceReference(),BlobResource.paramsOf(context.getRepository(), context.getBlobIdent())));@@ -143,7 +145,7 @@ public abstract class BlobViewPanel extends Panel {});- add(newCustomActions("customActions"));+ add(newRightActions("rightActions"));WebMarkupContainer changeActions = new WebMarkupContainer("changeActions") {@@ -268,7 +270,11 @@ public abstract class BlobViewPanel extends Panel {setOutputMarkupId(true);}- protected WebMarkupContainer newCustomActions(String id) {+ protected WebMarkupContainer newLeftActions(String id) {+ return new WebMarkupContainer(id);+ }++ protected WebMarkupContainer newRightActions(String id) {return new WebMarkupContainer(id);}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.htmlindex 7b6bec1d51..e118430312 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.html+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.html@@ -15,7 +15,12 @@</div></div><div wicket:id="symbolTooltip"></div>- <wicket:fragment wicket:id="actionsFrag">+ <wicket:fragment wicket:id="leftActionsFrag">+ <a wicket:id="selectionPermalink" class="selection-permalink">+ <i class="fa fa-link"></i> Permalink of selection+ </a>+ </wicket:fragment>+ <wicket:fragment wicket:id="rightActionsFrag"><a class="btn btn-default btn-xs outline-toggle active"><i class="fa fa-list-ul"></i> Outline</a></wicket:fragment></wicket:extend>\ No newline at end of filediff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.javaindex 37b59b693d..f4bb7104d4 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/SourceViewPanel.java@@ -72,6 +72,7 @@ import com.pmease.gitplex.web.component.repofile.blobview.BlobViewPanel;import com.pmease.gitplex.web.component.symboltooltip.SymbolTooltipPanel;import com.pmease.gitplex.web.page.repository.commit.RepoCommitPage;import com.pmease.gitplex.web.page.repository.file.Highlight;+import com.pmease.gitplex.web.page.repository.file.RepoFilePage;import com.pmease.gitplex.web.utils.DateUtils;@SuppressWarnings("serial")@@ -145,8 +146,22 @@ public class SourceViewPanel extends BlobViewPanel {}@Override- protected WebMarkupContainer newCustomActions(String id) {- Fragment fragment = new Fragment(id, "actionsFrag", this);+ protected WebMarkupContainer newLeftActions(String id) {+ Fragment fragment = new Fragment(id, "leftActionsFrag", this);+ PageParameters params = RepoFilePage.paramsOf(+ context.getRepository(),+ context.getBlobIdent().revision,+ context.getBlobIdent().path,+ null, PullRequest.idOf(context.getPullRequest()));+ String url = RequestCycle.get().urlFor(RepoFilePage.class, params).toString();+ fragment.add(new WebMarkupContainer("selectionPermalink")+ .add(AttributeAppender.replace("href", url)));+ return fragment;+ }++ @Override+ protected WebMarkupContainer newRightActions(String id) {+ Fragment fragment = new Fragment(id, "rightActionsFrag", this);fragment.setVisible(!symbols.isEmpty());return fragment;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.cssindex 70208f0e6c..a3b22254fa 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.css+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/repofile/blobview/source/source-view.css@@ -10,6 +10,10 @@.source-view>.outline .tree-node {line-height: 1.6;}+.selection-permalink {+ margin-left: 16px;+ display: none;+}.CodeMirror-annotations {width: 240px;