Module: Ramaze::Helper::Gravatar

### Home Classes Methods

### In Files

- lib/ramaze/helper/gravatar.rb

### Methods

- #gravatar

### Files

- Gemfile
- Rakefile

### Class/Module Index

Quicksearch

- Ramaze
- Ramaze::App
- Ramaze::Bin
- Ramaze::Bin::Create
- Ramaze::Bin::Runner
- Ramaze::Cache
- Ramaze::Cache::LRU
- Ramaze::Cache::LocalMemCache
- Ramaze::Cache::MemCache
- Ramaze::Cache::Redis
- Ramaze::Cache::Sequel
- Ramaze::Controller
- Ramaze::CoreExtensions
- Ramaze::CoreExtensions::Object
- Ramaze::CoreExtensions::String
- Ramaze::Current
- Ramaze::DefaultController
- Ramaze::Files
- Ramaze::Gestalt
- Ramaze::Helper
- Ramaze::Helper::Auth
- Ramaze::Helper::Bench
- Ramaze::Helper::BlueForm
- Ramaze::Helper::BlueForm::Form
- Ramaze::Helper::CSRF
- Ramaze::Helper::Cache
- Ramaze::Helper::Cache::SingletonMethods
- Ramaze::Helper::Email
- Ramaze::Helper::Erector
- Ramaze::Helper::Flash
- Ramaze::Helper::Formatting
- Ramaze::Helper::Gestalt
- Ramaze::Helper::Gravatar
- Ramaze::Helper::Identity
- Ramaze::Helper::Layout
- Ramaze::Helper::Layout::SingletonMethods
- Ramaze::Helper::Link
- Ramaze::Helper::Localize
- Ramaze::Helper::Localize::Dictionary
- Ramaze::Helper::Localize::Parser
- Ramaze::Helper::Markaby
- Ramaze::Helper::Maruku
- Ramaze::Helper::Paginate
- Ramaze::Helper::Paginate::Paginator
- Ramaze::Helper::Paginate::Paginator::ArrayPager
- Ramaze::Helper::Paginate::Paginator::DataMapperPager
- Ramaze::Helper::Remarkably
- Ramaze::Helper::RequestAccessor
- Ramaze::Helper::SendFile
- Ramaze::Helper::SimpleCaptcha
- Ramaze::Helper::Stack
- Ramaze::Helper::Thread
- Ramaze::Helper::Upload
- Ramaze::Helper::Upload::ClassMethods
- Ramaze::Helper::Upload::UploadedFile
- Ramaze::Helper::UserHelper
- Ramaze::Helper::UserHelper::Wrapper
- Ramaze::Helper::XHTML
- Ramaze::LRUHash
- Ramaze::Logger
- Ramaze::Logger::Informer
- Ramaze::Logger::LogHub
- Ramaze::Logger::Logger
- Ramaze::Logger::RotatingInformer
- Ramaze::Logger::Syslog
- Ramaze::Logging
- Ramaze::Reloader
- Ramaze::Reloader::Hooks
- Ramaze::Reloader::WatchInotify
- Ramaze::Reloader::WatchStat
- Ramaze::Request
- Ramaze::Response
- Ramaze::SpecLogger
- Ramaze::View
- Ramaze::View::Erector
- Ramaze::View::Erubis
- Ramaze::View::Ezamar
- Ramaze::View::Gestalt
- Ramaze::View::Haml
- Ramaze::View::Liquid
- Ramaze::View::Liquid::Tag
- Ramaze::View::Lokar
- Ramaze::View::Mustache
- Ramaze::View::Mustache::RamazeContext
- Ramaze::View::Nagoro
- Ramaze::View::Remarkably
- Ramaze::View::Sass
- Ramaze::View::Slippers
- Ramaze::View::Tagz
- Ramaze::View::Tagz::Methods
- Ramaze::View::Tenjin
- Innate
- Innate::View
- Innate::View::Slim
- Nagoro
- Nagoro::Pipe
- Nagoro::Pipe::RenderPartial
- Bacon
- Bacon::PrettyOutput
- Erector
- Erector::Widget
- Rack
- Rack::RouteExceptions
- Tenjin
- Tenjin::Template
- BlankSlate
- Controller
- MainController
- Object

No matching classes.

# Ramaze::Helper::Gravatar

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.

### Public Instance Methods

gravatar(email, opts = {}) click to toggle source

API to build gravatar URIs from an email address (or any other String).

@example Simple usage

    class Gravatars < Ramaze::Controller
      helper :gravatar

      def index
        %q(
        Input your email address and I'll show you your Gravatar
        <form>
          <input type="text" name="email" />
          <input type="submit" />
        </form>
        <?r if email = request[:email] ?>
          Your gravatar is:
          <img src="#{gravatar(email)}" />
        <?r end ?>
        )
      end
    end

@option opts [to_s] :ext (nil)

    append a filename extension for the image, like '.jpg'

@option opts [to_i] :size (80)

    The size of the gravatar, square, so 80 is 80x80.
    Allowed range is from 1 to 512.

@option opts [to_s] :rating ('g')

    Only serve a gravatar if it has a content rating equal or below the
    one specified. Ratings, in order are: 'g', 'pg', 'r', or 'x'

@option opts [to_s] :default (nil)

    Fall back to default if the given +email+ doesn't have an gravatar;
    may be an absolute url, 'identicon', 'monsterid', or 'wavatar'

@option opts [true, false] :force (false)

    Force use of the default avatar, useful if you want to use only
    identicons or the like

@param [to_str] email @return [URI] @see en.gravatar.com/site/implement/url @author manveru

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.