Module: FacebookApp::FacebookSdkHelper

Defined in:
app/helpers/facebook_app/facebook_sdk_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_facebook_sdkObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 4

def add_facebook_sdk
  %Q{
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
  FB.init({
    appId      : '#{FacebookApp::FacebookCredentials.app_id}', 
    channelURL : '#{facebook_app.facebook_channel_url}', 
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    oauth      : true, // enable OAuth 2.0
    xfbml      : true  // parse XFBML
  });
  // Additional initialization code here
};

// Load the SDK Asynchronously
(function(d){
   var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "//connect.facebook.net/en_US/all.js";
   d.getElementsByTagName('head')[0].appendChild(js);
 }(document));
</script>
  }.html_safe
end

#comments_boxObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 49

def comments_box
  %Q{
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=225198020866871";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-comments" data-href="http://apps.facebook.com/myprofilereport/" data-num-posts="20" data-width="700"></div>
  }.html_safe
end

#facebook_login(text, permissions, log_in_url) ⇒ Object



35
36
37
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 35

def (text, permissions, )
  link_to(text, "#", :onclick => "facebookLogin('#{permissions}', '#{}', 'http://www.identified.com/?fbg=1'").html_safe
end

#facebook_logout_buttonObject



45
46
47
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 45

def facebook_logout_button
  button_to_function("Log out of App", "FB.logout()")
end

#uidObject



31
32
33
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 31

def uid
  javascript_tag("FB.getUserID()")
end

#uninstall_facebook_app_buttonObject



39
40
41
42
43
# File 'app/helpers/facebook_app/facebook_sdk_helper.rb', line 39

def uninstall_facebook_app_button
  # hackish fix for route since engine in Rails 3.1 tries to double up
  # the initial backslash
  button_to_function("Uninstall App", "removeAppPermissions()")
end