sharing_tags 0.0.9 → 0.0.10

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +94 -0
  3. data/.travis.yml +1 -0
  4. data/Gemfile +2 -1
  5. data/Guardfile +21 -11
  6. data/README.md +8 -1
  7. data/Rakefile +16 -0
  8. data/Todo.md +4 -1
  9. data/app/assets/images/sharing_tags/icons/line.svg +9 -9
  10. data/app/assets/javascripts/sharing_tags.js +10 -0
  11. data/app/assets/javascripts/sharing_tags/init.js.coffee.erb +5 -4
  12. data/app/assets/javascripts/sharing_tags/links.js.coffee +9 -7
  13. data/app/assets/javascripts/sharing_tags/share.js.coffee +82 -62
  14. data/app/assets/javascripts/sharing_tags/share/callback.js.coffee +14 -0
  15. data/app/assets/javascripts/sharing_tags/share/facebook.js.coffee +82 -0
  16. data/app/assets/stylesheets/sharing_tags/wave_animation.css.sass +33 -0
  17. data/app/views/sharing_tags/meta/_open_graphs.html.slim +1 -1
  18. data/app/views/sharing_tags/meta/_twitter_card.html.slim +12 -9
  19. data/circle.yml +9 -0
  20. data/lib/generators/sharing_tags/install/install_generator.rb +12 -14
  21. data/lib/generators/sharing_tags/install/templates/initializer.rb +3 -0
  22. data/lib/sharing_tags.rb +0 -5
  23. data/lib/sharing_tags/action_controller/filters.rb +13 -10
  24. data/lib/sharing_tags/action_controller/helpers.rb +11 -9
  25. data/lib/sharing_tags/action_view/asset_helper.rb +39 -35
  26. data/lib/sharing_tags/action_view/button_helper.rb +62 -53
  27. data/lib/sharing_tags/action_view/meta_helper.rb +11 -8
  28. data/lib/sharing_tags/config.rb +3 -4
  29. data/lib/sharing_tags/configuration.rb +17 -18
  30. data/lib/sharing_tags/context.rb +11 -14
  31. data/lib/sharing_tags/engine.rb +11 -0
  32. data/lib/sharing_tags/network.rb +64 -30
  33. data/lib/sharing_tags/network/facebook.rb +11 -8
  34. data/lib/sharing_tags/railtie.rb +6 -9
  35. data/lib/sharing_tags/version.rb +1 -1
  36. data/sharing_tags.gemspec +1 -0
  37. data/spec/controllers/main_controller_spec.rb +2 -2
  38. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  39. data/spec/generators/install_generator_spec.rb +8 -6
  40. data/spec/helpers/asset_helper_spec.rb +3 -2
  41. data/spec/helpers/button_helper_spec.rb +70 -76
  42. data/spec/helpers/meta_tags_helper_spec.rb +1 -2
  43. data/spec/javascripts/fixtures/facebook.json +3 -1
  44. data/spec/javascripts/sharing_tags/share/{facebook_share_spec.coffee → facebook_spec.coffee} +73 -12
  45. data/spec/javascripts/sharing_tags/share/vkontakte_spec.coffee +29 -0
  46. data/spec/javascripts/sharing_tags/share_spec.coffee +193 -0
  47. data/spec/javascripts/sharing_tags/sharing_tags_spec.coffee +9 -14
  48. data/spec/models/configuration_spec.rb +12 -14
  49. data/spec/models/network_spec.rb +1 -4
  50. data/spec/models/running_in_context_spec.rb +19 -6
  51. data/spec/spec_helper.rb +1 -2
  52. data/spec/support/generator_support.rb +1 -3
  53. data/spec/teaspoon_env.rb +39 -39
  54. data/spec/views/meta_tags/facebook_meta_tags_erb_spec.rb +16 -17
  55. data/spec/views/meta_tags/meta_tags_erb_spec.rb +5 -7
  56. metadata +29 -13
  57. data/app/assets/javascripts/sharing_tags.js.coffee +0 -9
  58. data/app/assets/javascripts/sharing_tags/share/base.js.coffee +0 -38
  59. data/app/assets/javascripts/sharing_tags/share/facebook.coffee +0 -57
  60. data/app/assets/javascripts/sharing_tags/share/vkontakte.js.coffee +0 -13
  61. data/bin/rspec +0 -16
  62. data/spec/javascripts/sharing_tags/share/vkontakte_share_spec.coffee +0 -31
