public
Fork of stevenbristol/lovd-by-less
Description: Open Source Social Network written in Ruby on Rail by Less Everything
Homepage: http://lovdbyless.com
Clone URL: git://github.com/tomlion/lovd-by-less.git
updated to use avatar gem version 0.0.5; added asset_host settings for 
RailsAssetSourceWrapper
gcnovus (author)
Tue Apr 01 12:42:20 -0700 2008
commit  c9d282a9c55f36cbe319d549f744e22aa0ffc1bc
tree    581fc9ec0f1966c41927264172afae1144bb5e58
parent  48d98e90fe462e6ea49b7a371e1a8edc6ce0c67a
...
1
2
 
3
4
5
6
7
 
8
9
10
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,9 +1,11 @@
0
 .DS_Store
0
 db/*.db
0
+db/schema.rb
0
 log/*.log
0
 tmp
0
 config/database.yml
0
 index
0
 public/system
0
+public/javascripts/less_routes.js
0
 test/public/system
0
 vendor/rails
0
\ No newline at end of file
0
...
42
43
44
45
 
46
47
48
...
42
43
44
 
45
46
47
48
0
@@ -42,7 +42,7 @@ Install the Required Gems:
0
 - acts_as_ferret
0
 - ferret
0
 - win32console (windows only)
0
-- avatar
0
+- avatar (version 0.0.5 or greater)
0
 
0
 TIP:
0
 Installing ferret on Windows
...
5
6
7
8
9
 
 
10
11
12
13
14
15
16
17
18
19
20
21
22
...
5
6
7
 
 
8
9
10
11
12
13
14
15
 
 
 
 
 
 
16
0
@@ -5,18 +5,12 @@ module ProfilesHelper
0
   
0
   def icon profile, size = :small, img_opts = {}
0
     return "" if profile.nil?
0
- img_opts = img_opts.merge(:title => profile.full_name, :alt => profile.full_name, :class => size).merge(img_opts)
0
- link_to(avatar_tag(profile, {:size => size, :file_column_version => size, :default => default_image_url(size)}, img_opts))
0
+ img_opts = {:title => profile.full_name, :alt => profile.full_name, :class => size}.merge(img_opts)
0
+ link_to(avatar_tag(profile, {:size => size, :file_column_version => size }, img_opts))
0
   end
0
   
0
   def location_link profile = @p
0
     return profile.location if profile.location == Profile::NOWHERE
0
     link_to h(profile.location), search_profiles_path.add_param('search[location]' => profile.location)
0
   end
0
-
0
- private
0
- def default_image_url(size)
0
- req = controller.request
0
- "#{req.protocol}#{req.host_with_port}#{image_path("/images/avatar_default_#{size}.png")}"
0
- end
0
 end
...
13
14
15
 
16
17
18
...
13
14
15
16
17
18
19
0
@@ -13,6 +13,7 @@ config.action_controller.consider_all_requests_local = true
0
 config.action_controller.perform_caching = false
0
 config.action_view.cache_template_extensions = false
0
 config.action_view.debug_rjs = true
0
+config.action_controller.asset_host = "http://localhost:3000"
0
 
0
 # Don't care if the mailer can't send
0
 config.action_mailer.raise_delivery_errors = true
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@ config.cache_classes = true
0
 # Full error reports are disabled and caching is turned on
0
 config.action_controller.consider_all_requests_local = false
0
 config.action_controller.perform_caching = true
0
-#config.action_controller.asset_host = "http://assets%d.yoursite.com"
0
+config.action_controller.asset_host = "http://assets%d.yoursite.com"
0
 
0
 # Disable delivery errors, bad email addresses will be ignored
0
 # config.action_mailer.raise_delivery_errors = false
...
14
15
16
 
17
18
19
...
14
15
16
17
18
19
20
0
@@ -14,6 +14,7 @@ config.whiny_nils = true
0
 # Show full error reports and disable caching
0
 config.action_controller.consider_all_requests_local = true
0
 config.action_controller.perform_caching = false
0
+config.action_controller.asset_host = "http://test.host"
0
 
0
 # Tell ActionMailer not to deliver emails to the real world.
0
 # The :test delivery method accumulates sent emails in the
...
 
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
...
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
30
31
0
@@ -1,26 +1,31 @@
0
+gem 'avatar', '>= 0.0.5'
0
 require 'avatar'
0
 require 'avatar/source/file_column_source'
0
 require 'avatar/source/source_chain'
0
-require 'avatar/source/string_substitution_source'
0
+require 'avatar/source/static_url_source'
0
+require 'avatar/source/wrapper/rails_asset_source_wrapper'
0
+require 'avatar/source/wrapper/string_substitution_source_wrapper'
0
 require 'sized_gravatar_source'
0
 
0
 # order:
0
-# 1. FileColumn(Profile.icon)
0
-# 2. Gravatar(nil_source, Profile.email)
0
+# 1. FileColumn(Profile#icon)
0
+# 2. Gravatar(Profile#email), with default
0
+# a RailsAssetSourceWrapper containing
0
+# a StringSubstitutionSourceWrapper containing
0
+# a StaticUrlSource ('/images/avatar_default_#{size}.png')
0
 #
0
-# Gravatar accepts a default if no gravatar exists for the
0
-# email address passed. Unfortunately, it needs to be
0
-# a full URL (not just a path relative to the request).
0
-# Thus, this won't work:
0
-# gravatar.default_source = Avatar::Source::StringSubstitutionSource.new('/images/avatar_default_#{size}.png')
0
-# Instead, we have to pass in a default in the avatar_url_for
0
-# call in app/helpers/profiles_helper
0
-#
0
-# Additionally, Gravatar does not understand :small, :medium, and :big,
0
+# Gravatar does not understand :small, :medium, and :big,
0
 # so we must translate using SizedGravatarSource
0
 
0
+default = Avatar::Source::Wrapper::RailsAssetSourceWrapper.new(
0
+ Avatar::Source::Wrapper::StringSubstitutionSourceWrapper.new(
0
+ Avatar::Source::StaticUrlSource.new('/images/avatar_default_#{size}.png'),
0
+ {:size => :small}
0
+ )
0
+)
0
+
0
 chain = Avatar::Source::SourceChain.new
0
 chain << Avatar::Source::FileColumnSource.new(:icon)
0
-chain << SizedGravatarSource.new(nil, :email)
0
+chain << SizedGravatarSource.new(default, :email)
0
 
0
 Avatar::source = chain
...
9
10
11
12
13
 
 
 
 
 
 
14
15
16
17
...
9
10
11
 
 
12
13
14
15
16
17
18
19
20
21
0
@@ -9,8 +9,12 @@ class SizedGravatarSource < Avatar::Source::GravatarSource
0
   end
0
   
0
   def parse_options(profile, options)
0
- options[:size] = self.class.sizes[options[:size]] if self.class.sizes.has_key?(options[:size])
0
- parse_options_without_size(profile, options)
0
+ #pass :gravatar_size through, but translate :size or :s to a number if possible
0
+ parsed_options = parse_options_without_size(profile, options)
0
+ [:size, :s].each do |k|
0
+ parsed_options[k] = self.class.sizes[options[k]] if self.class.sizes.has_key?(options[k])
0
+ end
0
+ parsed_options
0
   end
0
   
0
 end
0
\ No newline at end of file
...
137
138
139
140
 
141
142
143
...
137
138
139
 
140
141
142
143
0
@@ -137,7 +137,7 @@ class ProfilesControllerTest < ActionController::TestCase
0
       p = profiles(:user2)
0
       assert_nil p.icon
0
       get :show, {:id => p.id}, {:user => p.id, :public_view => true}
0
- assert_tag :img, :attributes => {:src => /www\.gravatar\.com.*default=http:\/\/test.host\/images\/avatar_default_.*\.png/}
0
+ assert_tag :img, :attributes => { :src => /http...www.gravatar.com\/avatar\/[0-9a-f]+\?size\=50&amp;default\=http...test\.host\/images\/avatar_default_small\.png/ }
0
     end
0
   end
0
 

Comments

    No one has commented yet.