Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Implemented signup_url #10

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 1 deletion.
  1. +10 −1 lib/gravatar.rb
  2. +8 −0 spec/lib/gravatar_spec.rb
View
11 lib/gravatar.rb
@@ -18,7 +18,7 @@
class Gravatar
API_METHODS = [
:exists?, :addresses, :user_images, :save_data!, :save_image!, :save_url!, :use_image!, :use_user_image!,
- :remove_image!, :delete_user_image!, :test, :image_url, :image_data
+ :remove_image!, :delete_user_image!, :test, :image_url, :image_data, :signup_url
]
autoload :TestCase, File.expand_path('gravatar/test_case', File.dirname(__FILE__))
@@ -207,6 +207,15 @@ def image_url(options = {})
"#{proto}://#{sub}.gravatar.com/avatar/#{email_hash}#{extension_for_image(options)}#{query_for_image(options)}"
end
+ # Returns the URL for Gravatar's signup form, with the user's email pre-filled. Options include:
+ #
+ # :locale if non-nil, wil be used to prefix the URL. Example: :en
+ def signup_url(options = {})
+ locale_prefix = options[:locale] ? "#{options[:locale]}." : ''
+
+ "https://#{locale_prefix}gravatar.com/site/signup/#{CGI.escape(email)}"
+ end
+
# Returns the image data for this user's gravatar image. This is the same as reading the data at #image_url. See
# that method for more information.
#
View
8 spec/lib/gravatar_spec.rb
@@ -173,5 +173,13 @@
)
combinations.should include(image_url(:ssl => true, :default => "identicon", :size => 80, :rating => :g))
end
+
+ it "should return gravatar signup_url" do
+ signup_url.should == "https://gravatar.com/site/signup/gravatartest123%40gmail.com"
+ end
+
+ it "should return gravatar signup_url with locale" do
+ signup_url(:locale => :en).should == "https://en.gravatar.com/site/signup/gravatartest123%40gmail.com"
+ end
end
end
Something went wrong with that request. Please try again.