sharing_tags 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -22,7 +22,7 @@ Teaspoon.configure do |config|
22
22
 
23
23
  # Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in these paths will
24
24
  # be rendered as fixtures.
25
- #config.fixture_paths = ["spec/javascripts/fixtures"]
25
+ # config.fixture_paths = ["spec/javascripts/fixtures"]
26
26
 
27
27
  # SUITES
28
28
  #
@@ -47,52 +47,52 @@ Teaspoon.configure do |config|
47
47
 
48
48
  # Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These
49
49
  # files need to be within an asset path. You can add asset paths using the `config.asset_paths`.
50
- #suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
50
+ # suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
51
51
 
52
52
  # This suites spec helper, which can require additional support files. This file is loaded before any of your test
53
53
  # files are loaded.
54
- #suite.helper = "spec_helper"
54
+ # suite.helper = "spec_helper"
55
55
 
56
56
  # The core Teaspoon javascripts. It's recommended to include only the base files here, as you can require support
57
57
  # libraries from your spec helper.
58
58
  # Note: For CoffeeScript files use `"teaspoon/jasmine"` etc.
59
59
  #
60
60
  # Available: teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit
61
- #suite.javascripts = ["jasmine/1.3.1", "teaspoon-jasmine"]
61
+ # suite.javascripts = ["jasmine/1.3.1", "teaspoon-jasmine"]
62
62
 
63
63
  # You can include your own stylesheets if you want to change how Teaspoon looks.
64
64
  # Note: Spec related CSS can and should be loaded using fixtures.
65
- #suite.stylesheets = ["teaspoon"]
65
+ # suite.stylesheets = ["teaspoon"]
66
66
 
67
67
  # Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating
68
68
  # a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.
69
69
  #
70
70
  # Available: boot, boot_require_js
71
- #suite.boot_partial = "boot"
71
+ # suite.boot_partial = "boot"
72
72
 
73
73
  # Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure.
74
- #suite.body_partial = "body"
74
+ # suite.body_partial = "body"
75
75
 
76
76
  # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
77
77
  # default excludes assets from vendor, gems and support libraries.<br/><br/>
78
- #suite.no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
78
+ # suite.no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
79
79
 
80
80
  # Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a
81
81
  # synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name.
82
- #suite.hook :fixtures, proc{ }
82
+ # suite.hook :fixtures, proc{ }
83
83
 
84
84
  # Determine whether specs loaded into the test harness should be embedded as individual script tags or concatenated
85
85
  # into a single file. Similar to Rails' asset `debug: true` and `config.assets.debug = true` options. By default,
86
86
  # Teaspoon expands all assets to provide more valuable stack traces that reference individual source files.
87
- #suite.expand_assets = false
87
+ # suite.expand_assets = false
88
88
 
89
89
  end
90
90
 
91
91
  # Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also
92
92
  # be run in the default suite -- but can be focused into a more specific suite.
93
- #config.suite :targeted do |suite|
94
- # suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}"
95
- #end
93
+ # config.suite :targeted do |suite|
94
+ # suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}"
95
+ # end
96
96
 
97
97
  # CONSOLE RUNNER SPECIFIC
98
98
  #
@@ -111,44 +111,44 @@ Teaspoon.configure do |config|
111
111
  # Available: phantomjs, selenium
112
112
  # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
113
113
  # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
114
- #config.driver = "phantomjs"
114
+ # config.driver = "phantomjs"
115
115
 
116
116
  # Specify additional options for the driver.
117
117
  #
118
118
  # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
119
119
  # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
120
- #config.driver_options = nil
120
+ # config.driver_options = nil
121
121
 
122
122
  # Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be
123
123
  # considered a failure. This is to avoid issues that can arise where tests stall.
124
- #config.driver_timeout = 180
124
+ # config.driver_timeout = 180
125
125
 
126
126
  # Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.
127
- #config.server = nil
127
+ # config.server = nil
128
128
 
129
129
  # Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.
130
- #config.server_port = nil
130
+ # config.server_port = nil
131
131
 
132
132
  # Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may
133
133
  # want to lower this if you know it shouldn't take long to start.
134
- #config.server_timeout = 20
134
+ # config.server_timeout = 20
135
135
 
