aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/users_helper.rb
diff options
context:
space:
mode:
authorMichel Etienne2015-01-09 16:11:33 +0100
committerMichel Etienne2015-01-09 16:11:33 +0100
commit83f9d8cf48fb832b43f0ea08d6ee53eef1be734a (patch)
tree68e44e3f377a67dbd607ff7de9d7be2558b205ae /app/helpers/users_helper.rb
parent913bc3b257a8e3066388a8f2260756e97756a225 (diff)
parentef4cc372d9dffe91354fb5ea5b44ef46a86677c4 (diff)
downloadchouette-core-83f9d8cf48fb832b43f0ea08d6ee53eef1be734a.tar.bz2
add tests for hub export
Diffstat (limited to 'app/helpers/users_helper.rb')
-rw-r--r--app/helpers/users_helper.rb26
1 files changed, 7 insertions, 19 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 0dfc1552f..ea5f41fb7 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -4,25 +4,13 @@ module UsersHelper
image_tag user_image(user), :alt => "", :class => "preview", :width => size, :height => size
end
- def gravatar_hash(user)
- Digest::MD5.hexdigest( user.email)
- end
- def gravatar_url( user)
- "http://www.gravatar.com/avatar/#{gravatar_hash(user)}?d=404"
- end
- def user_image(user)
- begin
- gravatar_resource = RestClient.get( gravatar_url( user)){|response, request, result| response }
- rescue
- # Happens if network is not available
- return 'icons/user.png'
- end
- if gravatar_resource.code == 404
- # Happens if user has not registered to gravatar
- 'icons/user.png'
- else
- gravatar_url( user)
- end
+ def user_default_avatar
+ return "#{authenticated_root_url}#{image_path('icons/user.png')}" if Rails.application.config.relative_url_root.blank?
+
+ relative_url_root = Rails.application.config.relative_url_root.gsub( /\//, '')
+ "#{authenticated_root_url}#{image_path('icons/user.png')}".
+ sub( Regexp.new("/#{relative_url_root}/#{relative_url_root}/"), "/#{relative_url_root}/").
+ sub( Regexp.new("/#{relative_url_root}//#{relative_url_root}/"), "/#{relative_url_root}/")
end
end