Added js helper
This commit is contained in:
parent
930e4d683c
commit
6a47e3c67a
13
facebooker2.gemspec
Normal file
13
facebooker2.gemspec
Normal file
@ -0,0 +1,13 @@
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = 'facebooker2'
|
||||
s.version = '0.0.1'
|
||||
s.summary = "Facebook Connect integration library for ruby and rails"
|
||||
s.description = "Facebook Connect integration library for ruby and rails"
|
||||
s.files = Dir['lib/**/*.rb']
|
||||
s.require_path = 'lib'
|
||||
s.has_rdoc = false
|
||||
s.author = "Mike Mangino"
|
||||
s.email = "mmangino@elevatedrails.com"
|
||||
s.homepage = "http://developers.facebook.com/docs/api"
|
||||
s.add_dependency('mogli', ">=0.0.4")
|
||||
end
|
@ -21,5 +21,6 @@ end
|
||||
|
||||
require "facebooker2/rails/controller"
|
||||
require "facebooker2/rails/helpers/facebook_connect"
|
||||
require "facebooker2/rails/helpers/javascript"
|
||||
require "facebooker2/rails/helpers/user"
|
||||
require "facebooker2/rails/helpers"
|
@ -2,6 +2,7 @@ module Facebooker2
|
||||
module Rails
|
||||
module Helpers
|
||||
include FacebookConnect
|
||||
include Javascript
|
||||
include User
|
||||
end
|
||||
end
|
||||
|
34
lib/facebooker2/rails/helpers/javascript.rb
Normal file
34
lib/facebooker2/rails/helpers/javascript.rb
Normal file
@ -0,0 +1,34 @@
|
||||
module Facebooker2
|
||||
module Rails
|
||||
module Helpers
|
||||
module Javascript
|
||||
def fb_connect_async_js(app_id,options={})
|
||||
opts = Hash.new(true).merge!(options)
|
||||
cookie = opts[:cookie]
|
||||
status = opts[:status]
|
||||
status = opts[:xfbml]
|
||||
js = <<-JAVASCRIPT
|
||||
<div id="fb-root"></div>
|
||||
<script>
|
||||
window.fbAsyncInit = function() {
|
||||
FB.init({
|
||||
appId : '#{app_id}',
|
||||
status : #{status}, // check login status
|
||||
cookie : #{cookie}, // enable cookies to allow the server to access the session
|
||||
xfbml : #{xfbml} // parse XFBML
|
||||
});
|
||||
};
|
||||
|
||||
(function() {
|
||||
var e = document.createElement('script');
|
||||
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
|
||||
e.async = true;
|
||||
document.getElementById('fb-root').appendChild(e);
|
||||
}());
|
||||
</script>
|
||||
JAVASCRIPT
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +1,3 @@
|
||||
require "ruby-debug"
|
||||
module Facebooker2
|
||||
module Rails
|
||||
module Helpers
|
||||
|
Loading…
Reference in New Issue
Block a user