Module: Facebooker2::Rails::Helpers::FacebookConnect
- Included in:
- Facebooker2::Rails::Helpers
- Defined in:
- lib/facebooker2/rails/helpers/facebook_connect.rb
Instance Method Summary collapse
- #fb_login(options = {}, &proc) ⇒ Object
-
#fb_login_and_redirect(url, options = {}) ⇒ Object
Render an <fb:login-button> element, similar to fb_login_button.
-
#fb_logout_link(text, url, *args) ⇒ Object
Logs the user out of facebook and redirects to the given URL args are passed to the call to link_to_function.
- #fb_server_fbml(style = nil, &proc) ⇒ Object
Instance Method Details
#fb_login(options = {}, &proc) ⇒ Object
29 30 31 32 33 |
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 29 def fb_login( = {},&proc) js = capture(&proc) text = .delete(:text) concat(content_tag("fb:login-button",text,.merge(:onlogin=>js))) end |
#fb_login_and_redirect(url, options = {}) ⇒ Object
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 = "/other_page";"></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 = "/other_page";" v="2">Login with Facebook</fb:login-button>
19 20 21 22 23 24 25 26 27 |
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 19 def fb_login_and_redirect(url, = {}) js = update_page do |page| page.redirect_to url end text = .delete(:text) content_tag("fb:login-button",text,.merge(:onlogin=>js)) end |
#fb_logout_link(text, url, *args) ⇒ Object
Logs the user out of facebook and redirects to the given URL
args are passed to the call to link_to_function
38 39 40 41 |
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 38 def fb_logout_link(text,url,*args) function= "FB.logout(function() {window.location.href = '#{url}';})" link_to_function text, function, *args end |
#fb_server_fbml(style = nil, &proc) ⇒ Object
43 44 45 46 47 |
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 43 def fb_server_fbml(style=nil,&proc) style_string=" style=\"#{style}\"" if style content = capture(&proc) concat("<fb:serverFbml#{style_string}><script type='text/fbml'>#{content}</script></fb:serverFbml>") end |