@@ -0,0 +1,29 @@
1
+ #=require sharing_tags/share
2
+
3
+ fixture.preload("vkontakte.json")
4
+
5
+ xdescribe "SharingTags.VkontakteShare", ->
6
+
7
+ # subject = SharingTags.VkontakteShare
8
+ #
9
+ # beforeEach ->
10
+ # @vk_fixture = fixture.load("vkontakte.json")[0]
11
+ #
12
+ # it "expect defined class", ->
13
+ # expect( SharingTags ).toBeDefined()
14
+ # expect( SharingTags.VkontakteShare ).toBeDefined()
15
+ #
16
+ # describe "#share", ->
17
+ # beforeEach ->
18
+ # @vk = @vk_fixture.full
19
+ # @share = new subject(@vk)
20
+ #
21
+ # it "expect open popup", ->
22
+ # spyOn(@share, "share_popup")
23
+ #
24
+ # @share.share()
25
+ # expect(@share.share_popup).toHaveBeenCalled()
26
+ # expect(@share.share_popup).toHaveBeenCalledWith(
27
+ # "http://vk.com/share.php",
28
+ # jasmine.objectContaining(url: @vk.url, image: @vk.image, title: @vk.title, description: @vk.description)
29
+ # )
@@ -0,0 +1,193 @@
1
+ #=require jquery
2
+ #=require sharing_tags/share
3
+
4
+ describe "SharingTags.Share", ->
5
+
6
+ subject = SharingTags.Share
7
+ subject_proto = subject.prototype
8
+
9
+ beforeEach ->
10
+ spyOn(subject, "share_popup").andCallThrough()
11
+ spyOn(subject_proto, "open_popup").andCallThrough()
12
+
13
+ describe "facebook", ->
14
+ share_prototype = SharingTags.FacebookShare.prototype
15
+
16
+ beforeEach ->
17
+ @fb_fixture = fixture.load("facebook.json")[0]
18
+ @fb = @fb_fixture.full
19
+ window.FB = jasmine.createSpyObj "FB", ['ui', 'init']
20
+
21
+ it "expect init new class with params", ->
22
+ spyOn(share_prototype, 'detect_provider').andCallThrough()
23
+ spyOn(share_prototype, 'share').andCallThrough()
24
+
25
+ @share = subject.facebook(@fb)
26
+ expect(share_prototype.detect_provider).toHaveBeenCalled()
27
+ expect(share_prototype.share).toHaveBeenCalled() # for this attributes
28
+
29
+ expect(@share.provider).toBe("dialog")
30
+ expect(@share.app_id).toBe(@fb.app_id)
31
+ expect(@share.url).toBe(@fb.url)
32
+ expect(@share.return_url).toBe(@fb.return_url)
33
+
34
+ it "expect call sharing method", ->
35
+ spyOn(share_prototype, "share")
36
+ @share = subject.facebook(@fb)
37
+ expect(share_prototype.share).toHaveBeenCalled()
38
+
39
+ describe "vkontakte", ->
40
+ beforeEach ->
41
+ @fixture = fixture.load("vkontakte.json")[0]
42
+ @f = @fixture.full
43
+
44
+ @share = subject.vkontakte(@f)
45
+
46
+ it "expect valid open popup url", ->
47
+ expect(subject.share_popup).toHaveBeenCalled()
48
+
49
+ api_url = "http://vk.com/share.php"
50
+ params = {
51
+ url: @f.url,
52
+ title: @f.title,
53
+ description: @f.description,
54
+ image: @f.image
55
+ }
56
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
57
+ api_url, jasmine.objectContaining(params)
58
+ )
59
+
60
+ it "expect init new class with params", ->
61
+ expect(@share.network).toBe("vkontakte")
62
+ expect(@share.url).toBe(@f.url)
63
+
64
+ describe "twitter", ->
65
+ beforeEach ->
66
+ @fixture = fixture.load("vkontakte.json")[0]
67
+ @f = @fixture.full
68
+
69
+ @share = subject.twitter(@f)
70
+
71
+ it "expect valid open popup url", ->
72
+ expect(subject.share_popup).toHaveBeenCalled()
73
+
74
+ api_url = "http://twitter.com/intent/tweet"
75
+ params = {
76
+ url: @f.url
77
+ text: @f.title
78
+ }
79
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
80
+ api_url, jasmine.objectContaining(params)
81
+ )
82
+
83
+ it "expect init new class with params", ->
84
+ expect(@share.network).toBe("twitter")
85
+ expect(@share.url).toBe(@f.url)
86
+ # expect(@share.title).toBe(@f.title)
87
+
88
+ describe "google", ->
89
+ beforeEach ->
90
+ @fixture = fixture.load("vkontakte.json")[0]
91
+ @f = @fixture.full
92
+
93
+ @share = subject.google(@f)
94
+
95
+ it "expect valid open popup url", ->
96
+ expect(subject.share_popup).toHaveBeenCalled()
97
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
98
+ "https://plus.google.com/share",
99
+ url: @f.url
100
+ )
101
+
102
+ it "expect init new class with params", ->
103
+ expect(@share.network).toBe("google")
104
+ expect(@share.url).toBe(@f.url)
105
+
106
+ describe "odnoklassniki", ->
107
+ beforeEach ->
108
+ @fixture = fixture.load("vkontakte.json")[0]
109
+ @f = @fixture.full
110
+
111
+ @share = subject.odnoklassniki(@f)
112
+
113
+ it "expect valid open popup url and params", ->
114
+ expect(subject.share_popup).toHaveBeenCalled()
115
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
116
+ "http://www.odnoklassniki.ru/dk",
117
+ jasmine.objectContaining
118
+ 'st._surl': @f.url
119
+ 'st.comments': @f.description
120
+ 'st.cmd': 'addShare'
121
+ 'st.s': 1
122
+ )
123
+
124
+ it "expect init new class with params", ->
125
+ expect(@share.network).toBe("odnoklassniki")
126
+ expect(@share.url).toBe(@f.url)
127
+
128
+ describe "mailru", ->
129
+ beforeEach ->
130
+ @fixture = fixture.load("vkontakte.json")[0]
131
+ @f = @fixture.full
132
+
133
+ @share = subject.mailru(@f)
134
+
135
+ it "expect valid open popup url", ->
136
+ expect(subject.share_popup).toHaveBeenCalled()
137
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
138
+ "http://connect.mail.ru/share",
139
+ jasmine.objectContaining
140
+ url: @f.url
141
+ title: @f.title
142
+ description: @f.description
143
+ imageurl: @f.image
144
+ )
145
+
146
+ it "expect init new class with params", ->
147
+ expect(@share.network).toBe("mailru")
148
+ expect(@share.url).toBe(@f.url)
149
+
150
+ describe "linkedin", ->
151
+ beforeEach ->
152
+ @fixture = fixture.load("vkontakte.json")[0]
153
+ @f = @fixture.full
154
+
155
+ @share = subject.linkedin(@f)
156
+
157
+ it "expect valid open popup url", ->
158
+ expect(subject.share_popup).toHaveBeenCalled()
159
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
160
+ "http://www.linkedin.com/shareArticle",
161
+ jasmine.objectContaining
162
+ url: @f.url
163
+ title: @f.title
164
+ summary: @f.description
165
+ mini: true
166
+ )
167
+
168
+ it "expect init new class with params", ->
169
+ expect(@share.network).toBe("linkedin")
170
+ expect(@share.url).toBe(@f.url)
171
+
172
+ describe "line", ->
173
+ beforeEach ->
174
+ @fixture = fixture.load("vkontakte.json")[0]
175
+ @f = @fixture.full
176
+
177
+ @share = subject.line(@f)
178
+
179
+ it "expect valid open popup url", ->
180
+ message = "#{@f.title} #{@f.url}"
181
+ expect(subject.share_popup).toHaveBeenCalled()
182
+ expect(subject_proto.open_popup).toHaveBeenCalledWith(
183
+ "http://line.me/R/msg/text/?#{encodeURIComponent(message)}",
184
+ null
185
+ )
186
+
187
+ it "expect init new class with params", ->
188
+ expect(@share.network).toBe("line")
189
+ expect(@share.url).toBe(@f.url)
190
+
191
+
192
+ xdescribe "#_open_popup_check"
193
+ xdescribe "#open_popup"
@@ -1,32 +1,27 @@
1
1
  #=require jquery
