diff options
author | Philip Arndt <parndt@gmail.com> | 2011-05-27 23:41:50 +1200 |
---|---|---|
committer | Philip Arndt <parndt@gmail.com> | 2011-05-27 23:41:56 +1200 |
commit | ff795b2ab0040b5846960aeed238d9cd749cdad0 (patch) | |
tree | 001af6dfa945fd5e019ea277b40000a7015d4271 | |
parent | 92e128d2fbd049c62389598a6c97e6ffd400e2e9 (diff) | |
download | refinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.tar.gz refinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.tar.bz2 refinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.zip |
Added avatar to blog comments based on email address associated with a gravatar.
-rw-r--r-- | app/models/blog_comment.rb | 7 | ||||
-rw-r--r-- | app/views/blog/posts/_comment.html.erb | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 13aceb1..f461cdb 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -19,6 +19,13 @@ class BlogComment < ActiveRecord::Base scope :approved, :conditions => {:state => 'approved'} scope :rejected, :conditions => {:state => 'rejected'} + def avatar_url(options = {}) + options = {:size => 60} + require 'digest/md5' + options[:size] = "?s=#{size}" if options[:size] + "http://gravatar.com/avatar/#{Digest::MD5.hexdigest(self.email.to_s.strip.downcase)}#{size}.jpg" + end + def approve! self.update_attribute(:state, 'approved') end diff --git a/app/views/blog/posts/_comment.html.erb b/app/views/blog/posts/_comment.html.erb index ba4a508..17b2002 100644 --- a/app/views/blog/posts/_comment.html.erb +++ b/app/views/blog/posts/_comment.html.erb @@ -1,4 +1,5 @@ <article class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'> + <%= image_tag comment.avatar_url, :alt => comment.name, :class => 'avatar' %> <%= simple_format auto_link(comment.message.to_s) %> <footer class='blog_comment_author'> <p> |