136
136
  # Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have
137
137
  # several suites, but in environments like CI this may not be desirable.
138
- #config.fail_fast = true
138
+ # config.fail_fast = true
139
139
 
140
140
  # Specify the formatters to use when outputting the results.
141
141
  # Note: Output files can be specified by using `"junit>/path/to/output.xml"`.
142
142
  #
143
143
  # Available: clean, documentation, dot, json, junit, pride, rspec_html, snowday, swayze_or_oprah, tap, tap_y, teamcity
144
- #config.formatters = ["dot"]
144
+ # config.formatters = ["dot"]
145
145
 
146
146
  # Specify if you want color output from the formatters.
147
- #config.color = true
147
+ # config.color = true
148
148
 
149
149
  # Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to
150
150
  # remove them, but in verbose applications this may not be desirable.
151
- #config.suppress_log = false
151
+ # config.suppress_log = false
152
152
 
153
153
  # COVERAGE REPORTS / THRESHOLD ASSERTIONS
154
154
  #
@@ -163,26 +163,26 @@ Teaspoon.configure do |config|
163
163
  # - with the cli: teaspoon --coverage=[coverage_name]
164
164
 
165
165
  # Specify that you always want a coverage configuration to be used.
166
- #config.use_coverage = nil
166
+ # config.use_coverage = nil
167
167
 
168
- config.coverage do |coverage|
168
+ # config.coverage do |coverage|
169
169
 
170
- # Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.
171
- #
172
- # Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
173
- # coverage.reports = ["text-summary", "html"]
170
+ # # Which coverage reports Istanbul should generate. Correlates directly to what Istanbul supports.
171
+ # #
172
+ # # Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
173
+ # # coverage.reports = ["text-summary", "html"]
174
174
 
175
- # The path that the coverage should be written to - when there's an artifact to write to disk.
176
- # Note: Relative to `config.root`.
177
- #coverage.output_path = "coverage"
175
+ # # The path that the coverage should be written to - when there's an artifact to write to disk.
176
+ # # Note: Relative to `config.root`.
177
+ # # coverage.output_path = "coverage"
178
178
 
179
- # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
180
- # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
181
- #coverage.statements = nil
182
- #coverage.functions = nil
183
- #coverage.branches = nil
184
- #coverage.lines = nil
179
+ # # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
180
+ # # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
181
+ # # coverage.statements = nil
182
+ # # coverage.functions = nil
183
+ # # coverage.branches = nil
184
+ # # coverage.lines = nil
185
185
 
186
- end
186
+ # end
187
187
 
188
188
  end
@@ -1,5 +1,5 @@
1
1
 
2
- RSpec.describe "sharing_tags/meta_tags", :type => :view do
2
+ RSpec.describe "sharing_tags/meta_tags", type: :view do
3
3
 
4
4
  context "constant params" do
5
5
  before do
@@ -20,14 +20,14 @@ RSpec.describe "sharing_tags/meta_tags", :type => :view do
20
20
 
21
21
  it "render image size tags" do
22
22
  render
23
- expect(rendered).to have_tag "meta", with: {property: "og:title", content: "Facebook title"}
24
- expect(rendered).to have_tag "meta", with: {property: "og:description", content: "Facebook description"}
25
- expect(rendered).to have_tag "meta", with: {property: "og:image", content: "http://img.jpg"}
26
- expect(rendered).to have_tag "meta", with: {property: "og:image:type", content: "image/jpeg"}
27
- expect(rendered).to have_tag "meta", with: {property: "og:image:width", content: "100"}
28
- expect(rendered).to have_tag "meta", with: {property: "og:image:height",content: "200"}
29
- expect(rendered).to have_tag "meta", with: {property: "og:url", content: "http://a.b"}
30
- expect(rendered).to have_tag "meta", with: {property: "fb:app_id", content: "12345"}
23
+ expect(rendered).to have_tag "meta", with: {property: "og:title", content: "Facebook title"}
24
+ expect(rendered).to have_tag "meta", with: {property: "og:description", content: "Facebook description"}
25
+ expect(rendered).to have_tag "meta", with: {property: "og:image", content: "http://img.jpg"}
26
+ expect(rendered).to have_tag "meta", with: {property: "og:image:type", content: "image/jpeg"}
27
+ expect(rendered).to have_tag "meta", with: {property: "og:image:width", content: "100"}
28
+ expect(rendered).to have_tag "meta", with: {property: "og:image:height", content: "200"}
29
+ expect(rendered).to have_tag "meta", with: {property: "og:url", content: "http://a.b"}
30
+ expect(rendered).to have_tag "meta", with: {property: "fb:app_id", content: "12345"}
31
31
  end
