Commit 2a687dd5625c29e48b7b64a388a828c358d45215

Authored by Sato Hiroyuki
1 parent 00d0e57e

Show gravatar icon on tooltip.

app/assets/javascripts/branch-graph.js
@@ -320,15 +320,16 @@ @@ -320,15 +320,16 @@
320 320
321 }(this); 321 }(this);
322 Raphael.fn.commitTooltip = function(x, y, commit){ 322 Raphael.fn.commitTooltip = function(x, y, commit){
323 - var nameText, idText, messageText 323 + var icon, nameText, idText, messageText
324 , boxWidth = 300 324 , boxWidth = 300
325 , boxHeight = 200; 325 , boxHeight = 200;
326 326
327 - nameText = this.text(x, y + 10, commit.author.name); 327 + icon = this.image(commit.author.icon, x, y, 20, 20);
  328 + nameText = this.text(x + 25, y + 10, commit.author.name);
328 idText = this.text(x, y + 35, commit.id); 329 idText = this.text(x, y + 35, commit.id);
329 messageText = this.text(x, y + 50, commit.message); 330 messageText = this.text(x, y + 50, commit.message);
330 331
331 - textSet = this.set(nameText, idText, messageText).attr({ 332 + textSet = this.set(icon, nameText, idText, messageText).attr({
332 "text-anchor": "start", 333 "text-anchor": "start",
333 "font": "12px Monaco, monospace" 334 "font": "12px Monaco, monospace"
334 }); 335 });
app/controllers/graph_controller.rb
1 class GraphController < ProjectResourceController 1 class GraphController < ProjectResourceController
2 include ExtractsPath 2 include ExtractsPath
  3 + include ApplicationHelper
3 4
4 # Authorize 5 # Authorize
5 before_filter :authorize_read_project! 6 before_filter :authorize_read_project!
@@ -21,6 +22,9 @@ class GraphController &lt; ProjectResourceController @@ -21,6 +22,9 @@ class GraphController &lt; ProjectResourceController
21 format.html 22 format.html
22 format.json do 23 format.json do
23 graph = Graph::JsonBuilder.new(project, @ref, @commit) 24 graph = Graph::JsonBuilder.new(project, @ref, @commit)
  25 + graph.commits.each do |c|
  26 + c.icon = gravatar_icon(c.author.email)
  27 + end
24 render :json => graph.to_json 28 render :json => graph.to_json
25 end 29 end
26 end 30 end
app/models/graph/commit.rb
@@ -4,7 +4,7 @@ module Graph @@ -4,7 +4,7 @@ module Graph
4 class Commit 4 class Commit
5 include ActionView::Helpers::TagHelper 5 include ActionView::Helpers::TagHelper
6 6
7 - attr_accessor :time, :spaces, :refs, :parent_spaces 7 + attr_accessor :time, :spaces, :refs, :parent_spaces, :icon
8 8
9 def initialize(commit) 9 def initialize(commit)
10 @_commit = commit 10 @_commit = commit
@@ -23,8 +23,9 @@ module Graph @@ -23,8 +23,9 @@ module Graph
23 [p.id,0,0] 23 [p.id,0,0]
24 end 24 end
25 h[:author] = { 25 h[:author] = {
26 - name: author.name,  
27 - email: author.email 26 + name: author.name,
  27 + email: author.email,
  28 + icon: icon
28 } 29 }
29 h[:time] = time 30 h[:time] = time
30 h[:space] = spaces.first 31 h[:space] = spaces.first