README.md in gravatarify-1.0.0 vs README.md in gravatarify-1.1.0

- old
+ new

@@ -2,15 +2,15 @@ Removes any hassles building those pesky gravatar urls, it's not there arent any alternatives [out](http://github.com/mdeering/gravitar_image_tag), [there](http://github.com/chrislloyd/gravtastic), but none seem to support stuff like `Proc`s for the default picture url, or the multiple host names supported by gravatar.com (great when displaying lots of avatars). -And it integrates seamlessly with Rails, Merb and even plain old Ruby. +And it integrates seamlessly with Rails, DataMapper and even plain old Ruby. -- **Source**: [http://github.com/lwe/gravatarify](http://github.com/lwe/gravatarify) -- **Docs**: [http://rdoc.info/projects/lwe/gravatarify](http://rdoc.info/projects/lwe/gravatarify) -- **Gem**: [http://gemcutter.org/gems/gravatarify](http://gemcutter.org/gems/gravatarify) +- **Source**: <http://github.com/lwe/gravatarify> +- **Docs**: <http://rdoc.info/projects/lwe/gravatarify> +- **Gem**: <http://gemcutter.org/gems/gravatarify> ## Install Just install the gem (ensure you have gemcutter in your sources!) @@ -29,17 +29,16 @@ # Usage This library provides... - * ...object/model helpers, so that an object responds to `gravatar_url`, see [using the model helpers](#l_model_helpers). + * ...object/model helpers, so that an object responds to `gravatar_url`, see "Using the model helpers" Works also very well with plain old ruby objects. - * ...Rails view helpers, namely `gravatar_url` and `gravatar_tag`, see [using the view helpers](#l_view_helpers). This is rails only though! + * ...Rails view helpers, namely `gravatar_url` and `gravatar_tag`, see "Using the view helpers". This is rails only though! * ...and finally, a base module which provides the gravatar url generation, ready to be integrated into - custom helpers, plain ruby code or whatever, see [back to the roots](#l_roots) + custom helpers, plain ruby code or whatever, see "Back to the roots". -<a id="l_view_helpers"/> ## Using the view helpers (Rails only!) Probably one of the easiest ways to add support for gravatar images is with the included view helpers: <%= gravatar_tag @user %> # assumes @user has email or mail field! @@ -56,11 +55,10 @@ Using rails `image_tag` to create an `<img/>`-tag with `gravatar_url`. It's important to know that also an object can be passed to `gravatar_url`, if it responds to either `email` or `mail`. If not (like in the example above), the email address must be passed in. -<a id="l_model_helpers"/> ## Using the model helpers A very simple method to add `gravatar_url` support to models is by using the `gravatarify` class method. class User < ActiveRecord::Base @@ -106,11 +104,10 @@ end Tadaaa! Works exactly like the model helpers, so it's now possible to call `gravatar_url` on instances of `PoroUser`. -<a id="l_roots"/> ## Back to the roots? No need for sophisticated stuff like view helpers and ActiveRecord integration, want to go back to the roots? Then feel free to use `Gravatarify::Base#build_gravatar_url` directly. @@ -185,11 +182,16 @@ @user.gravatar_url # => "http://0.gravatar.com/...jpg?d=http%3A%2F%2Fexample.com%2Fgravatar-80.jpg" @user.gravatar_url(:size => 16) # => "http://0.gravatar.com/...jpg?d=http%3A%2F%2Fexample.com%2Fgravatar-16.jpg&s=16" -Into the block is passed the options hash and as second parameter the object itself, so in the example above -`object` would be `@user`, might be useful!? Never used it, so I might remove the second argument... +Into the block is passed the options hash and as second parameter the object itself, so it's possible to do stuff like + + # doing stuff like showing default avatar based on gender... + @user = User.new(:gender => :female, :email => 'bella@gmail.com') # => @user.female? = true + + @user.gravatar_url :default => Proc.new { |opts, obj| "http://example.com/avatar#{obj.respond_to?(:female) && obj.female? ? '_female' : ''}.jpg" } + # => http://0.gravatar.com/...jpg?d=http%3A%2F%2Fexample.com%2Fgravatar_female.jpg Not only the `:default` option accepts a Proc, but also `:secure`, can be useful to handle cases where it should evaluate against `request.ssl?` for example. ## About the code \ No newline at end of file