Sha256: 84015ff7e5cda45366cd5f37eb07881c709983cbb512b9cfeb48947b17c693a8

Contents?: true

Size: 804 Bytes

Versions: 7

Compression:

Stored size: 804 Bytes

Contents

#= require md5

# Private abbreviations
abbreviations =
  size:    's'
  default: 'd'
  rating:  'r'

window.Gravtastic = (email, options={}) ->
  id = MD5(email.toString().toLowerCase())

  # Initialize options
  opts = {}
  opts[key] = val for key, val of Gravtastic.defaults
  opts[key] = val for key, val of options

  host = if opts.secure
           "https://secure.gravatar.com/avatar"
         else
           "http://gravatar.com/avatar"

  path = "/#{id}.#{opts.filetype || 'png'}"

  params = "?" + (
    for key, val of opts when key isnt "secure" and key isnt "filetype"
      "#{abbreviations[key] || key}=#{val}"
  ).join('&')

  host + path + params


# These are easily overridden in your own application
window.Gravtastic.defaults =
  rating:   'PG'
  secure:   true
  filetype: 'png'

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
leifcr-gravtastic-3.2.7 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.6 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.5 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.4 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.2 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.1 vendor/assets/javascripts/gravtastic.coffee
gravtastic-3.2.0 vendor/assets/javascripts/gravtastic.coffee