facebook_share 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in facebook_share.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ facebook_share (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.2)
10
+ rspec (2.5.0)
11
+ rspec-core (~> 2.5.0)
12
+ rspec-expectations (~> 2.5.0)
13
+ rspec-mocks (~> 2.5.0)
14
+ rspec-core (2.5.1)
15
+ rspec-expectations (2.5.0)
16
+ diff-lcs (~> 1.1.2)
17
+ rspec-mocks (2.5.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ facebook_share!
24
+ rspec
@@ -0,0 +1,54 @@
1
+ # Facebook Share
2
+
3
+ This gem will add an easy-to-use Facebook Share button feature to your Rails project.
4
+
5
+ ## How To Install
6
+
7
+ This gem relies on jQuery, be sure to have it installed in your project. This gem does not depend on jquery-rails gem, because some projects use jQuery without it.
8
+
9
+ gem install facebook_share
10
+
11
+ then add
12
+
13
+ include FacebookShare
14
+
15
+ at the top of your ApplicationHelper
16
+
17
+ ## Examples
18
+
19
+ ###
20
+
21
+ ## Note on Patches/Pull Requests
22
+
23
+ * Fork the project.
24
+ * Create a feature branch
25
+ * Make your feature addition or bug fix.
26
+ * Add tests.
27
+ * Commit, do not mess with Rakefile, version, or history.
28
+ * Send me a pull request.
29
+
30
+ ## Copyright
31
+
32
+ Copyright (c) 2011 Mike Połtyn.
33
+
34
+ ## License
35
+
36
+ The MIT License
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining a copy
39
+ of this software and associated documentation files (the "Software"), to deal
40
+ in the Software without restriction, including without limitation the rights
41
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
42
+ copies of the Software, and to permit persons to whom the Software is
43
+ furnished to do so, subject to the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be included in
46
+ all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
49
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
50
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
51
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
52
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
53
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
54
+ THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => :spec
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "facebook_share/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "facebook_share"
7
+ s.version = FacebookShare::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Mike Połtyn"]
10
+ s.email = ["mike@poltyn.com"]
11
+ s.homepage = "http://github.com/Holek/facebook_share"
12
+ s.summary = %q{A Facebook Share button for convenient re-usage}
13
+ s.description = %q{A Facebook Share button for convenient re-usage}
14
+
15
+ s.add_development_dependency "rspec"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,49 @@
1
+ module FacebookShare
2
+
3
+ def facebook_share_once(app_id, params = {})
4
+ facebook_script_tags app_id, facebook_share('.fb_share', params)
5
+ end
6
+
7
+ def facebook_share(selector, params = {})
8
+ available_params = {
9
+ :display => "popup"
10
+ }.merge(params)
11
+
12
+ script = <<-JS
13
+ $("#{selector}").unbind("click.facebook_share").bind("click.facebook_share",function () {
14
+ FB.ui(
15
+ {
16
+ method: \'stream.publish\'
17
+ #{build_params(available_params)}
18
+ });
19
+ return false;
20
+ });
21
+ JS
22
+ script
23
+ end
24
+
25
+ def facebook_script_tags(app_id, initial_script = "")
26
+ script = <<-JS
27
+ <script type="text/javascript" src="https://connect.facebook.net/de_DE/all.js"></script>
28
+ <script type="text/javascript">
29
+ /* <![CDATA[ */
30
+ FB.init({appId:"#{app_id}", xfbml : true});
31
+ #{initial_script}
32
+ /* ]]> */
33
+ </script>
34
+ JS
35
+ script
36
+ end
37
+
38
+ private
39
+ def build_params(available_params)
40
+ script = ""
41
+ available_params.each do |key, value|
42
+ if value
43
+ value_sanitized = value.gsub(/"/, '\"')
44
+ script << ", #{key}: \"#{value_sanitized}\""
45
+ end
46
+ end
47
+ script
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module FacebookShare
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require "facebook_share"
5
+ require "rspec"
6
+
7
+ def fixture(file_name)
8
+ File.read(fixture_path(file_name))
9
+ end
10
+
11
+ def fixture_path(file_name)
12
+ File.expand_path(File.dirname(__FILE__)) + "/fixtures/#{file_name}"
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: facebook_share
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Mike Po\xC5\x82tyn"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-10 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: A Facebook Share button for convenient re-usage
36
+ email:
37
+ - mike@poltyn.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - Gemfile.lock
48
+ - README.md
49
+ - Rakefile
50
+ - facebook_share.gemspec
51
+ - lib/facebook_share.rb
52
+ - lib/facebook_share/version.rb
53
+ - spec/spec_helper.rb
54
+ has_rdoc: true
55
+ homepage: http://github.com/Holek/facebook_share
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: A Facebook Share button for convenient re-usage
88
+ test_files: []
89
+