facebook-social_plugins 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "facebook-social_plugins"
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-04-17"
12
+ s.date = "2012-05-03"
13
13
  s.description = "HTML5 compatible social plugin helpers for Rails 3"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.homepage = "http://github.com/kristianmandrup/facebook-social_plugins"
60
60
  s.licenses = ["MIT"]
61
61
  s.require_paths = ["lib"]
62
- s.rubygems_version = "1.8.22"
62
+ s.rubygems_version = "1.8.24"
63
63
  s.summary = "Facebook HTML5 style social plugins for Rails 3"
64
64
 
65
65
  if s.respond_to? :specification_version then
@@ -98,11 +98,21 @@ module FacebookSocialPlugins::Helper
98
98
  # options - status, cookie, xfbml (true|false)
99
99
  # - :channel => 'channel.html'
100
100
  def fb_async_init_script app_id, domain, options = {}
101
+ raise ArgumentError, "Not a valid Facebook App ID. It should be a 15 digit number, was: #{app_id}, length=#{app_id.size}" unless valid_facebook_id?(app_id)
102
+ raise ArgumentError, "No domain name specified" if domain.blank?
103
+
104
+ if options[:channel] || options[:channel_url]
105
+ locale = options[:locale] || I18n.locale
106
+ channel = options[:channel_url] || "assets/facebook_channel_#{locale}"
107
+ channelAttrib = "channelUrl : '//#{domain}/#{channel}.html', // Channel File"
108
+ else
109
+ channelAttrib = '// No Facebook channel defined (use fx #fb_channel_script)'
110
+ end
101
111
  %Q{
102
112
  window.fbAsyncInit = function() {
103
113
  FB.init({
104
- appId : '#{app_id}', // App ID
105
- channelUrl : '//#{domain}/#{options[:channel] || 'assets/facebook_channel'}.html', // Channel File
114
+ appId : '#{app_id}', // App ID
115
+ #{channelAttrib}
106
116
  status : #{options[:status] || true}, // check login status
107
117
  cookie : #{options[:cookie] || true}, // enable cookies to allow the server to access the session
108
118
  xfbml : #{options[:xfbml] || true } // parse XFBML
@@ -113,12 +123,19 @@ module FacebookSocialPlugins::Helper
113
123
  }
114
124
  end
115
125
 
126
+ def valid_facebook_id? id
127
+ raise ArgumentError, "No Facebook app id specified" if id.blank?
128
+ id = /\d{15}/
129
+ end
130
+
116
131
  def fb_channel_script locale = :en_US
117
132
  %Q{
118
133
  (function(d){
119
134
  var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
120
- js = d.createElement('script'); js.id = id; js.async = true;
121
- js.src = "#{all_script locale}";
135
+ js = d.createElement('script');
136
+ js.id = id;
137
+ js.async = true;
138
+ js.src = '#{all_script(locale)}';
122
139
  d.getElementsByTagName('head')[0].appendChild(js);
123
140
  }(document));
124
141
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-social_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-17 00:00:00.000000000 Z
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: -2068637524663629491
203
+ hash: 363436722533423850
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements:
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 1.8.22
212
+ rubygems_version: 1.8.24
213
213
  signing_key:
214
214
  specification_version: 3
215
215
  summary: Facebook HTML5 style social plugins for Rails 3