facebook-social_plugins 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -1
- data/VERSION +1 -1
- data/facebook-social_plugins.gemspec +4 -2
- data/lib/facebook-social_plugins.rb +2 -2
- data/lib/facebook-social_plugins/activity_feed.rb +2 -2
- data/lib/facebook-social_plugins/analytics.rb +0 -1
- data/lib/facebook-social_plugins/button.rb +1 -1
- data/lib/facebook-social_plugins/facepile.rb +1 -1
- data/lib/facebook-social_plugins/like_button.rb +1 -1
- data/lib/facebook-social_plugins/recommendations_box.rb +1 -1
- data/lib/facebook-social_plugins/registration.rb +5 -1
- data/lib/facebook-social_plugins/script_helper.rb +37 -2
- data/lib/facebook-social_plugins/social_plugin.rb +21 -1
- data/lib/facebook-social_plugins/subscribe_button.rb +1 -1
- data/lib/facebook-social_plugins/view_helper.rb +10 -0
- data/spec/facebook-social_plugins/script_helper_spec.rb +34 -9
- data/spec/facebook-social_plugins/view_helper_spec.rb +7 -0
- data/vendor/assets/images/fb_logout_large.gif +0 -0
- data/vendor/assets/images/fb_logout_small.gif +0 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -92,6 +92,17 @@ The JavaScript SDK is available in all locales that are supported by Facebook. T
|
|
92
92
|
}(document));
|
93
93
|
</script>
|
94
94
|
|
95
|
+
=== Configuration scripts*
|
96
|
+
|
97
|
+
* fb_async_init_script(app_id, domain)
|
98
|
+
* fb_channel_script(locale = :en_US)
|
99
|
+
|
100
|
+
=== Login and Logout
|
101
|
+
|
102
|
+
* fb_logout_and_reload(options = {:ready => false, :selector => '#fb_logout_and_reload'})
|
103
|
+
* fb_login_and_reload(options = {:ready => false, :selector => '#fb_login_and_reload'})
|
104
|
+
* fb_logout_and_redirect_to(path, options = {:ready => false})
|
105
|
+
|
95
106
|
== Open Graph Meta helper
|
96
107
|
|
97
108
|
Convenience method to generate all header/meta tags for Facebook Open Graph
|
@@ -114,6 +125,9 @@ Open graph <meta> tag helpers
|
|
114
125
|
* fb_analytics(app_id) # Facebook analytics meta tag
|
115
126
|
* fb_activity(namespace, action) # Open Graph action to perform
|
116
127
|
|
128
|
+
* fb_logout(script) # setup FB event handler to trigger on FB logout
|
129
|
+
* fb_logout_and_redirect_to(path) # setup FB event handler to trigger on FB logout and redirect
|
130
|
+
|
117
131
|
== Social plugins
|
118
132
|
|
119
133
|
Currently the following Social plugins are included in this gem
|
@@ -147,7 +161,15 @@ View methods exposed:
|
|
147
161
|
* fb_send_button (options = {})
|
148
162
|
* fb_subscribe_button (options = {})
|
149
163
|
|
150
|
-
Note: You don't have to worry about dashed or underscored properties. Conversions will be handled automatically. The Facebook Social plugins API is (sadly) not very consistent when it comes to attribute names.
|
164
|
+
Note: You don't have to worry about dashed or underscored properties. Conversions will be handled automatically. The Facebook Social plugins API is (sadly) not very consistent when it comes to attribute names.
|
165
|
+
|
166
|
+
Extras:
|
167
|
+
|
168
|
+
* fb_logout_button(options = {}) # renders logout button (english only)
|
169
|
+
|
170
|
+
Logout button options:
|
171
|
+
html: (html options for anchor tag)
|
172
|
+
size: 'small' or 'large' (size of logout button img)
|
151
173
|
|
152
174
|
=== Facebook root
|
153
175
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "facebook-social_plugins"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.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"]
|
@@ -52,7 +52,9 @@ Gem::Specification.new do |s|
|
|
52
52
|
"spec/facebook-social_plugins/script_helper_spec.rb",
|
53
53
|
"spec/facebook-social_plugins/view_helper_spec.rb",
|
54
54
|
"spec/spec_helper.rb",
|
55
|
-
"vendor/assets/html/facebook_channel.html"
|
55
|
+
"vendor/assets/html/facebook_channel.html",
|
56
|
+
"vendor/assets/images/fb_logout_large.gif",
|
57
|
+
"vendor/assets/images/fb_logout_small.gif"
|
56
58
|
]
|
57
59
|
s.homepage = "http://github.com/kristianmandrup/facebook-social_plugins"
|
58
60
|
s.licenses = ["MIT"]
|
@@ -5,7 +5,7 @@ require 'facebook-social_plugins/open_graph/meta_helper'
|
|
5
5
|
|
6
6
|
module FacebookSocialPlugins
|
7
7
|
def self.plugins
|
8
|
-
['activity_feed', 'add_to_timeline', 'comments', 'facepile', 'like_box', 'like_button',
|
8
|
+
['activity_feed', 'add_to_timeline', 'comments', 'facepile', 'like_box', 'like_button',
|
9
9
|
'live_stream', 'login_button', 'recommendations_box', 'registration', 'send_button', 'subscribe_button']
|
10
10
|
end
|
11
11
|
|
@@ -22,4 +22,4 @@ FacebookSocialPlugins.helpers.each do |name|
|
|
22
22
|
require "facebook-social_plugins/#{name}_helper"
|
23
23
|
end
|
24
24
|
|
25
|
-
require 'facebook-social_plugins/rails/engine'
|
25
|
+
require 'facebook-social_plugins/rails/engine' if defined?(::Rails::Engine)
|
@@ -26,8 +26,8 @@ module FacebookSocialPlugins
|
|
26
26
|
def attributes
|
27
27
|
super.merge(
|
28
28
|
:site => :string, :action => :array, :app_id => :string, :width => :integer, :height => :integer,
|
29
|
-
:header => :boolean, :colorscheme =>
|
30
|
-
:border_color => :string, :recommendations => :boolean, :filter => :string, :linktarget =>
|
29
|
+
:header => :boolean, :colorscheme => colorschemes, :font => fonts,
|
30
|
+
:border_color => :string, :recommendations => :boolean, :filter => :string, :linktarget => linktargets,
|
31
31
|
:ref => :string, :max_age => :integer, :width => :integer
|
32
32
|
)
|
33
33
|
end
|
@@ -12,7 +12,7 @@ module FacebookSocialPlugins
|
|
12
12
|
|
13
13
|
# attributes always availabe for a button?
|
14
14
|
def attributes
|
15
|
-
super.merge(:font =>
|
15
|
+
super.merge(:font => fonts, :colorscheme => colorschemes)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -30,7 +30,7 @@ module FacebookSocialPlugins
|
|
30
30
|
# max_rows - max rows to display, 1-10 normally
|
31
31
|
def attributes
|
32
32
|
super.merge(:'event-app-id' => :string, :action => :string, :href => :string,
|
33
|
-
:max_rows => :integer, :size =>
|
33
|
+
:max_rows => :integer, :size => sizes, :width => :integer
|
34
34
|
)
|
35
35
|
end
|
36
36
|
end
|
@@ -24,7 +24,7 @@ module FacebookSocialPlugins
|
|
24
24
|
# fb_source - the stream type ('home', 'profile', 'search', 'ticker', 'tickerdialog' or 'other') in which the click occurred and the story type ('oneline' or 'multiline'), concatenated with an underscore.
|
25
25
|
def attributes
|
26
26
|
super.merge(
|
27
|
-
:href => :string, :send => :boolean, :layout =>
|
27
|
+
:href => :string, :send => :boolean, :layout => layouts,
|
28
28
|
:show_faces => :boolean, :action => ['like', 'recommend'], :ref => :string,
|
29
29
|
:fb_ref => :string, :fb_source => :special, :width => :integer
|
30
30
|
)
|
@@ -34,7 +34,7 @@ module FacebookSocialPlugins
|
|
34
34
|
# Otherwise the valid values are 1-180, which specifies the number of days.
|
35
35
|
def attributes
|
36
36
|
super.merge(:site => :string, :action => :string, :app_id => :string, :height => :integer,
|
37
|
-
:header => :string, :linktarget =>
|
37
|
+
:header => :string, :linktarget => linktargets, :ref => :string,
|
38
38
|
:max_age => :integer, :width => :integer)
|
39
39
|
end
|
40
40
|
end
|
@@ -27,10 +27,14 @@ module FacebookSocialPlugins
|
|
27
27
|
# target Optional. The target of the form submission: _top (default), _parent, or _self.
|
28
28
|
def attributes
|
29
29
|
super.merge(:client_id => :string, :redirect_uri => :string, :fields => :string,
|
30
|
-
:fb_only => :boolean, :fb_register => :boolean, :border_color => :string, :target =>
|
30
|
+
:fb_only => :boolean, :fb_register => :boolean, :border_color => :string, :target => targets
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
34
|
+
def targets
|
35
|
+
['_top', '_parent', '_self']
|
36
|
+
end
|
37
|
+
|
34
38
|
# Named Fields
|
35
39
|
|
36
40
|
# Specify these in the order you want them to appear in the form. The name field must always be the first field.
|
@@ -1,11 +1,39 @@
|
|
1
1
|
module FacebookSocialPlugins
|
2
2
|
module ScriptHelper
|
3
3
|
|
4
|
+
# can be used inside a js.erb file or similar
|
5
|
+
def fb_login_and_reload options = {:ready => false, :selector => '#fb_login_and_reload'}
|
6
|
+
selector = options[:selector] || '#fb_login_and_reload'
|
7
|
+
script = %Q{$('#{selector}').click(function() {
|
8
|
+
FB.Connect.requireSession(function() { reload(); }); return false;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
options[:ready] ? wrap_ready(script) : script
|
12
|
+
end
|
13
|
+
|
14
|
+
def fb_logout_and_reload options = {:ready => false, :selector => '#fb_logout_and_reload'}
|
15
|
+
selector = options[:selector] || '#fb_logout_and_reload'
|
16
|
+
script = %Q{$('#{selector}').click(function() {
|
17
|
+
FB.Connect.logout(function() { reload(); }); return false;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
options[:ready] ? wrap_ready(script) : script
|
21
|
+
end
|
22
|
+
|
23
|
+
def fb_logout_and_redirect_to path, options = {:ready => false}
|
24
|
+
script = %Q{FB.Event.subscribe("auth.logout", function() {
|
25
|
+
window.location = '#{path}'
|
26
|
+
});
|
27
|
+
}
|
28
|
+
options[:ready] ? wrap_ready(script) : script
|
29
|
+
end
|
30
|
+
|
31
|
+
|
4
32
|
# app_id - facebook app id, a number/string, fx '753632322'
|
5
33
|
# domain - fx www.example.com
|
6
34
|
# options - status, cookie, xfbml (true|false)
|
7
35
|
# - :channel => 'channel.html'
|
8
|
-
def
|
36
|
+
def fb_async_init_script app_id, domain, options = {}
|
9
37
|
%Q{
|
10
38
|
window.fbAsyncInit = function() {
|
11
39
|
FB.init({
|
@@ -21,7 +49,7 @@ module FacebookSocialPlugins
|
|
21
49
|
}
|
22
50
|
end
|
23
51
|
|
24
|
-
def
|
52
|
+
def fb_channel_script locale = :en_US
|
25
53
|
%Q{
|
26
54
|
(function(d){
|
27
55
|
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
|
@@ -34,6 +62,13 @@ module FacebookSocialPlugins
|
|
34
62
|
|
35
63
|
protected
|
36
64
|
|
65
|
+
def wrap_ready script
|
66
|
+
%Q{$(function() {
|
67
|
+
#{script}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
37
72
|
# The JavaScript SDK is available in all locales that are supported by Facebook.
|
38
73
|
# This list of supported locales is available as an XML file.
|
39
74
|
# To change the locale of the SDK to match the locale of your site, change en_US to a
|
@@ -29,6 +29,26 @@ module FacebookSocialPlugins
|
|
29
29
|
|
30
30
|
protected
|
31
31
|
|
32
|
+
def layouts
|
33
|
+
['standard', 'button_count', 'box_count']
|
34
|
+
end
|
35
|
+
|
36
|
+
def sizes
|
37
|
+
['small', 'large']
|
38
|
+
end
|
39
|
+
|
40
|
+
def fonts
|
41
|
+
['arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana']
|
42
|
+
end
|
43
|
+
|
44
|
+
def colorschemes
|
45
|
+
['light', 'dark']
|
46
|
+
end
|
47
|
+
|
48
|
+
def linktargets
|
49
|
+
['_top', '_parent']
|
50
|
+
end
|
51
|
+
|
32
52
|
def find_att_key key
|
33
53
|
return key if attributes[key]
|
34
54
|
key = key.to_s.dasherize.to_sym
|
@@ -47,7 +67,7 @@ module FacebookSocialPlugins
|
|
47
67
|
end
|
48
68
|
|
49
69
|
def attributes
|
50
|
-
@attributes ||= {}
|
70
|
+
@attributes ||= {:id => :string, :style => :string}
|
51
71
|
end
|
52
72
|
|
53
73
|
def valid? value, valid_type
|
@@ -18,7 +18,7 @@ module FacebookSocialPlugins
|
|
18
18
|
# font - the font to display in the plugin. Options: 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
|
19
19
|
# width - the width of the plugin.
|
20
20
|
def attributes
|
21
|
-
super.merge(:href => :string, :layout =>
|
21
|
+
super.merge(:href => :string, :layout => layouts,
|
22
22
|
:show_faces => :boolean, :width => :integer)
|
23
23
|
end
|
24
24
|
end
|
@@ -44,6 +44,16 @@ module FacebookSocialPlugins
|
|
44
44
|
FacebookSocialPlugins::LoginButton.new(options).render
|
45
45
|
end
|
46
46
|
|
47
|
+
def fb_logout_button options = {}
|
48
|
+
content_tag :a, '', {:id => 'fb_logout_and_reload', :href => '#'}.merge(options[:html] || {}) do
|
49
|
+
content_tag(:img, '', :id => 'fb_logout_image', :src => "/assets/fb_logout_#{options[:size] || :small}.gif", :alt => "Facebook Logout").html_safe
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def fb_logout &block
|
54
|
+
content_tag :script, %Q{FB.Event.subscribe("auth.logout", function() { #{yield} });}
|
55
|
+
end
|
56
|
+
|
47
57
|
def fb_recommendations_box options = {}
|
48
58
|
FacebookSocialPlugins::RecommendationsBox.new(options).render
|
49
59
|
end
|
@@ -38,18 +38,43 @@ describe FacebookSocialPlugins::ScriptHelper do
|
|
38
38
|
include ControllerTestHelpers,
|
39
39
|
FacebookSocialPlugins::ScriptHelper
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
describe '#async_init_script' do
|
42
|
+
it "should create async init script" do
|
43
|
+
output = fb_async_init_script '123', 'www.example.com'
|
44
|
+
output.should == async_script
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
describe '#facebook_script' do
|
49
|
+
it "should create facebook script" do
|
50
|
+
output = fb_channel_script
|
51
|
+
output.should == fb_script
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should create localized facebook script" do
|
55
|
+
output = fb_channel_script :es_LA
|
56
|
+
output.should == fb_script_es
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#fb_login_and_reload' do
|
61
|
+
it 'should work' do
|
62
|
+
output = fb_login_and_reload :ready => true, :selector => '#fb_login'
|
63
|
+
output.should == "$(function() {\n\t\t$('#fb_login').click(function() { \n\t\tFB.Connect.requireSession(function() { reload(); }); return false;\n }\n\n\t}\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#fb_logout_and_reload' do
|
68
|
+
it 'should work' do
|
69
|
+
output = fb_logout_and_reload(:ready => true)
|
70
|
+
output.should == "$(function() {\n\t\t$('#fb_logout_and_reload').click(function() { \n\t\tFB.Connect.logout(function() { reload(); }); return false;\n }\n\n\t}\n"
|
71
|
+
end
|
49
72
|
end
|
50
73
|
|
51
|
-
|
52
|
-
|
53
|
-
|
74
|
+
describe '#fb_logout_and_redirect_to' do
|
75
|
+
it 'should work' do
|
76
|
+
output = fb_logout_and_redirect_to('facebook/logout', :ready => true)
|
77
|
+
output.should == "$(function() {\n\t\tFB.Event.subscribe(\"auth.logout\", function() { \n\twindow.location = 'facebook/logout' \n\t}); \n\n\t}\n"
|
78
|
+
end
|
54
79
|
end
|
55
80
|
end
|
@@ -17,6 +17,13 @@ describe FacebookSocialPlugins::ViewHelper do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
describe 'Logout button' do
|
21
|
+
it "should create :logout button (anchor with image" do
|
22
|
+
output = fb_logout_button :size => :large
|
23
|
+
output.should == "<a href=\"#\" id=\"fb_logout_and_reload\"><img alt=\"Facebook Logout\" id=\"fb_logout_image\" src=\"/assets/fb_logout_large.gif\"></img></a>"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
20
27
|
describe 'Facebook Root placeholder' do
|
21
28
|
it "should create :root div" do
|
22
29
|
output = fb_root
|
Binary file
|
Binary file
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- spec/facebook-social_plugins/view_helper_spec.rb
|
184
184
|
- spec/spec_helper.rb
|
185
185
|
- vendor/assets/html/facebook_channel.html
|
186
|
+
- vendor/assets/images/fb_logout_large.gif
|
187
|
+
- vendor/assets/images/fb_logout_small.gif
|
186
188
|
homepage: http://github.com/kristianmandrup/facebook-social_plugins
|
187
189
|
licenses:
|
188
190
|
- MIT
|
@@ -198,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
200
|
version: '0'
|
199
201
|
segments:
|
200
202
|
- 0
|
201
|
-
hash:
|
203
|
+
hash: 2399279571937946151
|
202
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
205
|
none: false
|
204
206
|
requirements:
|