1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  def avatar_for(user, link = false, size = "64x64", options_for_link = {})
    buddy_icon = buddy_icon_for(user, size)

    if featured?(user)
      featured(size) do |badge|
        (link) ? link_to_profile(user, options_for_link) { badge + buddy_icon } : badge + buddy_icon
      end
    else
      (link) ? link_to_profile(user, options_for_link) { buddy_icon } : buddy_icon
    end
  end

  def buddy_icon_for(user, size="64x64")
    image_tag user.buddy_icon, :class => "photo", :size => size, :alt => :icon
  end
  
  def featured(size = "64x64")
    width, height = size.split(/x/)
    output = ""
    #output << %q{<div class="featuredv featured-avatarv">}
    output << %Q{<div class="featured-avatar" style="width: #{width}px; height: #{height}px; border: 1px solid green !important;">}
    output << yield(%q{<img class="featured-swash" src="/img/featured-swash.gif" alt="Featured" />})
    output << %q{</div>}
  end
  
  def link_to_profile(user, options = {})
    result = yield
    link_to result, profile_url(:screen_name => user.screen_name), options
  end