##// END OF EJS Templates
Use protocol-relative URL for gravatars (#21855)....
Jean-Philippe Lang -
r14863:3de694f5e58b
parent child
Show More
@@ -1244,7 +1244,7 module ApplicationHelper
1244 # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
1244 # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
1245 def avatar(user, options = { })
1245 def avatar(user, options = { })
1246 if Setting.gravatar_enabled?
1246 if Setting.gravatar_enabled?
1247 options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default})
1247 options.merge!(:default => Setting.gravatar_default)
1248 email = nil
1248 email = nil
1249 if user.respond_to?(:mail)
1249 if user.respond_to?(:mail)
1250 email = user.mail
1250 email = user.mail
@@ -55,15 +55,9 module GravatarHelper
55 image_tag src, options
55 image_tag src, options
56 end
56 end
57
57
58 # Returns the base Gravatar URL for the given email hash. If ssl evaluates to true,
58 # Returns the base Gravatar URL for the given email hash
59 # a secure URL will be used instead. This is required when the gravatar is to be
59 def gravatar_api_url(hash)
60 # displayed on a HTTPS site.
60 "//www.gravatar.com/avatar/#{hash}"
61 def gravatar_api_url(hash, ssl=false)
62 if ssl
63 "https://secure.gravatar.com/avatar/#{hash}"
64 else
65 "http://www.gravatar.com/avatar/#{hash}"
66 end
67 end
61 end
68
62
69 # Return the gravatar URL for the given email address.
63 # Return the gravatar URL for the given email address.
@@ -71,7 +65,7 module GravatarHelper
71 email_hash = Digest::MD5.hexdigest(email)
65 email_hash = Digest::MD5.hexdigest(email)
72 options = DEFAULT_OPTIONS.merge(options)
66 options = DEFAULT_OPTIONS.merge(options)
73 options[:default] = CGI::escape(options[:default]) unless options[:default].nil?
67 options[:default] = CGI::escape(options[:default]) unless options[:default].nil?
74 gravatar_api_url(email_hash, options.delete(:ssl)).tap do |url|
68 gravatar_api_url(email_hash).tap do |url|
75 opts = []
69 opts = []
76 [:rating, :size, :default].each do |opt|
70 [:rating, :size, :default].each do |opt|
77 unless options[opt].nil?
71 unless options[opt].nil?
General Comments 0
You need to be logged in to leave comments. Login now