Module: Ramaze::Helper::Gravatar
- Defined in:
- lib/ramaze/helper/gravatar.rb
Overview
Helps you building Gravatar URIs from an email address.
For more information about gravatars, please see: gravatar.com
The implementation of the gravatar method changed significantly, it does less hand-holding but is more flexible so you can simply put your own helper on top.
It might not know about all the secret parameters (like ‘force’), if you find out more of these please consider contributing a patch.
Instance Method Summary collapse
-
#gravatar(email, opts = {}) ⇒ URI
API to build gravatar URIs from an email address (or any other String).
Instance Method Details
#gravatar(email, opts = {}) ⇒ URI
API to build gravatar URIs from an email address (or any other String).
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ramaze/helper/gravatar.rb', line 59 def gravatar(email, opts = {}) uri = URI("http://www.gravatar.com/") ext = opts[:ext] uri.path = "/avatar/#{Digest::MD5.hexdigest(email.to_str)}#{ext}" query = {} query[:size] = opts[:size].to_i.to_s if opts.key?(:size) query[:rating] = opts[:rating].to_s if opts.key?(:rating) query[:default] = opts[:default].to_s if opts.key?(:default) query[:force] = '1' if opts[:force] uri.query = Rack::Utils.build_query(query) if query.any? uri end |