32
32
  end
33
33
 
@@ -49,14 +49,13 @@ RSpec.describe "sharing_tags/meta_tags", :type => :view do
49
49
 
50
50
  it "render image size tags" do
51
51
  render
52
- expect(rendered).to have_tag "meta", with: {property: "og:title", content: "Facebook title"}
53
- expect(rendered).to have_tag "meta", with: {property: "og:description", content: "Facebook description"}
54
- expect(rendered).to have_tag "meta", with: {property: "og:image", content: "http://img.jpg"}
55
- expect(rendered).to have_tag "meta", with: {property: "og:image:type", content: "image/jpeg"}
56
- expect(rendered).to have_tag "meta", with: {property: "og:image:width", content: "100"}
57
- expect(rendered).to have_tag "meta", with: {property: "og:image:height",content: "200"}
58
- expect(rendered).to have_tag "meta", with: {property: "og:url", content: "http://a.b"}
52
+ expect(rendered).to have_tag "meta", with: {property: "og:title", content: "Facebook title"}
53
+ expect(rendered).to have_tag "meta", with: {property: "og:description", content: "Facebook description"}
54
+ expect(rendered).to have_tag "meta", with: {property: "og:image", content: "http://img.jpg"}
55
+ expect(rendered).to have_tag "meta", with: {property: "og:image:type", content: "image/jpeg"}
56
+ expect(rendered).to have_tag "meta", with: {property: "og:image:width", content: "100"}
57
+ expect(rendered).to have_tag "meta", with: {property: "og:image:height", content: "200"}
58
+ expect(rendered).to have_tag "meta", with: {property: "og:url", content: "http://a.b"}
59
59
  end
60
60
  end
61
-
62
61
  end
@@ -1,4 +1,4 @@
1
- RSpec.describe "sharing_tags/meta_tags", :type => :view do
1
+ RSpec.describe "sharing_tags/meta_tags", type: :view do
2
2
 
3
3
  before do
4
4
  controller.append_view_path 'app/views'
@@ -48,10 +48,10 @@ RSpec.describe "sharing_tags/meta_tags", :type => :view do
48
48
  it "render twitter card tags" do
49
49
  render
50
50
 
51
- expect(rendered).to have_tag "meta", with: {name: "twitter:card", content: "summary"}
51
+ expect(rendered).to have_tag "meta", with: {name: "twitter:card", content: "summary"}
52
52
  # expect(rendered).to have_tag "meta", with: {name: "twitter:site", content: ""}
53
- expect(rendered).to have_tag "meta", with: {name: "twitter:title", content: "Twitter title"}
54
- expect(rendered).to have_tag "meta", with: {name: "twitter:description",content: "Twitter description"}
53
+ expect(rendered).to have_tag "meta", with: {name: "twitter:title", content: "Twitter title"}
54
+ expect(rendered).to have_tag "meta", with: {name: "twitter:description", content: "Twitter description"}
55
55
  # expect(rendered).to have_tag "meta", with: {name: "twitter:creator", content: ""}
56
56
  # expect(rendered).to have_tag "meta", with: {name: "twitter:image:src", content: ""}
57
57
  # expect(rendered).to have_tag "meta", with: {name: "twitter:domain", content: ""}
@@ -62,6 +62,4 @@ RSpec.describe "sharing_tags/meta_tags", :type => :view do
62
62
  render
63
63
  expect(rendered).to_not have_tag('meta')
64
64
  end
65
-
66
-
67
- end
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sharing_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Kovalchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0.8'
265
+ - !ruby/object:Gem::Dependency
266
+ name: guard-rubocop
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: 1.2.0
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: 1.2.0
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: sqlite3
267
281
  requirement: !ruby/object:Gem::Requirement
