plataforma_social 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,5 +44,9 @@ module PlataformaSocial
44
44
  configuration.facebook_callback_url || "#{protocol}://apps.facebook.com/#{configuration.facebook_app_namespace}/"
45
45
  end
46
46
 
47
+ def admin_controller_name
48
+ configuration.admin_controller_name || 'admin'
49
+ end
50
+
47
51
  end
48
52
  end
@@ -1,5 +1,5 @@
1
1
  module PlataformaSocial
2
2
  class Configuration
3
- attr_accessor :api_key, :secret, :facebook_app_secret, :facebook_app_id, :facebook_app_namespace, :facebook_scope, :facebook_callback_url
3
+ attr_accessor :api_key, :secret, :facebook_app_secret, :facebook_app_id, :facebook_app_namespace, :facebook_scope, :facebook_callback_url, :admin_controller_name
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ module PlataformaSocial
2
2
  module Helpers
3
3
 
4
4
  def plataforma_social_javascripts
5
- plataforma_social_script_tag + plataforma_social_config_script
5
+ plataforma_social_script_tag + plataforma_social_config_script + signed_request_javascript
6
6
  end
7
7
 
8
8
  def plataforma_social_script_tag
@@ -16,6 +16,43 @@ module PlataformaSocial
16
16
  </script>}.html_safe
17
17
  end
18
18
 
19
+ def signed_request_javascript
20
+ default_params = {
21
+ :signed_request => params[:signed_request] || nil,
22
+ :code => params[:code] || nil
23
+ }
24
+
25
+ p default_params
26
+
27
+ %Q{
28
+ <script type="text/javascript" charset="utf-8">
29
+ $(function(){
30
+ $('body').bind('ajaxSend', function(elm, xhr, s){
31
+ var defaultParams = #{default_params.to_json};
32
+ var params = {};
33
+
34
+ var data = s.type == "POST" ? s.data : s.url.split('?')[1];
35
+
36
+ if(data){
37
+ var splittedData = data.split('&');
38
+ for(var i in splittedData){
39
+ var param = splittedData[i].split('=');
40
+
41
+ params[param[0]] = param[1];
42
+ } // for
43
+ } // if
44
+
45
+ for(var i in defaultParams){
46
+ if(!params[i]) params[i] = defaultParams[i];
47
+ }
48
+
49
+ s.data = $.param(params);
50
+ })
51
+ });
52
+ </script>
53
+ }.html_safe
54
+ end
55
+
19
56
  def custom_redirect_to path, options = {}
20
57
  options.each_pair do |key, value|
21
58
  cookies[key] = value
@@ -29,28 +66,31 @@ module PlataformaSocial
29
66
  end
30
67
 
31
68
  def link_to *args, &block
69
+ args[2] ||= {}
70
+
32
71
  if args[2][:normal] === true
33
72
  super
34
73
  else
35
74
  unless block_given?
36
75
  referer = request.referer
37
76
  facebook_domain = 'apps.facebook.com'
38
- if params["controller"].include?("admin/")
77
+
78
+ if params[:controller].index(PlataformaSocial.admin_controller_name) == 0
39
79
  super
40
80
  else
41
81
  server_domain = request.env['HTTP_HOST']
82
+ url = facebook_domain + '/' + PlataformaSocial.facebook_app_namespace
83
+
42
84
  if args[1].index(request.env['HTTP_HOST'])
43
- args[1].gsub! server_domain, facebook_domain + '/' + PlataformaSocial.facebook_app_namespace
85
+ args[1].gsub! server_domain, url
44
86
  else
45
- args[1] = request.protocol + facebook_domain + '/' + PlataformaSocial.facebook_app_namespace + args[1]
87
+ args[1] = request.protocol + url + args[1]
46
88
  end
47
89
 
48
- args[2] ||= {}
49
90
  args[2][:target] = '_top'
50
-
51
91
  end
52
92
  end
53
-
93
+
54
94
  super
55
95
  end
56
96
  end
@@ -1,3 +1,3 @@
1
1
  module PlataformaSocial
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
 
21
- gem.add_dependency "capistrano", "~>2.11.2"
21
+ gem.add_dependency 'capistrano'
22
22
  gem.add_dependency 'rsa', '~> 0.1.4'
23
23
  gem.add_dependency 'koala', '~> 1.6.0'
24
24
  gem.add_dependency 'httparty', '~> 0.10.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plataforma_social
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,17 +16,17 @@ dependencies:
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.11.2
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.11.2
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rsa
32
32
  requirement: !ruby/object:Gem::Requirement