diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 62685ec..d8dfb89 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -609,6 +609,10 @@ module ApplicationHelper url end + def gravatar_profile_url(email) + 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email) + end + attr_reader :environment def select_categories(object_name, title=nil, title_size=4) return nil if environment.enabled?(:disable_categories) diff --git a/app/views/content_viewer/_comment.rhtml b/app/views/content_viewer/_comment.rhtml index 22d8d10..1a9d895 100644 --- a/app/views/content_viewer/_comment.rhtml +++ b/app/views/content_viewer/_comment.rhtml @@ -11,14 +11,21 @@ :title => comment.author_name %> <% else %> - <%# unauthenticated user: display gravatar icon %> - <% 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'] %> - <%= content_tag 'span', image_tag(url_image) + - content_tag('span', comment.author_name, :class => 'comment-info') + - content_tag('span', comment.message, :class => 'comment-user-status ' + status_class), + <% url_image, status_class = comment.author_id ? + [comment.removed_user_image, 'icon-user-removed'] : + [str_gravatar_url_for( comment.email, :size => 50, :d=>404 ), 'icon-user-unknown'] %> + + <%= link_to( + image_tag(url_image, :onerror=>'gravatarCommentFailback(this)', + 'data-gravatar'=>str_gravatar_url_for(comment.email, :size=>50)) + + content_tag('span', comment.author_name, :class => 'comment-info') + + content_tag('span', comment.message, + :class => 'comment-user-status ' + status_class), + gravatar_profile_url(comment.email), + :target => '_blank', :class => 'comment-picture', :title => '%s %s' % [comment.author_name, comment.message] - %> + )%> <% end %> <% comment_balloon do %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a134af2..871d53d 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -681,6 +681,12 @@ function original_image_dimensions(src) { return { 'width' : img.width, 'height' : img.height }; } +function gravatarCommentFailback(img) { + var link = img.parentNode; + link.href = "http://www.gravatar.com"; + img.src = img.getAttribute("data-gravatar"); +} + jQuery(function() { jQuery("#ajax-form").before("
"); jQuery("#ajax-form").before(""); -- libgit2 0.21.2