social-buttons 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 97d7309db2b66fdca5a1f62e24ebd8e0a2699a5b
4
+ data.tar.gz: 66e9765c95b5959a4286c08eb2012fe3a6188fa5
5
+ SHA512:
6
+ metadata.gz: 4fdc5f594c457da05e5d5e4a2d0ad850b04ba76d956108ce24ecb84579a86c1035c0c6af584c8c3f5eba64283e4a2ab7e18faed3d15f21fbb2a7a43036ef385d
7
+ data.tar.gz: f2d49c7261d60c82a658cf42ec1bcac736742d5129d295c61591d383f8bdfdf4cd03f41c478dafe474650eebed280cc7fc39230af945b92343cc2bd67ecfb058
@@ -5,4 +5,10 @@
5
5
  - Added Scripter for handling script logic
6
6
  - Ensure script is only output once for each request, but again for next request
7
7
  by moving state to instance level (fixes bug in 3.5)
8
- - Specs added to test if script works correctly on multiple requests
8
+ - Specs added to test if script works correctly on multiple requests
9
+
10
+ ### 0.3.9
11
+
12
+ -Bugs with google+ fixed
13
+ -Added locale changing to facebook button
14
+ -Added vk like button
data/README.md CHANGED
@@ -65,7 +65,7 @@ More information can be found from [Twitter](https://twitter.com/about/resources
65
65
  So, if you wanted to tweet about Hacker News, attribute it to Peter Cooper, and add some custom text, all from a tweet button with a horizontal counter, you'd do this:
66
66
 
67
67
  ```erb
68
- <%= tweet_button(via: => "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.") %>
68
+ <%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", text: "AWESOME.") %>
69
69
  ```
70
70
 
71
71
  ### Like Button
@@ -104,6 +104,19 @@ So, a simple pinit button can be added like this:
104
104
  <%= pinit_button(url: request.url, media: @picture.image.url, description: "Amazing Picture") %>
105
105
  ```
106
106
 
107
+ ### Vkontakte like button
108
+
109
+ Before using you should include in the head:
110
+ `<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript" charset="windows-1251"></script>`
111
+
112
+ * `:appId` - AppIp of your application or site
113
+ * `:type` - full, button, mini, vertical, vertical by default
114
+ * `:width` - only if full. Should be > 200
115
+ * `:height` - only 18, 20, 22, 24
116
+ * `:verb` - 0 or 1
117
+
118
+ See [Vk like](http://vk.com/pages?oid=-1&p=%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%86%D0%B8%D1%8F_%D0%BA_%D0%B2%D0%B8%D0%B4%D0%B6%D0%B5%D1%82%D1%83_%D0%9C%D0%BD%D0%B5_%D0%BD%D1%80%D0%B0%D0%B2%D0%B8%D1%82%D1%81%D1%8F) for more info
119
+
107
120
  ### Google Plus Button
108
121
 
109
122
  * `:href` - The URL to share; the default is the current URL.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.7
1
+ 0.3.9
@@ -1,6 +1,6 @@
1
1
  module SocialButtons
2
2
  def self.names
3
- %w{pinit tweet like google_plus}
3
+ %w{pinit tweet like google_plus vkontakte}
4
4
  end
5
5
 
6
6
  def self.helpers
@@ -26,4 +26,4 @@ module SocialButtons
26
26
  end
27
27
 
28
28
  require "social_buttons/view_helper"
29
- require "social_buttons/engine" if defined?(::Rails::Engine)
29
+ require "social_buttons/railtie" if defined?(Rails)
@@ -0,0 +1,7 @@
1
+ module SocialButtons
2
+ class Railtie < ::Rails::Railtie
3
+ initializer 'social buttons config' do
4
+ ActionView::Base.send :include, ViewHelper
5
+ end
6
+ end
7
+ end
@@ -47,14 +47,14 @@ module SocialButtons
47
47
  def script lang = nil
48
48
  return empty_content if widgetized? :google_plus
49
49
  widgetized! :google_plus
50
- %q{<script type="text/javascript">
51
- #{language lang}
52
- (function() {
53
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
54
- po.src = 'https://apis.google.com/js/plusone.js';
55
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
56
- })();
57
- </script>}.html_safe
50
+ ['<script type="text/javascript">',
51
+ " #{language lang} ",
52
+ '(function() {',
53
+ 'var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;',
54
+ 'po.src = \'https://apis.google.com/js/plusone.js\';',
55
+ 'var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);',
56
+ '})();',
57
+ '</script>'].join.html_safe
58
58
  end
59
59
 
60
60
  def language lang = nil
@@ -66,9 +66,9 @@ module SocialButtons
66
66
  class AsyncScripter < SocialButtons::Scripter
67
67
  # Place this tag in your head or just before your close body tag
68
68
  def script lang = nil
69
- %Q{<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
70
- #{language lang}
71
- </script>}
69
+ ['<script type="text/javascript" src="https://apis.google.com/js/plusone.js">',
70
+ "#{language lang}",
71
+ '</script>'].join.html_safe
72
72
  end
73
73
 
74
74
  def language lang = nil
@@ -11,7 +11,7 @@ module SocialButtons
11
11
 
12
12
  html = "".html_safe
13
13
  html << content_tag(:div, nil, id: "fb-root")
14
- html << clazz::Scripter.new(self).script(app_id)
14
+ html << clazz::Scripter.new(self).script(app_id, options)
15
15
  html << content_tag(:div, nil, params)
16
16
  html
17
17
  end
@@ -31,15 +31,19 @@ module SocialButtons
31
31
  end
32
32
 
33
33
  class Scripter < SocialButtons::Scripter
34
- def script(app_id)
34
+ def script(app_id, options = {})
35
35
  return empty_content if widgetized? :like
36
- widgetized! :like
37
- "<script src=#{js_sdk(app_id)} type='text/javascript'></script>".html_safe
36
+ widgetized! :like
37
+ [
38
+ "<script src=#{js_sdk options} type='text/javascript'></script>",
39
+ "<script>FB.init({ appId: '#{app_id}', status: true, cookie: true, xfbml: true });</script>",
40
+ ].join.html_safe
38
41
  end
39
42
 
40
- def js_sdk app_id
41
- "https://connect.facebook.net/en_US/all.js#xfbml=1&appId=#{app_id}"
43
+ def js_sdk options = {}
44
+ loc = options[:locale] || 'en_US'
45
+ "https://connect.facebook.net/" + loc + "/all.js"
42
46
  end
43
47
  end
44
48
  end
45
- end
49
+ end
@@ -42,8 +42,8 @@ module SocialButtons
42
42
  "<script src=#{twitter_wjs} type='text/javascript'></script>".html_safe
43
43
  end
44
44
 
45
- def twitter_wjs
46
- "http://platform.twitter.com/widgets.js"
45
+ def twitter_wjs
46
+ "https://platform.twitter.com/widgets.js"
47
47
  end
48
48
  end # class
49
49
  end
@@ -0,0 +1,43 @@
1
+ module SocialButtons
2
+ module Vkontakte
3
+ include SocialButtons::Assistant
4
+
5
+ def vkontakte_like appId, *args
6
+ clazz = SocialButtons::Vkontakte
7
+ options = args.extract_options!
8
+
9
+ clazz.default_options.each { |k,v| options[k] ||= v }
10
+
11
+ html = "".html_safe
12
+ html << clazz::Scripter.new(self).init_js(appId)
13
+ html << content_tag(:div, nil, id: "vk_like")
14
+ html << clazz::Scripter.new(self).script(options)
15
+ html
16
+ end
17
+
18
+ class << self
19
+ def default_options
20
+ @default_options ||= {
21
+ width: '350',
22
+ type: 'vertical',
23
+ verb: '0',
24
+ height: '22',
25
+ verb: '0'
26
+ }
27
+ end
28
+ end
29
+
30
+ class Scripter < SocialButtons::Scripter
31
+ def init_js appId
32
+ "<script type=\"text/javascript\"> VK.init({apiId: #{appId}, onlyWidgets: true}); </script>".html_safe
33
+ end
34
+ def script options = {}
35
+ [
36
+ "<script type=\"text/javascript\">",
37
+ "VK.Widgets.Like(\"vk_like\", { type: \"#{options[:type]}\", width: '#{options[:width]}', verb: '#{options[:verb] }'});",
38
+ "</script>"
39
+ ].join.html_safe
40
+ end
41
+ end
42
+ end
43
+ end
Binary file
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: social-buttons 0.3.9 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "social-buttons"
8
- s.version = "0.3.7"
9
+ s.version = "0.3.9"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Jeremy McAnally", "Yuva"]
12
- s.date = "2013-02-12"
14
+ s.date = "2014-05-17"
13
15
  s.description = "Generate Social Buttons for your Rails apps"
14
16
  s.email = "yuva@codemancers.com"
15
17
  s.extra_rdoc_files = [
@@ -29,6 +31,7 @@ Gem::Specification.new do |s|
29
31
  "lib/social-buttons.rb",
30
32
  "lib/social_buttons.rb",
31
33
  "lib/social_buttons/engine.rb",
34
+ "lib/social_buttons/railtie.rb",
32
35
  "lib/social_buttons/view_helper.rb",
33
36
  "lib/social_buttons/view_helpers/assistant.rb",
34
37
  "lib/social_buttons/view_helpers/google_plus.rb",
@@ -37,22 +40,24 @@ Gem::Specification.new do |s|
37
40
  "lib/social_buttons/view_helpers/pinit.rb",
38
41
  "lib/social_buttons/view_helpers/scripter.rb",
39
42
  "lib/social_buttons/view_helpers/tweet.rb",
43
+ "lib/social_buttons/view_helpers/vkontakte.rb",
44
+ "social-buttons-0.3.8.gem",
40
45
  "social-buttons.gemspec",
41
46
  "spec/social_buttons/config_spec.rb",
42
47
  "spec/social_buttons/google_plus_spec.rb",
43
48
  "spec/social_buttons/like_spec.rb",
44
49
  "spec/social_buttons/pinit_spec.rb",
45
50
  "spec/social_buttons/tweet_spec.rb",
51
+ "spec/social_buttons/vkontakte_spec.rb",
46
52
  "spec/spec_helper.rb",
47
53
  "spec/view_helper_config.rb"
48
54
  ]
49
55
  s.homepage = "https://github.com/iffyuva/social-buttons"
50
- s.require_paths = ["lib"]
51
- s.rubygems_version = "1.8.25"
56
+ s.rubygems_version = "2.2.2"
52
57
  s.summary = "Generate new Social Buttons"
53
58
 
54
59
  if s.respond_to? :specification_version then
55
- s.specification_version = 3
60
+ s.specification_version = 4
56
61
 
57
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
63
  s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
@@ -26,6 +26,10 @@ describe SocialButtons::ViewHelper do
26
26
  output = like_button('128085897213395', :width => '400')
27
27
  output.should_not match(/<script/)
28
28
  end
29
+ it "should print locale" do
30
+ output = like_button('128085897213395', { locale: 'ru_RU' })
31
+ output.should match(/\/ru_RU\//)
32
+ end
29
33
  end
30
34
 
31
35
  context 'with script - on next request' do
@@ -0,0 +1,29 @@
1
+ require 'view_helper_config'
2
+
3
+ describe SocialButtons::ViewHelper do
4
+ include ControllerTestHelpers, SocialButtons::ViewHelper
5
+ describe "vk like button" do
6
+ context 'with app_id' do
7
+ it "should require a Facebook app id" do
8
+ expect { vkontakte_like('4138567') }.not_to raise_error
9
+ end
10
+ it "should require a Facebook app id" do
11
+ expect { vkontakte_like() }.to raise_error
12
+ end
13
+ end
14
+
15
+ context 'with options' do
16
+ it "should set width using option" do
17
+ output = vkontakte_like('4138567', :width => '400')
18
+ output.should match(/width: '400'/)
19
+ output.should match(/<script/)
20
+ end
21
+ it "should print type" do
22
+ output = vkontakte_like('4138567', :type => 1 )
23
+ output.should match(/type: "1"/)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social-buttons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
5
- prerelease:
4
+ version: 0.3.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy McAnally
@@ -10,102 +9,90 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2014-05-17 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ">="
21
19
  - !ruby/object:Gem::Version
22
20
  version: 3.0.0
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ">="
29
26
  - !ruby/object:Gem::Version
30
27
  version: 3.0.0
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rspec
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: 2.8.0
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: 2.8.0
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rdoc
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: '3.12'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - ">="
61
54
  - !ruby/object:Gem::Version
62
55
  version: '3.12'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: bundler
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
62
  version: 1.0.0
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
69
  version: 1.0.0
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: jeweler
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ~>
74
+ - - "~>"
85
75
  - !ruby/object:Gem::Version
86
76
  version: 1.8.4
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ~>
81
+ - - "~>"
93
82
  - !ruby/object:Gem::Version
94
83
  version: 1.8.4
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: simplecov
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - ">="
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0.5'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - ">="
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0.5'
111
98
  description: Generate Social Buttons for your Rails apps
@@ -116,8 +103,8 @@ extra_rdoc_files:
116
103
  - LICENSE
117
104
  - README.md
118
105
  files:
119
- - .document
120
- - .rspec
106
+ - ".document"
107
+ - ".rspec"
121
108
  - CHANGELOG.md
122
109
  - Gemfile
123
110
  - Gemfile.lock
@@ -128,6 +115,7 @@ files:
128
115
  - lib/social-buttons.rb
129
116
  - lib/social_buttons.rb
130
117
  - lib/social_buttons/engine.rb
118
+ - lib/social_buttons/railtie.rb
131
119
  - lib/social_buttons/view_helper.rb
132
120
  - lib/social_buttons/view_helpers/assistant.rb
133
121
  - lib/social_buttons/view_helpers/google_plus.rb
@@ -136,36 +124,38 @@ files:
136
124
  - lib/social_buttons/view_helpers/pinit.rb
137
125
  - lib/social_buttons/view_helpers/scripter.rb
138
126
  - lib/social_buttons/view_helpers/tweet.rb
127
+ - lib/social_buttons/view_helpers/vkontakte.rb
128
+ - social-buttons-0.3.8.gem
139
129
  - social-buttons.gemspec
140
130
  - spec/social_buttons/config_spec.rb
141
131
  - spec/social_buttons/google_plus_spec.rb
142
132
  - spec/social_buttons/like_spec.rb
143
133
  - spec/social_buttons/pinit_spec.rb
144
134
  - spec/social_buttons/tweet_spec.rb
135
+ - spec/social_buttons/vkontakte_spec.rb
145
136
  - spec/spec_helper.rb
146
137
  - spec/view_helper_config.rb
147
138
  homepage: https://github.com/iffyuva/social-buttons
148
139
  licenses: []
140
+ metadata: {}
149
141
  post_install_message:
150
142
  rdoc_options: []
151
143
  require_paths:
152
144
  - lib
153
145
  required_ruby_version: !ruby/object:Gem::Requirement
154
- none: false
155
146
  requirements:
156
- - - ! '>='
147
+ - - ">="
157
148
  - !ruby/object:Gem::Version
158
149
  version: '0'
159
150
  required_rubygems_version: !ruby/object:Gem::Requirement
160
- none: false
161
151
  requirements:
162
- - - ! '>='
152
+ - - ">="
163
153
  - !ruby/object:Gem::Version
164
154
  version: '0'
165
155
  requirements: []
166
156
  rubyforge_project:
167
- rubygems_version: 1.8.25
157
+ rubygems_version: 2.2.2
168
158
  signing_key:
169
- specification_version: 3
159
+ specification_version: 4
170
160
  summary: Generate new Social Buttons
171
161
  test_files: []