@@ -294,14 +308,14 @@ description: " Describe your sharing information for different contexts in one s
294
308
  configuration file. "
295
309
  email:
296
310
  - kr00lix@gmail.com
297
- executables:
298
- - rspec
311
+ executables: []
299
312
  extensions: []
300
313
  extra_rdoc_files: []
301
314
  files:
302
315
  - ".coveralls.yml"
303
316
  - ".gitignore"
304
317
  - ".rspec"
318
+ - ".rubocop.yml"
305
319
  - ".travis.yml"
306
320
  - Gemfile
307
321
  - Guardfile
@@ -316,15 +330,15 @@ files:
316
330
  - app/assets/images/sharing_tags/icons/odnoklassniki.svg
317
331
  - app/assets/images/sharing_tags/icons/twitter.svg
318
332
  - app/assets/images/sharing_tags/icons/vkontakte.svg
319
- - app/assets/javascripts/sharing_tags.js.coffee
333
+ - app/assets/javascripts/sharing_tags.js
320
334
  - app/assets/javascripts/sharing_tags/init.js.coffee.erb
321
335
  - app/assets/javascripts/sharing_tags/links.js.coffee
322
336
  - app/assets/javascripts/sharing_tags/share.js.coffee
323
- - app/assets/javascripts/sharing_tags/share/base.js.coffee
324
- - app/assets/javascripts/sharing_tags/share/facebook.coffee
325
- - app/assets/javascripts/sharing_tags/share/vkontakte.js.coffee
337
+ - app/assets/javascripts/sharing_tags/share/callback.js.coffee
338
+ - app/assets/javascripts/sharing_tags/share/facebook.js.coffee
326
339
  - app/assets/stylesheets/sharing_tags.css.sass
327
340
  - app/assets/stylesheets/sharing_tags/icons.css.sass
341
+ - app/assets/stylesheets/sharing_tags/wave_animation.css.sass
328
342
  - app/views/sharing_tags/button/_facebook.html.slim
329
343
  - app/views/sharing_tags/button/_google.html.slim
330
344
  - app/views/sharing_tags/button/_line.html.slim
@@ -337,7 +351,7 @@ files:
337
351
  - app/views/sharing_tags/meta/_schema_tags.html.slim
338
352
  - app/views/sharing_tags/meta/_twitter_card.html.slim
339
353
  - app/views/sharing_tags/meta_tags.html.slim
340
- - bin/rspec
354
+ - circle.yml
341
355
  - lib/generators/sharing_tags/install/install_generator.rb
342
356
  - lib/generators/sharing_tags/install/templates/POST_INSTALL
343
357
  - lib/generators/sharing_tags/install/templates/initializer.rb
@@ -417,8 +431,9 @@ files:
417
431
  - spec/helpers/meta_tags_helper_spec.rb
418
432
  - spec/javascripts/fixtures/facebook.json
419
433
  - spec/javascripts/fixtures/vkontakte.json
420
- - spec/javascripts/sharing_tags/share/facebook_share_spec.coffee
421
- - spec/javascripts/sharing_tags/share/vkontakte_share_spec.coffee
434
+ - spec/javascripts/sharing_tags/share/facebook_spec.coffee
435
+ - spec/javascripts/sharing_tags/share/vkontakte_spec.coffee
436
+ - spec/javascripts/sharing_tags/share_spec.coffee
422
437
  - spec/javascripts/sharing_tags/sharing_tags_spec.coffee
423
438
  - spec/javascripts/spec_helper.coffee
424
439
  - spec/models/configuration_spec.rb
@@ -518,8 +533,9 @@ test_files:
518
533
  - spec/helpers/meta_tags_helper_spec.rb
519
534
  - spec/javascripts/fixtures/facebook.json
520
535
  - spec/javascripts/fixtures/vkontakte.json
521
- - spec/javascripts/sharing_tags/share/facebook_share_spec.coffee
522
- - spec/javascripts/sharing_tags/share/vkontakte_share_spec.coffee
536
+ - spec/javascripts/sharing_tags/share/facebook_spec.coffee
537
+ - spec/javascripts/sharing_tags/share/vkontakte_spec.coffee
538
+ - spec/javascripts/sharing_tags/share_spec.coffee
523
539
  - spec/javascripts/sharing_tags/sharing_tags_spec.coffee
