Commit 892da9b5403deacddf21e728ad5fee063908ebfb
1 parent
fc7e02f2
Exists in
master
and in
28 other branches
Link to Gravatar home or prfile
closes ActionItem2125
Showing
3 changed files
with
23 additions
and
6 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -609,6 +609,10 @@ module ApplicationHelper |
| 609 | 609 | url |
| 610 | 610 | end |
| 611 | 611 | |
| 612 | + def gravatar_profile_url(email) | |
| 613 | + 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email) | |
| 614 | + end | |
| 615 | + | |
| 612 | 616 | attr_reader :environment |
| 613 | 617 | def select_categories(object_name, title=nil, title_size=4) |
| 614 | 618 | return nil if environment.enabled?(:disable_categories) | ... | ... |
app/views/content_viewer/_comment.rhtml
| ... | ... | @@ -11,14 +11,21 @@ |
| 11 | 11 | :title => comment.author_name |
| 12 | 12 | %> |
| 13 | 13 | <% else %> |
| 14 | - <%# unauthenticated user: display gravatar icon %> | |
| 15 | - <% url_image, status_class = comment.author_id ? [comment.removed_user_image, 'icon-user-removed'] : [str_gravatar_url_for( comment.email, :size => 50 ), 'icon-user-unknown'] %> | |
| 16 | - <%= content_tag 'span', image_tag(url_image) + | |
| 17 | - content_tag('span', comment.author_name, :class => 'comment-info') + | |
| 18 | - content_tag('span', comment.message, :class => 'comment-user-status ' + status_class), | |
| 14 | + <% url_image, status_class = comment.author_id ? | |
| 15 | + [comment.removed_user_image, 'icon-user-removed'] : | |
| 16 | + [str_gravatar_url_for( comment.email, :size => 50, :d=>404 ), 'icon-user-unknown'] %> | |
| 17 | + | |
| 18 | + <%= link_to( | |
| 19 | + image_tag(url_image, :onerror=>'gravatarCommentFailback(this)', | |
| 20 | + 'data-gravatar'=>str_gravatar_url_for(comment.email, :size=>50)) + | |
| 21 | + content_tag('span', comment.author_name, :class => 'comment-info') + | |
| 22 | + content_tag('span', comment.message, | |
| 23 | + :class => 'comment-user-status ' + status_class), | |
| 24 | + gravatar_profile_url(comment.email), | |
| 25 | + :target => '_blank', | |
| 19 | 26 | :class => 'comment-picture', |
| 20 | 27 | :title => '%s %s' % [comment.author_name, comment.message] |
| 21 | - %> | |
| 28 | + )%> | |
| 22 | 29 | <% end %> |
| 23 | 30 | |
| 24 | 31 | <% comment_balloon do %> | ... | ... |
public/javascripts/application.js
| ... | ... | @@ -681,6 +681,12 @@ function original_image_dimensions(src) { |
| 681 | 681 | return { 'width' : img.width, 'height' : img.height }; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | +function gravatarCommentFailback(img) { | |
| 685 | + var link = img.parentNode; | |
| 686 | + link.href = "http://www.gravatar.com"; | |
| 687 | + img.src = img.getAttribute("data-gravatar"); | |
| 688 | +} | |
| 689 | + | |
| 684 | 690 | jQuery(function() { |
| 685 | 691 | jQuery("#ajax-form").before("<div id='ajax-form-loading-area' style='display:block;width:16px;height:16px;'></div>"); |
| 686 | 692 | jQuery("#ajax-form").before("<div id='ajax-form-message-area'></div>"); | ... | ... |