-
-
Save jimmybaker/268809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment | |
include MongoMapper::EmbeddedDocument | |
include Gravatarable | |
key :name, String | |
key :email, String | |
key :url, String | |
key :body, String | |
key :created_at, Time | |
def post | |
_root_document | |
end | |
def to_liquid | |
CommentDrop.new(self) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/md5' | |
module Gravatarable | |
# override this in your class if email key is not named email | |
def gravatar_email | |
email.downcase | |
end | |
def gravatar_id | |
Digest::MD5.hexdigest(gravatar_email) | |
end | |
def gravatar(size=50, default=nil) | |
url = "http://www.gravatar.com/avatar/#{gravatar_id}?s=#{size}" | |
url += "&d=#{default}" if default | |
url | |
end | |
def gravatarable? | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment