<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>config/initializers/avatar_sources.rb</filename>
    </added>
    <added>
      <filename>config/initializers/file_column_settings.rb</filename>
    </added>
    <added>
      <filename>lib/sized_gravatar_source.rb</filename>
    </added>
    <added>
      <filename>test/public/images/user.png</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -43,6 +43,7 @@ Install the Required Gems:
 - acts_as_ferret
 - ferret
 - win32console (windows only)
+- avatar
 
 TIP:
 Installing ferret on Windows</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,41 @@
 module PhotosHelper
   
-  
-  
-  def image photo, size = :square, img_opts = {}
-    return image_tag(image_path( photo, size), :class =&gt; size) if photo.image.blank?
-    img_tag = image_tag(image_path( photo, size), {:title=&gt;photo.caption, :alt=&gt;photo.caption, :class=&gt;size}.merge(img_opts))
-    img_tag
+  def self.included(base)
+    #this gets auto-included, but only later, so do it now:
+    base.send :include, ActionView::Helpers::AssetTagHelper
+    
+    #replace image_path with a version that understands stored photos:
+    unless base.method_defined?(:image_path_without_photo)
+      base.send :alias_method, :image_path_without_photo, :image_path
+    end
+    base.send :include, PhotosHelper::InstanceMethods
   end
   
+  module InstanceMethods
+    def image photo, size = :square, img_opts = {}
+      return image_tag(image_path( photo, size), :class =&gt; size) if photo.image.blank?
+      img_tag = image_tag(image_path( photo, size), {:title=&gt;photo.caption, :alt=&gt;photo.caption, :class=&gt;size}.merge(img_opts))
+      img_tag
+    end
   
+    def photo_path photo, size
+      return &quot;/images/missing_#{size}.png&quot; if photo.image.blank?
+      if size
+        path = url_for_image_column(photo, :image, size) rescue path = &quot;/images/missing_#{size}.png&quot;
+        # QUESTION: Is there a way to do a file column return on a fixture and return a
+        # fake path when the actual path DNE?  Returns nil if file missing
+        path = &quot;/images/missing_#{size}.png&quot; if path.nil?
+      else
+        path = url_for_file_column(photo, :image) rescue path = &quot;/images/missing_.png&quot;
+        # QUESTION: Is there a way to do a file column return on a fixture and return a
+        # fake path when the actual path DNE?  Returns nil if file missing
+        path = &quot;/images/missing_.png&quot; if path.nil? 
+      end
+      return path
+    end
   
-  def image_path photo = nil, size = :square
-    return &quot;/images/missing_#{size}.png&quot; if photo.image.blank?
-    if size
-      path = url_for_image_column(photo, :image, size) rescue path = &quot;/images/missing_#{size}.png&quot;
-      # QUESTION: Is there a way to do a file column return on a fixture and return a
-      # fake path when the actual path DNE?  Returns nil if file missing
-      path = &quot;/images/missing_#{size}.png&quot; if path.nil?
-    else
-      path = url_for_file_column(photo, :image) rescue path = &quot;/images/missing_.png&quot;
-      # QUESTION: Is there a way to do a file column return on a fixture and return a
-      # fake path when the actual path DNE?  Returns nil if file missing
-      path = &quot;/images/missing_.png&quot; if path.nil? 
+    def image_path(source_or_photo, size = :square)
+      source_or_photo.respond_to?(:image) ? photo_path(source_or_photo, size) : image_path_without_photo(source_or_photo)
     end
-    return path
   end
-
-
-end
+end
\ No newline at end of file</diff>
      <filename>app/helpers/photos_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,22 @@
+require 'avatar/view/action_view_support'
+
 module ProfilesHelper
+  include Avatar::View::ActionViewSupport
   
   def icon profile, size = :small, img_opts = {}
-    return link_to(image_tag(icon_path( profile, size), {:title=&gt;profile.full_name, :alt=&gt;profile.full_name, :class=&gt;size}.merge(img_opts)), profile_path(profile)) if profile.icon.blank?
-    link_to(image_tag(icon_path( profile, size), {:title=&gt;profile.full_name, :alt=&gt;profile.full_name, :class=&gt;size}.merge(img_opts)), profile_path(profile)) rescue ''
-  end
-  
-  
-  
-  def icon_path profile = nil, size = :small
-    return &quot;/images/avatar_default_#{size}.png&quot; if profile.icon.blank?
-    url_for_image_column(profile, :icon, size) rescue &quot;/images/avatar_default_#{size}.png&quot;
+    return &quot;&quot; if profile.nil?
+    img_opts = img_opts.merge(:title =&gt; profile.full_name, :alt =&gt; profile.full_name, :class =&gt; size).merge(img_opts)
+    link_to(avatar_tag(profile, {:size =&gt; size, :file_column_version =&gt; size, :default =&gt; default_image_url(size)}, img_opts))
   end
   
   def location_link profile = @p
     return profile.location if profile.location == Profile::NOWHERE
     link_to h(profile.location), search_profiles_path.add_param('search[location]' =&gt; profile.location)
   end
+  
+  private
+  def default_image_url(size)
+    req = controller.request
+    &quot;#{req.protocol}#{req.host_with_port}#{image_path(&quot;/images/avatar_default_#{size}.png&quot;)}&quot;
+  end
 end</diff>
      <filename>app/helpers/profiles_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,9 +24,8 @@ class Photo &lt; ActiveRecord::Base
     feed_item = FeedItem.create(:item =&gt; self)
     ([profile] + profile.friends + profile.followers).each{ |p| p.feed_items &lt;&lt; feed_item }
   end
-  
-  
-  file_column :image, :root_path =&gt; File.join(RAILS_ROOT, &quot;public/system&quot;), :web_root =&gt; 'system/', :magick =&gt; {
+
+  file_column :image, :magick =&gt; {
     :versions =&gt; { 
       :square =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;50x50&quot;, :name =&gt; &quot;square&quot;},
       :small =&gt; &quot;175x250&gt;&quot;</diff>
      <filename>app/models/photo.rb</filename>
    </modified>
    <modified>
      <diff>@@ -68,11 +68,11 @@ class Profile &lt; ActiveRecord::Base
   
   acts_as_ferret :fields =&gt; [ :location, :f, :about_me ], :remote=&gt;true
   
-  file_column :icon, :root_path =&gt; File.join(RAILS_ROOT, &quot;public/system&quot;), :web_root =&gt; 'system/', :magick =&gt; {
+  file_column :icon, :magick =&gt; {
     :versions =&gt; { 
-    :big =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;150x150&quot;, :name =&gt; &quot;big&quot;},
-    :medium =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;100x100&quot;, :name =&gt; &quot;medium&quot;},
-    :small =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;50x50&quot;, :name =&gt; &quot;small&quot;}
+      :big =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;150x150&quot;, :name =&gt; &quot;big&quot;},
+      :medium =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;100x100&quot;, :name =&gt; &quot;medium&quot;},
+      :small =&gt; {:crop =&gt; &quot;1:1&quot;, :size =&gt; &quot;50x50&quot;, :name =&gt; &quot;small&quot;}
     }
   }
   </diff>
      <filename>app/models/profile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@ namespace :gems do
           imagick
           acts_as_ferret
           ferret
+          avatar
         ]
       gems &lt;&lt; 'win32console' if windoz
       sudo = windoz ? '' : 'sudo '</diff>
      <filename>lib/tasks/getting_started.rake</filename>
    </modified>
    <modified>
      <diff>@@ -25,13 +25,14 @@
 #
 
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
 user:
     user: user
     first_name: De
     last_name: Veloper
     email: user@example.com
     is_active: true
-    icon: Photo_2.jpg
+    icon: user.png
 
 user2:
     user: user2</diff>
      <filename>test/fixtures/profiles.yml</filename>
    </modified>
    <modified>
      <diff>@@ -112,6 +112,33 @@ class ProfilesControllerTest &lt; ActionController::TestCase
     should_render_template :edit
     should_render_a_form
     should_not_set_the_flash
+  end  
+  
+  context 'rendering an avatar' do
+    
+    should 'use the user\'s icon if it exists' do
+      p =  profiles(:user)
+      p.icon = File.new(File.join(RAILS_ROOT, ['test', 'public','images','user.png']))
+      p.save!
+      #raise (p.send :icon_state).inspect
+      assert_not_nil p.icon
+      get :show, {:id =&gt; p.id, :public_view =&gt; true}, {:user =&gt; p.id}
+      assert_tag :img, :attributes =&gt; { :src =&gt; /\/system\/profile\/icon\/\d*\/big\/user.png/ }
+    end
+    
+    should 'use gravatar otherwise' do
+      p =  profiles(:user2)
+      assert_nil p.icon
+      get :show, {:id =&gt; p.id}, {:user =&gt; p.id, :public_view =&gt; true}
+      assert_tag :img, :attributes =&gt; {:src =&gt; /www\.gravatar\.com/}
+    end
+    
+    should 'send the app\'s internal default as the default to gravatar' do
+      p =  profiles(:user2)
+      assert_nil p.icon
+      get :show, {:id =&gt; p.id}, {:user =&gt; p.id, :public_view =&gt; true}
+      assert_tag :img, :attributes =&gt; {:src =&gt; /www\.gravatar\.com.*default=http:\/\/test.host\/images\/avatar_default_.*\.png/}
+    end
   end
 
 </diff>
      <filename>test/functional/profiles_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,10 @@ require 'redgreen' unless ENV['TM_MODE']
 require 'ostruct'
 require 'mocha'
 
+# for testing uploaded files
+# place any &quot;already uploaded&quot; files in a subdirectory within /test/ instead of overwriting production files.
+FileColumn::ClassMethods::DEFAULT_OPTIONS[:root_path] = File.join(RAILS_ROOT, 'test', &quot;public&quot;, 'system')
+
 class Test::Unit::TestCase
   # Transactional fixtures accelerate your tests by wrapping each test method
   # in a transaction that's rolled back on completion.  This ensures that the
@@ -117,6 +121,5 @@ class Test::Unit::TestCase
   
   # Teardown and setup - for quick recycling of env. within a single test
   def recycle; teardown; setup; end
-  
 
 end</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>43a952709363ad42ac98563927b5ac41a0a9ae2c</id>
    </parent>
  </parents>
  <author>
    <name>James Rosen</name>
    <email>james@u-presence.com</email>
  </author>
  <url>http://github.com/janx/lovd-by-less/commit/6babefa22ed9b9eb77a997b4dd4c4a2912ed06f5</url>
  <id>6babefa22ed9b9eb77a997b4dd4c4a2912ed06f5</id>
  <committed-date>2008-03-25T22:34:24-07:00</committed-date>
  <authored-date>2008-03-25T22:34:24-07:00</authored-date>
  <message>added Gravatar support through avatar gem</message>
  <tree>c04612bd986ee04e6e82d89dcfc88645cc52fde5</tree>
  <committer>
    <name>James Rosen</name>
    <email>james@u-presence.com</email>
  </committer>
</commit>