2
2
  #=require sharing_tags/share
3
3
 
4
- describe "Sharing Tags", ->
4
+ describe "SharingTags.share", ->
5
5
 
6
6
  it "expect defined class", ->
7
7
  expect( SharingTags ).toBeDefined()
8
8
  expect( SharingTags.share ).toBeDefined()
9
9
 
10
10
  describe ".share", ->
11
- beforeEach ->
12
11
 
13
12
  describe "facebook", ->
14
13
  beforeEach ->
15
14
  spyOn(SharingTags.Share, "facebook")
16
- spyOn(SharingTags.MobileShare, "facebook")
17
15
 
18
- it "expect mobile version", ->
19
- SharingTags.share('facebook', mobile: true, url: "url")
20
- expect(SharingTags.MobileShare.facebook).toHaveBeenCalled()
21
-
22
- it "expect desktop version", ->
16
+ it "expect calling", ->
23
17
  SharingTags.share('facebook')
24
18
  expect(SharingTags.Share.facebook).toHaveBeenCalled()
25
19
 
26
- # it "vkontakte"
27
- # it "twitter"
28
- # it "google"
29
- # it "odnoklassniki"
30
- # it "mailru"
31
- # it "linkedin"
20
+ describe "vkontakte", ->
21
+ beforeEach ->
22
+ spyOn(SharingTags.Share, "vkontakte")
23
+
24
+ it "expect desktop version", ->
25
+ SharingTags.share('vkontakte')
26
+ expect(SharingTags.Share.vkontakte).toHaveBeenCalled()
32
27
 
