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 320  
321 321 }(this);
322 322 Raphael.fn.commitTooltip = function(x, y, commit){
323   - var nameText, idText, messageText
  323 + var icon, nameText, idText, messageText
324 324 , boxWidth = 300
325 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 329 idText = this.text(x, y + 35, commit.id);
329 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 333 "text-anchor": "start",
333 334 "font": "12px Monaco, monospace"
334 335 });
... ...
app/controllers/graph_controller.rb
1 1 class GraphController < ProjectResourceController
2 2 include ExtractsPath
  3 + include ApplicationHelper
3 4  
4 5 # Authorize
5 6 before_filter :authorize_read_project!
... ... @@ -21,6 +22,9 @@ class GraphController &lt; ProjectResourceController
21 22 format.html
22 23 format.json do
23 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 28 render :json => graph.to_json
25 29 end
26 30 end
... ...
app/models/graph/commit.rb
... ... @@ -4,7 +4,7 @@ module Graph
4 4 class Commit
5 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 9 def initialize(commit)
10 10 @_commit = commit
... ... @@ -23,8 +23,9 @@ module Graph
23 23 [p.id,0,0]
24 24 end
25 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 30 h[:time] = time
30 31 h[:space] = spaces.first
... ...