Sha256: ad70624548830547649797dde649d77426f87ac7b3f185f58f03004d5aa70dd3

Contents?: true

Size: 603 Bytes

Versions: 11

Compression:

Stored size: 603 Bytes

Contents

module Trestle
  module AvatarHelper
    def avatar(options={})
      fallback = options.delete(:fallback) if options[:fallback]

      content_tag(:div, options.reverse_merge(class: "avatar")) do
        concat content_tag(:span, fallback, class: "avatar-fallback") if fallback
        concat yield if block_given?
      end
    end

    def gravatar(email, options={})
      options = { d: "mm" }.merge(options)

      url = "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s.downcase)}.png"
      url << "?#{options.to_query}" if options.any?

      image_tag(url)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
trestle-0.9.5 app/helpers/trestle/avatar_helper.rb
trestle-0.9.4 app/helpers/trestle/avatar_helper.rb
trestle-0.9.3 app/helpers/trestle/avatar_helper.rb
trestle-0.9.2 app/helpers/trestle/avatar_helper.rb
trestle-0.9.1 app/helpers/trestle/avatar_helper.rb
trestle-0.9.0 app/helpers/trestle/avatar_helper.rb
trestle-0.8.13 app/helpers/trestle/avatar_helper.rb
trestle-0.8.12 app/helpers/trestle/avatar_helper.rb
trestle-0.8.11 app/helpers/trestle/avatar_helper.rb
trestle-0.8.10 app/helpers/trestle/avatar_helper.rb
trestle-0.8.9 app/helpers/trestle/avatar_helper.rb