aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Conley2013-08-22 15:52:50 (EDT)
committerBogdan Gheorghe2013-08-22 15:53:47 (EDT)
commit21b213494f12241903ae6e71640a8eadc42bad2d (patch)
treec9f93b1edced09354af9d5fa8f32cf2132fb798d
parent3083b82aa2a0c6487ddb023936aed594f27583fd (diff)
downloadorg.eclipse.orion.client-21b213494f12241903ae6e71640a8eadc42bad2d.zip
org.eclipse.orion.client-21b213494f12241903ae6e71640a8eadc42bad2d.tar.gz
org.eclipse.orion.client-21b213494f12241903ae6e71640a8eadc42bad2d.tar.bz2
Show git blame annotations in the editor.
Signed-off-by: Chris Conley <chrisconley15@gmail.com>
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.css32
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js46
2 files changed, 66 insertions, 12 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.css b/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.css
index aa7f2bc..0884b36 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.css
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/annotations.css
@@ -225,3 +225,35 @@
background-color: #EAF2FE;
}
+
+
+#gravatar{
+ height:64px;
+ width:64px;
+ position:absolute;
+ padding-top:8px;
+ padding-left:4px;
+}
+#authorImage{
+ width: 72px;
+ height: 80px;
+ float:left;
+}
+
+.title{
+ height: 20px;
+ padding: 4px 0px 8px 0px;
+ margin: 0px;
+}
+
+
+.tooltipCommitInfo{
+ float:right;
+ background-color: InfoBackground;
+ color: InfoText;
+ margin-right: 4px;
+}
+
+.titleSpan{
+ width:100%;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
index edb8f60..9c9ffff 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
@@ -16,8 +16,9 @@ define("orion/editor/editor", [ //$NON-NLS-0$
'orion/editor/eventTarget', //$NON-NLS-0$
'orion/editor/tooltip', //$NON-NLS-0$
'orion/editor/annotations', //$NON-NLS-0$
- 'orion/util' //$NON-NLS-0$
-], function(messages, mEventTarget, mTooltip, mAnnotations, util) {
+ 'orion/util', //$NON-NLS-0$
+ 'require' //$NON-NLS-0$
+], function(messages, mEventTarget, mTooltip, mAnnotations, util, require) {
/** @private */
function merge(obj1, obj2) {
@@ -763,8 +764,8 @@ define("orion/editor/editor", [ //$NON-NLS-0$
showBlame : function(blameMarkers) {
var blameRGB = this._blameRGB;
+ var document = this.getTextView().getOptions("parent").ownerDocument; //$NON-NLS-0$
if (!blameRGB) {
- var document = this.getTextView().getOptions("parent").ownerDocument; //$NON-NLS-0$
var div = util.createElement(document, "div"); //$NON-NLS-0$
div.className = "annotation blame"; //$NON-NLS-0$
document.body.appendChild(div);
@@ -782,6 +783,8 @@ define("orion/editor/editor", [ //$NON-NLS-0$
annotation.style = merge({}, annotation.style);
annotation.style.style = merge({}, annotation.style.style);
annotation.style.style.backgroundColor = "";
+ annotation.blameMarker = this.blameMarker;
+ annotation.html = this.html;
this.groupAnnotation = annotation;
return annotation;
};
@@ -791,21 +794,40 @@ define("orion/editor/editor", [ //$NON-NLS-0$
], function (blameMarker) {
var start = model.getLineStart(blameMarker.Start - 1);
var end = model.getLineEnd(blameMarker.End - 1, true);
- var string = "Message: " + blameMarker.Message.substring(0, 80) + "\nID:" +
- blameMarker.Name + "\nLocation: " +
- blameMarker.CommitLocation + "\nAuthor: " +
- blameMarker.AuthorName + " (" + blameMarker.AuthorEmail +
- ") " + blameMarker.Time + "\nCommitter: " +
- blameMarker.CommitterName + " (" + blameMarker.CommitterEmail +
- ")";
-
- var annotation = mAnnotations.AnnotationType.createAnnotation(AT.ANNOTATION_BLAME, start, end, string);
+
+ blameMarker.Message = blameMarker.Message.substring(0, 60);
+ blameMarker.CommitLocation = require.toUrl("git/git-commit.html#")+blameMarker.CommitLocation+"?page=1&pageSize=1"; //$NON-NLS-0$ //$NON-NLS-1$
+ var title = function(){
+ var blameMarker = this.blameMarker;
+ var div = util.createElement(document, "div"); //$NON-NLS-0$
+ div.className = "tooltipCommitInfo"; //$NON-NLS-0$
+ var h3 = util.createElement(document, "h3"); //$NON-NLS-0$
+ var a = util.createElement(document, "a"); //$NON-NLS-0$
+ a.href = blameMarker.CommitLocation;
+ h3.className = "title"; //$NON-NLS-0$
+ a.innerHTML = blameMarker.Message ;
+ h3.appendChild(a);
+ div.appendChild(h3);
+ var commitInfo = "Author: "+ blameMarker.AuthorName + " (" + blameMarker.AuthorEmail+") "+
+ blameMarker.Time +"\nCommitter: "+ blameMarker.CommitterName+" ("+
+ blameMarker.CommitterEmail+")\nCommit: "+blameMarker.Name;
+ div.appendChild(document.createTextNode(commitInfo));
+ return div;
+ };
+ var annotation = mAnnotations.AnnotationType.createAnnotation(AT.ANNOTATION_BLAME, start, end, title);
var blameColor = blameRGB.slice(0);
blameColor.push(blameMarker.Shade);
annotation.style = merge({}, annotation.style);
annotation.style.style = merge({}, annotation.style.style);
annotation.style.style.backgroundColor = "rgba(" + blameColor.join() + ")"; //$NON-NLS-0$ //$NON-NLS-1$
+
+ annotation.html =
+ "<div id='authorImage'>" +
+ "<img id='gravatar' src='"+blameMarker.AuthorImage+"'>"+
+ "</div>";
+
annotation.groupId = blameMarker.Name;
+ annotation.blameMarker = blameMarker;
annotation.groupType = AT.ANNOTATION_CURRENT_BLAME;
annotation.createGroupAnnotation = createGroup;
return annotation;