Added js helper

This commit is contained in:
Mike Mangino 2010-05-05 14:08:46 -04:00
parent 930e4d683c
commit 6a47e3c67a
5 changed files with 49 additions and 1 deletions

13
facebooker2.gemspec Normal file
View 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

View File

@ -21,5 +21,6 @@ end
require "facebooker2/rails/controller" require "facebooker2/rails/controller"
require "facebooker2/rails/helpers/facebook_connect" require "facebooker2/rails/helpers/facebook_connect"
require "facebooker2/rails/helpers/javascript"
require "facebooker2/rails/helpers/user" require "facebooker2/rails/helpers/user"
require "facebooker2/rails/helpers" require "facebooker2/rails/helpers"

View File

@ -2,6 +2,7 @@ module Facebooker2
module Rails module Rails
module Helpers module Helpers
include FacebookConnect include FacebookConnect
include Javascript
include User include User
end end
end end

View 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

View File

@ -1,4 +1,3 @@
require "ruby-debug"
module Facebooker2 module Facebooker2
module Rails module Rails
module Helpers module Helpers