Skip to content
Browse files

Merge branch 'master' of github.com:mmangino/facebooker

  • Loading branch information...
2 parents 0c56041 + 26689d5 commit 014fbc9f176fdc4ca2b6dd05656ba2734e9d7655 @mmangino mmangino committed Mar 1, 2010
View
45 lib/facebooker/rails/helpers/fb_connect.rb
@@ -66,37 +66,64 @@ def init_fb_connect(*required_features,&proc)
end
end
+ #
# Render an <fb:login-button> element
#
# ==== Examples
#
- # <%= fb_login_button%>
- # => <fb:login-button></fb:login-button>
+ # <%= fb_login_button%>
+ # => <fb:login-button></fb:login-button>
#
# Specifying a javascript callback
#
- # <%= fb_login_button 'update_something();'%>
- # => <fb:login-button onlogin='update_something();'></fb:login-button>
+ # <%= fb_login_button 'update_something();'%>
+ # => <fb:login-button onlogin='update_something();'></fb:login-button>
#
# Adding options <em>See:</em> http://wiki.developers.facebook.com/index.php/Fb:login-button
#
- # <%= fb_login_button 'update_something();', :size => :small, :background => :dark%>
- # => <fb:login-button background='dark' onlogin='update_something();' size='small'></fb:login-button>
+ # <%= fb_login_button 'update_something();', :size => :small, :background => :dark%>
+ # => <fb:login-button background='dark' onlogin='update_something();' size='small'></fb:login-button>
+ #
+ # :text option allows you to set the text value of the
+ # button. *A note!* This will only do what you expect it to do
+ # if you set :v => 2 as well.
#
+ # <%= fb_login_button 'update_somethign();',
+ # :text => 'Loginto Facebook', :v => 2 %>
+ # => <fb:login-button v='2' onlogin='update_something();'>Login to Facebook</fb:login-button>
def fb_login_button(*args)
callback = args.first
options = args[1] || {}
- options.merge!(:onlogin=>callback)if callback
+ options.merge!(:onlogin=>callback) if callback
+
+ text = options.delete(:text)
- content_tag("fb:login-button",nil, options)
+ content_tag("fb:login-button",text, options)
end
+ #
+ # Render an <fb:login-button> element, similar to
+ # fb_login_button. Adds a js redirect to the onlogin event via rjs.
+ #
+ # ==== Examples
+ #
+ # fb_login_and_redirect '/other_page'
+ # => <fb:login-button onlogin="window.location.href = &quot;/other_page&quot;;"></fb:login-button>
+ #
+ # Like #fb_login_button, this also supports the :text option
+ #
+ # fb_login_and_redirect '/other_page', :text => "Login with Facebook", :v => '2'
+ # => <fb:login-button onlogin="window.location.href = &quot;/other_page&quot;;" v="2">Login with Facebook</fb:login-button>
+ #
def fb_login_and_redirect(url, options = {})
js = update_page do |page|
page.redirect_to url
end
- content_tag("fb:login-button",nil,options.merge(:onlogin=>js))
+
+ text = options.delete(:text)
+
+ content_tag("fb:login-button",text,options.merge(:onlogin=>js))
end
def fb_unconnected_friends_count
View
1 lib/facebooker/rails/publisher.rb
@@ -108,6 +108,7 @@ def initialize
@from = nil
@full_story_template = nil
@recipients = nil
+ @action_links = nil
@controller = PublisherController.new(self)
@action_links = nil
end
View
1 lib/facebooker/service.rb
@@ -7,6 +7,7 @@ def initialize(api_base, api_path, api_key)
@api_key = api_key
end
+ @active_service = nil
def self.active_service
unless @active_service
if Facebooker.use_curl?
View
4 test/facebooker/rails_integration_test.rb
@@ -1032,6 +1032,8 @@ def test_fb_narrow
def test_fb_login_button
assert_equal "<fb:login-button onlogin=\"somejs\"></fb:login-button>",@h.fb_login_button("somejs")
+
+ assert_equal "<fb:login-button onlogin=\"somejs\">Custom</fb:login-button>",@h.fb_login_button("somejs", :text => 'Custom')
end
def test_init_fb_connect_no_features
@@ -1096,6 +1098,8 @@ def test_init_fb_connect_with_options_app_settings
def test_fb_login_and_redirect
assert_equal @h.fb_login_and_redirect("/path"),"<fb:login-button onlogin=\"window.location.href = &quot;/path&quot;;\"></fb:login-button>"
+
+ assert_equal @h.fb_login_and_redirect("/path", :text => 'foo'),"<fb:login-button onlogin=\"window.location.href = &quot;/path&quot;;\">foo</fb:login-button>"
end
def test_fb_logout_link

0 comments on commit 014fbc9

Please sign in to comment.
Something went wrong with that request. Please try again.