@@ -9,8 +9,8 @@ describe SharingTags::Configuration do
9
9
  describe "constants" do
10
10
 
11
11
  it "expect NETWORKS" do
12
- #expect(SharingTags::Configuration).to be_include(:twitter)
13
- #expect(SharingTags::Configuration).to has_include(:facebook)
12
+ # expect(SharingTags::Configuration).to be_include(:twitter)
13
+ # expect(SharingTags::Configuration).to has_include(:facebook)
14
14
  end
15
15
 
16
16
  it "expect defined version" do
@@ -100,7 +100,7 @@ describe SharingTags::Configuration do
100
100
  describe "define utm params" do
101
101
  before do
102
102
  SharingTags.configure do
103
- share_url "http:://example.com"
103
+ share_url "http://example.com"
104
104
 
105
105
  google do
106
106
  link_params utm_source: "google_source", utm_medium: "google_medium", utm_content: "google_content",
@@ -113,7 +113,7 @@ describe SharingTags::Configuration do
113
113
  end
114
114
 
115
115
  twitter do
116
- share_url "http:://for_twitter.com"
116
+ share_url "http://for_twitter.com"
117
117
 
118
118
  link_params utm_source: "twitter_source", utm_medium: "twitter_medium"
119
119
  end
@@ -123,7 +123,7 @@ describe SharingTags::Configuration do
123
123
  it "expect add utm params to facebook share_url" do
124
124
  facebook_config = subject.facebook
125
125
  expect(facebook_config).to be_truthy
126
- expect(facebook_config.share_url).to be_include("http:://example.com")
126
+ expect(facebook_config.share_url).to be_include("http://example.com")
127
127
  expect(facebook_config.share_url).to be_include("utm_campaign=facebook_campaign")
128
128
  expect(facebook_config.share_url).to be_include("utm_source=facebook_source")
129
129
  expect(facebook_config.share_url).to be_include("marker=facebook_marker")
@@ -135,7 +135,7 @@ describe SharingTags::Configuration do
135
135
  it "expect add utm params to google share_url" do
136
136
  google_config = subject.google
137
137
  expect(google_config).to be_truthy
138
- expect(google_config.share_url).to be_include("http:://example.com")
138
+ expect(google_config.share_url).to be_include("http://example.com")
139
139
  expect(google_config.share_url).to be_include("utm_campaign=google_campaign")
140
140
  expect(google_config.share_url).to be_include("utm_source=google_source")
141
141
 
@@ -148,7 +148,7 @@ describe SharingTags::Configuration do
148
148
  it "expect add utm params to twitter share_url" do
149
149
  twitter_config = subject.twitter
150
150
  expect(twitter_config).to be_truthy
151
- expect(twitter_config.share_url).to be_include("http:://for_twitter.com")
151
+ expect(twitter_config.share_url).to be_include("http://for_twitter.com")
152
152
  expect(twitter_config.share_url).to be_include("utm_source=twitter_source")
153
153
  expect(twitter_config.share_url).to be_include("utm_medium=twitter_medium")
154
154
 
@@ -164,17 +164,15 @@ describe SharingTags::Configuration do
164
164
  SharingTags.configure do
165
165
  facebook do
166
166
  app_id "APP ID"
167
+ provider "sharer"
167
168
  end
168
169
  end
169
170
  end
170
171
 
