Module: Facebooker2::Rails::Helpers::FacebookConnect

Included in:
Facebooker2::Rails::Helpers
Defined in:
lib/facebooker2/rails/helpers/facebook_connect.rb

Instance Method Summary collapse

Instance Method Details

#fb_login(options = {}, &proc) ⇒ Object



29
30
31
32
33
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 29

def (options = {},&proc)
   js = capture(&proc)
   text = options.delete(:text)
   concat(("fb:login-button",text,options.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 = &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>


19
20
21
22
23
24
25
26
27
# File 'lib/facebooker2/rails/helpers/facebook_connect.rb', line 19

def (url, options = {})
  js = update_page do |page|
    page.redirect_to url
  end

  text = options.delete(:text)
  
  ("fb:login-button",text,options.merge(:onlogin=>js))
end

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