facebook_session 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b5d4f0754ffc4ec193b5d4361c452ad0d4cbb6a
4
- data.tar.gz: c6b7aab9c0612dd22cc62e349ca7bf3445061a42
3
+ metadata.gz: 563400c1a078004b52fb9a9f990ccbb2339efdcf
4
+ data.tar.gz: c86f941baaa481c0225af3b37b530a3d8be36036
5
5
  SHA512:
6
- metadata.gz: 4145e761156a6e411a39eb90fcc5a8af36834e84740d02c61b5503f67b59e5db8f64c18536a29d362757865395ac265fc0dd8baa03f392d571f3a8134c127251
7
- data.tar.gz: 63a7742caf13f59f3eec877707e8e40c29912ca79ab2ba3cf3af2591878aa60730c7b1d57dc16070b845d72f2b82c3222c8d70c09d04a2423076d917b909186e
6
+ metadata.gz: 99e83ed882ae4b7970fcbbc5b15e5ed1d11a6311f86a37df0a01d77e4963b35c5350612031c7906140d22e6457eed938dc5adaff326efbb16ce1b39bedc5beac
7
+ data.tar.gz: 5ef0a1ea12ca864e0968f6722ac7c86cfcd6f7a1f42791e6c65c4af5562abffc407364c848d5e1b6cdbc2072477435ba7a72a39312e0551a95a9ea8e35082e4f
@@ -0,0 +1,54 @@
1
+ turbolinksEventsBound = false
2
+ facebookReady = false
3
+ facebookAppId = '<%= FacebookSession.application_id %>'
4
+
5
+ window.withFacebookAPI = (callback) ->
6
+ if facebookReady
7
+ callback()
8
+ else
9
+ interval = setInterval ->
10
+ if facebookReady
11
+ clearInterval interval
12
+ callback()
13
+ , 50
14
+
15
+ $ ->
16
+ if facebookAppId
17
+ loadFacebookSDK()
18
+ bindTurbolinksEvents() unless turbolinksEventsBound
19
+ else
20
+ console.log 'Warning: FacebookSession not configured, skipping Facebook API'
21
+
22
+ bindTurbolinksEvents = ->
23
+ fbRoot = null
24
+
25
+ saveFacebookRoot = ->
26
+ fbRoot = $('#fb-root').detach()
27
+
28
+ restoreFacebookRoot = ->
29
+ if $('#fb-root').length > 0
30
+ $('#fb-root').replaceWith fbRoot
31
+ else
32
+ $('body').append fbRoot
33
+
34
+ $(document)
35
+ .on('page:fetch', saveFacebookRoot)
36
+ .on('page:change', restoreFacebookRoot)
37
+ .on('page:load', ->
38
+ FB.XFBML.parse()
39
+ )
40
+
41
+ turbolinksEventsBound = true
42
+
43
+ loadFacebookSDK = ->
44
+ window.fbAsyncInit = initializeFacebookSDK
45
+ $.getScript("//connect.facebook.com/en_US/sdk.js#xfbml=1")
46
+
47
+ initializeFacebookSDK = ->
48
+ FB.init
49
+ appId : facebookAppId
50
+ version : 'v2.0'
51
+ status : true
52
+ cookie : true
53
+ xfbml : true
54
+ facebookReady = true
@@ -1,10 +1,10 @@
1
1
  require 'base64'
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'facebook_session/decodeable_struct')
4
+ require File.join(File.dirname(__FILE__), 'facebook_session/engine')
4
5
  require File.join(File.dirname(__FILE__), 'facebook_session/helper')
5
6
  require File.join(File.dirname(__FILE__), 'facebook_session/message_decoder')
6
7
  require File.join(File.dirname(__FILE__), 'facebook_session/session')
7
- require File.join(File.dirname(__FILE__), 'facebook_session/railtie')
8
8
  require File.join(File.dirname(__FILE__), 'facebook_session/signed_request')
9
9
 
10
10
  module FacebookSession
@@ -56,4 +56,3 @@ module FacebookSession
56
56
  end
57
57
  end
58
58
  end
59
-
@@ -1,7 +1,7 @@
1
1
  require 'rails'
2
2
 
3
3
  module PagesCore
4
- class Railtie < ::Rails::Railtie
4
+ class Engine < ::Rails::Engine
5
5
  initializer :extend_rails do
6
6
  ActionView::Base.send :include, FacebookSession::Helper
7
7
  ActionController::Base.send :include, FacebookSession::Helper
@@ -1,3 +1,3 @@
1
1
  module FacebookSession
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,36 @@
1
+ module FacebookSession
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path '../templates', __FILE__
5
+
6
+ desc "Create facebook_session config and prepare application.js"
7
+
8
+ def create_initializer
9
+ template 'initializer.rb', File.join('config', 'initializers', 'facebook_session.rb')
10
+ end
11
+
12
+
13
+ def inject_js
14
+ require_js = "//= require facebook_session\n"
15
+
16
+ if manifest.exist?
17
+ manifest_contents = File.read(manifest)
18
+
19
+ if manifest_contents.include? 'require_tree'
20
+ inject_into_file manifest, require_js, {before: '//= require_tree'}
21
+ else
22
+ append_file manifest, require_js
23
+ end
24
+ else
25
+ create_file manifest, require_js
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def manifest
32
+ Pathname.new(destination_root).join('app/assets/javascripts', 'application.js')
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+ FacebookSession.configure(
2
+ application_id: ENV['FACEBOOK_APPLICATION_ID'],
3
+ application_secret: ENV['FACEBOOK_APPLICATION_SECRET']
4
+ )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_session
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,20 +24,51 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coffee-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: Rails plugin for simple Facebook session authentication
28
56
  email: inge@manualdesign.no
29
57
  executables: []
30
58
  extensions: []
31
59
  extra_rdoc_files: []
32
60
  files:
61
+ - app/assets/javascripts/facebook_session.js.coffee.erb
33
62
  - lib/facebook_session.rb
34
63
  - lib/facebook_session/decodeable_struct.rb
64
+ - lib/facebook_session/engine.rb
35
65
  - lib/facebook_session/helper.rb
36
66
  - lib/facebook_session/message_decoder.rb
37
- - lib/facebook_session/railtie.rb
38
67
  - lib/facebook_session/session.rb
39
68
  - lib/facebook_session/signed_request.rb
40
69
  - lib/facebook_session/version.rb
70
+ - lib/generators/facebook_session/install_generator.rb
71
+ - lib/generators/facebook_session/templates/initializer.rb
41
72
  - spec/facebook_session_spec.rb
42
73
  - spec/helper_spec.rb
43
74
  - spec/message_decoder_spec.rb