facebook-social_plugins 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/AddToTimeline.txt +49 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +121 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +277 -0
  8. data/Rakefile +49 -0
  9. data/VERSION +1 -0
  10. data/facebook-social_plugins.gemspec +93 -0
  11. data/lib/facebook-social_plugins.rb +22 -0
  12. data/lib/facebook-social_plugins/activity_feed.rb +35 -0
  13. data/lib/facebook-social_plugins/add_to_timeline.rb +18 -0
  14. data/lib/facebook-social_plugins/button.rb +18 -0
  15. data/lib/facebook-social_plugins/comments.rb +20 -0
  16. data/lib/facebook-social_plugins/facepile.rb +37 -0
  17. data/lib/facebook-social_plugins/like_box.rb +28 -0
  18. data/lib/facebook-social_plugins/like_button.rb +51 -0
  19. data/lib/facebook-social_plugins/live_stream.rb +21 -0
  20. data/lib/facebook-social_plugins/login_button.rb +26 -0
  21. data/lib/facebook-social_plugins/rails/engine.rb +10 -0
  22. data/lib/facebook-social_plugins/recommendations_box.rb +41 -0
  23. data/lib/facebook-social_plugins/registration.rb +52 -0
  24. data/lib/facebook-social_plugins/script_helper.rb +48 -0
  25. data/lib/facebook-social_plugins/send_button.rb +24 -0
  26. data/lib/facebook-social_plugins/social_plugin.rb +84 -0
  27. data/lib/facebook-social_plugins/subscribe_button.rb +27 -0
  28. data/lib/facebook-social_plugins/ui_helper.rb +10 -0
  29. data/lib/facebook-social_plugins/view_helper.rb +56 -0
  30. data/spec/facebook-social_plugins/script_helper_spec.rb +55 -0
  31. data/spec/facebook-social_plugins/view_helper_spec.rb +113 -0
  32. data/spec/spec_helper.rb +47 -0
  33. data/vendor/assets/html/facebook_channel.html +1 -0
  34. metadata +211 -0
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "facebook-social_plugins"
18
+ gem.homepage = "http://github.com/kristianmandrup/facebook-social_plugins"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Facebook HTML5 style social plugins for Rails 3}
21
+ gem.description = %Q{HTML5 compatible social plugin helpers for Rails 3}
22
+ gem.email = "kmandrup@gmail.com"
23
+ gem.authors = ["Kristian Mandrup"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "facebook-social_plugins #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,93 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "facebook-social_plugins"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kristian Mandrup"]
12
+ s.date = "2012-04-03"
13
+ s.description = "HTML5 compatible social plugin helpers for Rails 3"
14
+ s.email = "kmandrup@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "AddToTimeline.txt",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "facebook-social_plugins.gemspec",
30
+ "lib/facebook-social_plugins.rb",
31
+ "lib/facebook-social_plugins/activity_feed.rb",
32
+ "lib/facebook-social_plugins/add_to_timeline.rb",
33
+ "lib/facebook-social_plugins/button.rb",
34
+ "lib/facebook-social_plugins/comments.rb",
35
+ "lib/facebook-social_plugins/facepile.rb",
36
+ "lib/facebook-social_plugins/like_box.rb",
37
+ "lib/facebook-social_plugins/like_button.rb",
38
+ "lib/facebook-social_plugins/live_stream.rb",
39
+ "lib/facebook-social_plugins/login_button.rb",
40
+ "lib/facebook-social_plugins/rails/engine.rb",
41
+ "lib/facebook-social_plugins/recommendations_box.rb",
42
+ "lib/facebook-social_plugins/registration.rb",
43
+ "lib/facebook-social_plugins/script_helper.rb",
44
+ "lib/facebook-social_plugins/send_button.rb",
45
+ "lib/facebook-social_plugins/social_plugin.rb",
46
+ "lib/facebook-social_plugins/subscribe_button.rb",
47
+ "lib/facebook-social_plugins/ui_helper.rb",
48
+ "lib/facebook-social_plugins/view_helper.rb",
49
+ "spec/facebook-social_plugins/script_helper_spec.rb",
50
+ "spec/facebook-social_plugins/view_helper_spec.rb",
51
+ "spec/spec_helper.rb",
52
+ "vendor/assets/html/facebook_channel.html"
53
+ ]
54
+ s.homepage = "http://github.com/kristianmandrup/facebook-social_plugins"
55
+ s.licenses = ["MIT"]
56
+ s.require_paths = ["lib"]
57
+ s.rubygems_version = "1.8.20"
58
+ s.summary = "Facebook HTML5 style social plugins for Rails 3"
59
+
60
+ if s.respond_to? :specification_version then
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
+ s.add_development_dependency(%q<rails>, [">= 3"])
65
+ s.add_development_dependency(%q<rspec>, [">= 2"])
66
+ s.add_development_dependency(%q<rspec-rails>, [">= 2.5"])
67
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
68
+ s.add_development_dependency(%q<rdoc>, [">= 3.12"])
69
+ s.add_development_dependency(%q<bundler>, [">= 1.1.0"])
70
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
71
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
72
+ else
73
+ s.add_dependency(%q<rails>, [">= 3"])
74
+ s.add_dependency(%q<rspec>, [">= 2"])
75
+ s.add_dependency(%q<rspec-rails>, [">= 2.5"])
76
+ s.add_dependency(%q<shoulda>, [">= 0"])
77
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
78
+ s.add_dependency(%q<bundler>, [">= 1.1.0"])
79
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
80
+ s.add_dependency(%q<simplecov>, [">= 0"])
81
+ end
82
+ else
83
+ s.add_dependency(%q<rails>, [">= 3"])
84
+ s.add_dependency(%q<rspec>, [">= 2"])
85
+ s.add_dependency(%q<rspec-rails>, [">= 2.5"])
86
+ s.add_dependency(%q<shoulda>, [">= 0"])
87
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
88
+ s.add_dependency(%q<bundler>, [">= 1.1.0"])
89
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
90
+ s.add_dependency(%q<simplecov>, [">= 0"])
91
+ end
92
+ end
93
+
@@ -0,0 +1,22 @@
1
+ require 'facebook-social_plugins/button'
2
+
3
+ module FacebookSocialPlugins
4
+ def self.plugins
5
+ ['activity_feed', 'add_to_timeline', 'comments', 'facepile', 'like_box', 'like_button',
6
+ 'live_stream', 'login_button', 'recommendations_box', 'registration', 'send_button', 'subscribe_button']
7
+ end
8
+
9
+ def self.helpers
10
+ ['script', 'view']
11
+ end
12
+ end
13
+
14
+ FacebookSocialPlugins.plugins.each do |name|
15
+ require "facebook-social_plugins/#{name}"
16
+ end
17
+
18
+ FacebookSocialPlugins.helpers.each do |name|
19
+ require "facebook-social_plugins/#{name}_helper"
20
+ end
21
+
22
+ require 'facebook-social_plugins/rails/engine'
@@ -0,0 +1,35 @@
1
+ module FacebookSocialPlugins
2
+ class ActivityFeed < SocialPlugin
3
+ def initialize options = {}
4
+ super
5
+ end
6
+
7
+ def plugin_class
8
+ 'fb-activity'
9
+ end
10
+
11
+ # site - the domain for which to show activity; include just the full domain name, without http:// or a path. The XFBML version defaults to the current domain.
12
+ # action - a comma separated list of actions to show activities for.
13
+ # app_id - will display all actions, custom and global, associated with this app_id.
14
+ # width - the width of the plugin in pixels. Default width: 300px.
15
+ # height - the height of the plugin in pixels. Default height: 300px.
16
+ # header - specifies whether to show the Facebook header.
17
+ # colorscheme - the color scheme for the plugin. Options: 'light', 'dark'
18
+ # font - the font to display in the plugin. Options: 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
19
+ # border_color - the border color of the plugin.
20
+ # recommendations - specifies whether to always show recommendations in the plugin. If recommendations is set to true, the plugin will display recommendations in the bottom half.
21
+ # filter - allows you to filter which URLs are shown in the plugin. The plugin will only include URLs which contain the filter string in the first two path parameters of the URL. If nothing in the first two path parameters of the URL matches the filter, the URL will not be included. For example, if the 'site' parameter is set to 'www.example.com' and the 'filter' parameter was set to '/section1/section2' then only pages which matched 'http://www.example.com/section1/section2/*' would be included in the activity feed section of this plugin. The filter parameter does not apply to any recommendations which may appear in this plugin (see above); Recommendations are based only on 'site' parameter.
22
+ # linktarget - This specifies the context in which content links are opened. By default all links within the plugin will open a new window. If you want the content links to open in the same window, you can set this parameter to _top or _parent. Links to Facebook URLs will always open in a new window.
23
+ # ref - a label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_). Specifying a value for the ref attribute adds the 'fb_ref' parameter to the any links back to your site which are clicked from within the plugin. Using different values for the ref parameter for different positions and configurations of this plugin within your pages allows you to track which instances are performing the best.
24
+ # max_age - a limit on recommendation and creation time of articles that are surfaced in the plugins, the default is 0 (we don’t take age into account). Otherwise the valid values are 1-180, which specifies the number of days.
25
+
26
+ def attributes
27
+ super.merge(
28
+ :site => :string, :action => :array, :app_id => :string, :width => :integer, :height => :integer,
29
+ :header => :boolean, :colorscheme => ['light', 'dark'], :font => ['arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'],
30
+ :border_color => :string, :recommendations => :boolean, :filter => :string, :linktarget => ['_top', '_parent'],
31
+ :ref => :string, :max_age => :integer, :width => :integer
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ module FacebookSocialPlugins
2
+ # Also see AddToTimeline.txt of this gem for example of using OpenGraph with this feature.
3
+ class AddToTimeline < SocialPlugin
4
+ def initialize options = {}
5
+ super
6
+ end
7
+
8
+ def plugin_class
9
+ 'fb-add-to-timeline'
10
+ end
11
+
12
+ # mode - the display mode - box (default) and button
13
+ # show_faces - whether to show faces
14
+ def attributes
15
+ super.merge(:show_faces => :boolean, :mode => ['box', 'button'])
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'facebook-social_plugins/social_plugin'
2
+
3
+ module FacebookSocialPlugins
4
+ class Button < SocialPlugin
5
+ def initialize options = {}
6
+ super
7
+ end
8
+
9
+ def plugin_class
10
+ super
11
+ end
12
+
13
+ # attributes always availabe for a button?
14
+ def attributes
15
+ super.merge(:font => ['arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'], :colorscheme => ['light', 'dark'])
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module FacebookSocialPlugins
2
+ class Comments < SocialPlugin
3
+ def initialize options = {}
4
+ super
5
+ end
6
+
7
+ def plugin_class
8
+ 'fb-comments'
9
+ end
10
+
11
+ # href - the URL for this Comments plugin. News feed stories on Facebook will link to this URL.
12
+ # width - the width of the plugin in pixels. Minimum recommended width: 400px.
13
+ # colorscheme - the color scheme for the plugin. Options: 'light', 'dark'
14
+ # num_posts - the number of comments to show by default. Default: 10. Minimum: 1
15
+ # mobile - whether to show the mobile-optimized version. Default: auto-detect.
16
+ def attributes
17
+ super.merge(:href => :string, :num_posts => :integer, :mobile => :boolean, :width => :integer)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ module FacebookSocialPlugins
2
+
3
+ # The Facepile plugin displays the Facebook profile pictures of users who have connected with your
4
+ # page via a global or custom action, or can also be configured to display users that have
5
+ # signed up for your site.
6
+
7
+ # If you want to display users who have connected to your page via an action, specify with the action parameter
8
+
9
+ # <div class="fb-facepile" data-href="http://developers.facebook.com"
10
+ # data-action="join" data-size="large" data-max-rows="1" data-width="300"
11
+ # data-colorscheme="dark">
12
+ # </div>
13
+
14
+ # To display users who have liked your page, specify the URL of your page as the href parameter.
15
+ # To display users who have signed up for your site, specify your application id as the app_id
16
+
17
+ class Facepile < SocialPlugin
18
+ def initialize options = {}
19
+ super
20
+ end
21
+
22
+ def plugin_class
23
+ 'fb-facepile'
24
+ end
25
+
26
+ # event-app-id - the app id for the event
27
+ # action - the action to perform, fx 'og_recipebox:planning_to_make'
28
+ # width - the width of the plugin in pixels. Minimum recommended width: 400px.
29
+ # href - the referenced page
30
+ # max_rows - max rows to display, 1-10 normally
31
+ def attributes
32
+ super.merge(:'event-app-id' => :string, :action => :string, :href => :string,
33
+ :max_rows => :integer, :size => ['small', 'large'], :width => :integer
34
+ )
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ module FacebookSocialPlugins
2
+ class LikeBox < SocialPlugin
3
+ def initialize options = {}
4
+ super
5
+ end
6
+
7
+ def plugin_class
8
+ 'fb-like-box'
9
+ end
10
+
11
+ # href - the URL of the Facebook Page for this Like Box
12
+ # width - the width of the plugin in pixels. Default width: 300px.
13
+ # height - the height of the plugin in pixels. The default height varies based on number of faces to display, and whether the stream is displayed. With the stream displayed, and 10 faces the default height is 556px. With no faces, and no stream the default height is 63px.
14
+ # colorscheme - the color scheme for the plugin. Options: 'light', 'dark'
15
+ # show_faces - specifies whether or not to display profile photos in the plugin. Default value: true.
16
+ # stream - specifies whether to display a stream of the latest posts from the Page's wall
17
+ # header - specifies whether to display the Facebook header at the top of the plugin.
18
+ # border_color - the border color of the plugin.
19
+ # force_wall - for Places, specifies whether the stream contains posts from the Place's wall or just checkins from friends. Default value: false.
20
+
21
+ def attributes
22
+ super.merge(
23
+ :href => :string, :height => :integer, :stream => :boolean, :header => :string,
24
+ :show_faces => :boolean, :force_wall => :boolean, :width => :integer
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,51 @@
1
+ module FacebookSocialPlugins
2
+ class LikeButton < Button
3
+ def initialize options = {}
4
+ super
5
+ end
6
+
7
+ def plugin_class
8
+ 'fb-like'
9
+ end
10
+
11
+ # href - the URL to like. The XFBML version defaults to the current page.
12
+ # send - specifies whether to include a Send button with the Like button. This only works with the XFBML version.
13
+ # layout - there are three options.
14
+ # standard - displays social text to the right of the button and friends' profile photos below. Minimum width: 225 pixels. Minimum increases by 40px if action is 'recommend' by and increases by 60px if send is 'true'. Default width: 450 pixels. Height: 35 pixels (without photos) or 80 pixels (with photos).
15
+ # button_count - displays the total number of likes to the right of the button. Minimum width: 90 pixels. Default width: 90 pixels. Height: 20 pixels.
16
+ # box_count - displays the total number of likes above the button. Minimum width: 55 pixels. Default width: 55 pixels. Height: 65 pixels.
17
+ # show_faces - specifies whether to display profile photos below the button (standard layout only)
18
+ # width - the width of the Like button.
19
+ # action - the verb to display on the button. Options: 'like', 'recommend'
20
+ # font - the font to display in the button. Options: 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
21
+ # colorscheme - the color scheme for the like button. Options: 'light', 'dark'
22
+ # ref - a label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_). The ref attribute causes two parameters to be added to the referrer URL when a user clicks a link from a stream story about a Like action:
23
+ # fb_ref - the ref parameter
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
+ def attributes
26
+ super.merge(
27
+ :href => :string, :send => :boolean, :layout => ['standard', 'button_count', 'box_count'],
28
+ :show_faces => :boolean, :action => ['like', 'recommend'], :ref => :string,
29
+ :fb_ref => :string, :fb_source => :special, :width => :integer
30
+ )
31
+ end
32
+
33
+ def validate_fb_source value
34
+ raise ArgumentError, "The fb_source option must have a [stream type]_[story line] format, was #{value}" unless value =~ /\S+_\S+/
35
+
36
+ stream_type, story_line = value.split('_')
37
+ raise ArgumentError, "Not a valid stream type, must be one of #{stream_types}, was #{stream_type}" unless stream_types.include?(stream_type)
38
+ raise ArgumentError, "Not a valid story line, must be one of #{story_lines}, was #{story_line}" unless story_lines.include?(story_line)
39
+ end
40
+
41
+ private
42
+
43
+ def stream_types
44
+ ['home', 'profile', 'search', 'ticker', 'tickerdialog', 'other']
45
+ end
46
+
47
+ def story_lines
48
+ ['oneline', 'multiline']
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ module FacebookSocialPlugins
2
+ class LiveStream < SocialPlugin
3
+ def initialize options = {}
4
+ super
5
+ end
6
+
7
+ def plugin_class
8
+ 'fb-live-stream'
9
+ end
10
+
11
+ # event-app-id - the app id for the event
12
+ # width - the width of the plugin in pixels. Minimum recommended width: 400px.
13
+ # height - the height of the plugin in pixels. Minimum recommended height: 200px.
14
+ # always-post-to-friends - whether to always post to friend, default: false
15
+ def attributes
16
+ super.merge(:'via-url' => :string, :xid => :string, :'event-app-id' => :string,
17
+ :height => :integer, :'always-post-to-friends' => :boolean, :width => :integer)
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,26 @@
1
+ module FacebookSocialPlugins
2
+ # <div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>
3
+ class LoginButton < SocialPlugin
4
+ def initialize options = {}
5
+ super
6
+ end
7
+
8
+ def plugin_class
9
+ 'fb-login-button'
10
+ end
11
+
12
+ # show-faces - specifies whether to show faces underneath the Login button.
13
+ # width - the width of the plugin in pixels. Default width: 200px.
14
+ # max-rows - the maximum number of rows of profile pictures to display. Default value: 1.
15
+ # scope - a comma separated list of extended permissions.
16
+ # By default the Login button prompts users for their public information.
17
+ # If your application needs to access other parts of the user's profile that may be
18
+ # private, your application can request extended permissions.
19
+ def attributes
20
+ super.merge(:'show-faces' => :boolean, :'max-rows' => :integer, :scope => :array, :width => :integer)
21
+ end
22
+ end
23
+ end
24
+
25
+
26
+
@@ -0,0 +1,10 @@
1
+ module FacebookSocialPlugins
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer 'setup rails' do
5
+ ActionView::Base.send :include, FacebookSocialPlugins::ViewHelper
6
+ ActionView::Base.send :include, FacebookSocialPlugins::ScriptHelper
7
+ end
8
+ end
9
+ end
10
+ end