gravatar-protocol-relative-url.diff

patch (protocol relative URL) - Go MAEDA, 2016-01-28 16:55

Download (1.92 KB)

View differences:

app/helpers/application_helper.rb (working copy)
1244 1244
  # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
1245 1245
  def avatar(user, options = { })
1246 1246
    if Setting.gravatar_enabled?
1247
      options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default})
1247
      options.merge!(:default => Setting.gravatar_default)
1248 1248
      email = nil
1249 1249
      if user.respond_to?(:mail)
1250 1250
        email = user.mail
lib/plugins/gravatar/lib/gravatar.rb (working copy)
55 55
      image_tag src, options
56 56
    end
57 57
    
58
    # Returns the base Gravatar URL for the given email hash. If ssl evaluates to true,
59
    # a secure URL will be used instead. This is required when the gravatar is to be 
60
    # displayed on a HTTPS site.
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
58
    # Returns the base Gravatar URL for the given email hash
59
    def gravatar_api_url(hash)
60
      "//www.gravatar.com/avatar/#{hash}"
67 61
    end
68 62

  
69 63
    # Return the gravatar URL for the given email address.
......
71 65
      email_hash = Digest::MD5.hexdigest(email)
72 66
      options = DEFAULT_OPTIONS.merge(options)
73 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 69
        opts = []
76 70
        [:rating, :size, :default].each do |opt|
77 71
          unless options[opt].nil?