171
- describe "switch context to photo" do
172
-
173
- it "expect new context data" do
174
- expect(subject[:facebook][:app_id]).to be == "APP ID"
175
- end
172
+ it "expect get app id" do
173
+ expect(subject.facebook.app_id).to be == "APP ID"
174
+ expect(subject.facebook.provider).to be == "sharer"
176
175
  end
177
- end
178
-
179
176
 
177
+ end
180
178
  end
@@ -1,5 +1,4 @@
1
1
  module SharingTags
2
-
3
2
  describe Network do
4
3
  let!(:config) { Configuration.new }
5
4
  let!(:context) { Context.new(:test, config) }
@@ -34,7 +33,7 @@ module SharingTags
34
33
  config.running_context = running_class_context.new
35
34
  end
36
35
 
37
- subject { network.attributes_for.image}
36
+ subject { network.attributes_for.image }
38
37
 
39
38
  it "add network image through asset_url " do
40
39
  network.image "sharing/image.png"
@@ -81,9 +80,7 @@ module SharingTags
81
80
  expect(network.attributes_for.image_content_type).to be_nil
82
81
  end
83
82
  end
84
-
85
83
  end
86
84
 
87
85
  end
88
-
89
86
  end
@@ -2,6 +2,7 @@ describe SharingTags::Configuration do
2
2
  before do
3
3
  SharingTags.configure do
4
4
  page_url { root_url }
5
+ link_params { {utm_source: "#{network}_source", utm_campaign: "#{network}_#{context}"} }
5
6
 
6
7
  twitter do
7
8
  title { awesome_title }
@@ -18,7 +19,7 @@ describe SharingTags::Configuration do
18
19
  let(:running_context) do
19
20
  Class.new do
20
21
  def root_url
21
- "context url"
22
+ "http://example.com"
22
23
  end
23
24
 
24
25
  def awesome_title
@@ -31,11 +32,18 @@ describe SharingTags::Configuration do
31
32
 
32
33
  describe "default context" do
33
34
  it "expect get twitter title from calling in running_context" do
34
- expect(params.twitter.page_url).to eql("context url")
35
+ expect(params.twitter.title).to eql("All you need is love")
35
36
  end
36
37
 
37
38
  it "expect get page_url from calling in running_context" do
38
- expect(params.twitter.title).to eql("All you need is love")
39
+ expect(params.twitter.page_url).to eql("http://example.com")
40
+ end
41
+
42
+ xit "expect get share_url with assigned network name params" do
43
+ expect(params.twitter.share_url).to include("http://example.com")
44
+ expect(params.twitter.share_url).to include("utm_source=twitter_source")
45
+ expect(params.twitter.share_url).to include("utm_campaign=twitter_default")
46
+ expect(params.twitter.share_url).to include("utm_campaign").once
39
47
  end
40
48
  end
41
49
 
@@ -49,9 +57,14 @@ describe SharingTags::Configuration do
49
57
  end
50
58
 
51
59
  it "expect get twitter title from calling in running_context" do
52
- expect(params.twitter.page_url).to eql("context url")
60
+ expect(params.twitter.page_url).to eql("http://example.com")
53
61
  end
54
- end
55
-
56
62
 
63
+ xit "expect get share_url with assigned network name params" do
64
+ expect(params.twitter.share_url).to include("http://example.com")
65
+ expect(params.twitter.share_url).to include("utm_source=twitter_source")
66
+ expect(params.twitter.share_url).to include("utm_campaign=twitter_copyright")
67
+ expect(params.twitter.share_url).to include("utm_campaign").once
68
+ end
69
+ end
57
70
  end
@@ -7,7 +7,7 @@ require 'ammeter/init'
7
7
  require 'slim'
8
8
  require 'rspec/support/spec'
9
9
 
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
11
 
12
12
  if ENV['CODECLIMATE_REPO_TOKEN']
13
13
  require 'codeclimate-test-reporter'
@@ -37,5 +37,4 @@ RSpec.configure do |config|
37
37
  mocks.syntax = :expect
38
38
  mocks.verify_partial_doubles = true
39
39
  end
40
-
41
40
  end
@@ -1,5 +1,4 @@
1
1
  module GeneratorSupport
2
-
3
2
  def create_file(file_path, content = '')
4
3
  full_file_path = File.expand_path(file_path, destination_root)
5
4
  FileUtils.mkdir_p File.dirname(full_file_path)
@@ -20,5 +19,4 @@ module GeneratorSupport
20
19
  def content_for(file_name)
21
20
  File.read(file(file_name))
22
21
  end
23
-
24
- end
22
+ end