524
540
  - spec/javascripts/spec_helper.coffee
525
541
  - spec/models/configuration_spec.rb
@@ -1,9 +0,0 @@
1
- #= require jquery
2
- #= require jquery.role.js
3
-
4
- #= require sharing_tags/share
5
- #= require sharing_tags/share/base
6
- #= require sharing_tags/share/facebook
7
- #= require sharing_tags/share/vkontakte
8
- #= require sharing_tags/links
9
- #= require sharing_tags/init
@@ -1,38 +0,0 @@
1
- class @SharingTags.BaseShare
2
-
3
- url: null
4
- title: null
5
- description: null
6
-
7
- constructor: ({@url, @title, @description})->
8
- @_assert_vars 'url'
9
-
10
- _open_popup: (api_url, params)->
11
- share_url = if params then "#{api_url}?#{$.param(params)}" else api_url
12
- share_window = window.open share_url, 'Sharing', 'width=740,height=440'
13
-
14
- clearInterval(@interval)
15
- iteration = 0
16
- @interval = setInterval((=>
17
- iteration++
18
- if @_checkSharing(share_url, share_window, iteration)
19
- clearInterval @interval
20
- jQuery("body").trigger("sharing_tags.shared") if jQuery
21
- ), 500)
22
-
23
- _checkSharing: (share_url, share_window, iteration)=>
24
- # console.log("check desktop sharing", share_url, share_window, iteration)
25
- share_window?.closed || iteration >= 15
26
-
27
- _after_callback: =>
28
- jQuery?("body").trigger("sharing_tags.shared")
29
-
30
- _assert_vars: (vars...)->
31
- for var_name in vars
32
- if ! @[var_name]
33
- arguments_list = ''
34
- arguments_list += " #{var_name}: '#{@[var_name]}'" for arg, val in vars
35
- throw new SharingTags.Error("Error could not initialize sharing class, with params: #{arguments_list}")
36
-
37
- _user_agent: ->
38
- window.navigator?.userAgent
@@ -1,57 +0,0 @@
1
- class @SharingTags.FacebookShare extends @SharingTags.BaseShare
2
-
3
- # available providers: sharer, fb_ui, dialog
4
- @default_provider: "fb_ui"
5
-
6
- app_id: null
7
- return_url: null
8
- provider: null
9
-
10
- constructor: ({@app_id, @return_url, @provider})->
11
- @provider = @detect_provider() if !@provider
12
-
13
- # todo: throw error for invalid provider
14
- @constructor.init() if @provider is 'fb_ui' and not FB?
15
-
16
- super
17
-
18
- @init: (locale="en_US")->
19
- if not FB?
20
- jQuery.ajax(
21
- url: "//connect.facebook.net/#{locale}/all.js"
22
- dataType: "script"
23
- cache: true
24
- )
25
-
26
- share: ()->
27
- @["_#{@provider}"]()
28
-
29
- _sharer: ->
30
- @_assert_vars "url"
31
- @_open_popup("http://www.facebook.com/sharer.php", u: @url)
32
-
33
- _fb_ui: =>
34
- @_assert_vars "url", "app_id"
35
- return @constructor.init().done(@_fb_ui) if not FB?
36
-
37
- FB?.ui(method: 'share', href: @url, app_id: @app_id, (response)=>
38
- @_after_callback(response)
39
- # if response && !response.error_code
40
- # @_after_callback(response)
41
- # else
42
- # # another callback
43
- )
44
-
45
- _dialog: (display = 'page')->
46
- @_assert_vars 'url', 'return_url'
47
- @_open_popup("http://www.facebook.com/dialog/share", href: @url, redirect_uri: @return_url, app_id: @app_id, display: display)
48
-
49
-
50
- detect_provider: ->
51
- if @_user_agent().match('CriOS')
52
- "sharer"
53
- else if @app_id
54
- if @return_url then "dialog"
55
- else "fb_ui"
56
- else
57
- "sharer"