sharing_tags 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/assets/images/sharing_tags/icons/twitter.svg +1 -1
- data/app/assets/javascripts/sharing_tags/init.js.coffee.erb +2 -2
- data/app/assets/javascripts/sharing_tags/links.js.coffee +1 -1
- data/app/assets/javascripts/sharing_tags/share/callback.js.coffee +5 -3
- data/app/assets/javascripts/sharing_tags/share/facebook.js.coffee +22 -21
- data/app/assets/javascripts/sharing_tags/share.js.coffee +17 -5
- data/app/assets/stylesheets/sharing_tags/themes.css.sass +75 -0
- data/app/assets/stylesheets/sharing_tags/wave_animation.css.sass +1 -1
- data/app/assets/stylesheets/sharing_tags.css.sass +6 -4
- data/app/views/sharing_tags/buttons.html.slim +1 -1
- data/app/views/sharing_tags/meta/_open_graphs.html.slim +2 -2
- data/lib/sharing_tags/action_view/button_helper.rb +2 -2
- data/lib/sharing_tags/network/facebook.rb +5 -1
- data/lib/sharing_tags/version.rb +1 -1
- data/spec/helpers/button_helper_spec.rb +12 -6
- data/spec/javascripts/fixtures/facebook.json +4 -2
- data/spec/javascripts/sharing_tags/share/callback_spec.coffee +21 -0
- data/spec/javascripts/sharing_tags/share/facebook_spec.coffee +24 -21
- data/spec/models/configuration_spec.rb +5 -6
- data/spec/views/meta_tags/facebook_meta_tags_erb_spec.rb +33 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 270817d3806e9cc9aa725b7024ee800d57cdbe35
|
4
|
+
data.tar.gz: 5b08fbc8d4e692309e9b5e64bf268733c47112ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da7c3d0b92af30223626f77611b845e177bfd999b5bcdb2204f1d92d3efa271af3eec09abcc0f91fbf22239adfaebe281484e6413600d2a5c95ff6b25b89f220
|
7
|
+
data.tar.gz: 7d4eb00a481549809894a037f05b0ee52f20137a22093bd271816bd01b90d998e0c12b9f74098942de919bf0cd1cf1427240ee3312582c6bce8c679b202c5e53
|
data/README.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1 78 79"><path class="tw-sharing-tags-icon-fill sharing-tags-icon-fill" fill="none" d="M38.9.3C18.2.3 1.4 17.4 1.4 38.5s16.8 38.2 37.5 38.2 37.5-17.1 37.5-38.2S59.6.3 38.9.3z"/><path class="tw-sharing-tags-icon-in sharing-tags-icon-in" d="M19.5 52.9c.3 0 .7.1 1 .1h1c1 0 2-.1 2.9-.3.9-.1 1.9-.4 2.8-.8.9-.3 1.7-.7 2.5-1.2s1.6-.9 2.4-1.6c-.9 0-1.9-.1-2.7-.5-.9-.3-1.6-.8-2.4-1.2-.7-.5-1.3-1.2-1.9-1.9s-.9-1.5-1.2-2.4c.3 0 .5.1.8.1h.8c.4 0 .8 0 1.2-.1.4 0 .8-.1 1.2-.3-.9-.3-1.9-.5-2.8-1-.8-.5-1.6-1.2-2.3-1.9-.7-.8-1-1.6-1.5-2.5-.4-.9-.5-1.9-.5-2.9.5.3 1.2.5 1.9.8.7.1 1.3.3 2 .3-1.2-.8-2.1-1.7-2.8-3-.7-1.2-1-2.7-1-4.1 0-.8.1-1.5.3-2.3.3-.8.5-1.5.8-2 1 1.3 2.3 2.5 3.6 3.6 1.3 1 2.8 2 4.3 2.8 1.5.8 3 1.3 4.8 1.9 1.7.5 3.4.8 5.2.8 0-.3-.1-.7-.1-.9v-1c0-1.2.3-2.3.7-3.3.4-1 1-2 1.9-2.8s1.7-1.5 2.8-1.9c1-.4 2.1-.7 3.3-.7s2.4.3 3.4.8 2 1.2 2.8 2c.9-.1 2-.5 2.9-.8.9-.4 1.9-.8 2.7-1.3-.3.9-.8 1.9-1.5 2.7-.7.8-1.5 1.5-2.4 2 .9-.1 1.7-.3 2.5-.5.8-.3 1.6-.5 2.4-.8-.5.8-1.2 1.6-2 2.4-.7.8-1.5 1.5-2.4 2.1v1c0 2.8-.5 5.7-1.6 8.6-1 2.9-2.7 5.6-4.8 8-2.1 2.4-4.7 4.3-7.7 5.7-3 1.5-6.5 2.3-10.5 2.3-1.2 0-2.4-.1-3.6-.3-1.2-.1-2.4-.4-3.4-.8-1-.3-2.1-.8-3.2-1.2-.7-.4-1.7-1-2.6-1.7z"/></svg>
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class @SharingTags.Share.Callback
|
2
2
|
constructor: (@share)->
|
3
|
+
@network = @share.network
|
4
|
+
@context = @share.context
|
3
5
|
|
4
6
|
before_sharing: (provider)=>
|
5
|
-
@trigger("start_share", url: @share.url, provider: provider)
|
7
|
+
@trigger("start_share", url: @share.url, provider: provider, network: @network, context: @context)
|
6
8
|
|
7
|
-
after_sharing: ->
|
8
|
-
@trigger("shared")
|
9
|
+
after_sharing: (response)->
|
10
|
+
@trigger("shared", response: response, network: @network, context: @context)
|
9
11
|
|
10
12
|
before_open_popup: (open_url, popup_window)=>
|
11
13
|
@trigger("open_popup", url: open_url, popup_window: popup_window)
|
@@ -23,14 +23,18 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
23
23
|
# js.src = "//connect.facebook.net/en_US/sdk/debug.js";
|
24
24
|
if not FB?
|
25
25
|
sdk_url = locale + (if @debug then "/sdk/debug.js" else "/all.js")
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
jQuery.ajax(
|
27
|
+
url: "//connect.facebook.net/#{sdk_url}"
|
28
|
+
dataType: "script"
|
29
|
+
cache: true
|
30
|
+
)
|
31
|
+
# `(function(d, s, id){
|
32
|
+
# var js, fjs = d.getElementsByTagName(s)[0];
|
33
|
+
# if (d.getElementById(id)) {return;}
|
34
|
+
# js = d.createElement(s); js.id = id;
|
35
|
+
# js.src = "http://connect.facebook.net/" + sdk_url;
|
36
|
+
# fjs.parentNode.insertBefore(js, fjs);
|
37
|
+
# }(document, 'script', 'facebook-jssdk'));`
|
34
38
|
|
35
39
|
share: (provider = @provider)->
|
36
40
|
@callback.before_sharing(provider)
|
@@ -44,8 +48,6 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
44
48
|
# https://developers.facebook.com/docs/javascript/reference/FB.ui
|
45
49
|
_fb_ui: =>
|
46
50
|
@_assert_vars "url", "app_id"
|
47
|
-
return @constructor.init().done(@_fb_ui) if not FB?
|
48
|
-
|
49
51
|
FB?.ui(
|
50
52
|
method: 'share',
|
51
53
|
href: @url,
|
@@ -72,22 +74,21 @@ class @SharingTags.FacebookShare extends @SharingTags.Share
|
|
72
74
|
@callback.after_sharing(response)
|
73
75
|
)
|
74
76
|
|
75
|
-
# @note: iphone facebook browser - doesn't
|
77
|
+
# @note: iphone facebook browser - doesn't redirect to page after sharing
|
76
78
|
# @note: android browser - Ok
|
77
79
|
# return post_id
|
78
80
|
# https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.3
|
79
81
|
_fb_ui_feed: =>
|
80
|
-
return @constructor.init().done(@_fb_ui_feed) if not FB?
|
81
82
|
FB.ui(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
83
|
+
@_prepare_params(
|
84
|
+
method: 'feed'
|
85
|
+
link: @url
|
86
|
+
name: @caption # The name of the link attachment.
|
87
|
+
caption: @title
|
88
|
+
description: @description
|
89
|
+
picture: @image
|
90
|
+
redirect_uri: @return_url
|
91
|
+
),
|
91
92
|
(response)=>
|
92
93
|
@callback.after_sharing(response)
|
93
94
|
)
|
@@ -21,8 +21,8 @@ class @SharingTags
|
|
21
21
|
popup_params: null
|
22
22
|
)
|
23
23
|
|
24
|
-
@facebook: ({url, app_id, return_url, provider}) ->
|
25
|
-
@_debug("Facebook sharing",
|
24
|
+
@facebook: ({url, app_id, caption, title, description, image, return_url, provider}) ->
|
25
|
+
@_debug("Facebook sharing", arguments[0])
|
26
26
|
(new SharingTags.FacebookShare(arguments[0])).share()
|
27
27
|
|
28
28
|
@twitter: ({url, title}) ->
|
@@ -82,16 +82,24 @@ class @SharingTags
|
|
82
82
|
@_debug: (args...)->
|
83
83
|
console?.debug(args...) if SharingTags.debug
|
84
84
|
|
85
|
-
constructor: ({@network, @url, @title, @description, @image})->
|
85
|
+
constructor: ({@network, @context, @url, @title, @description, @image})->
|
86
86
|
@_assert_vars 'url'
|
87
87
|
@callback = new SharingTags.Share.Callback(@)
|
88
88
|
|
89
89
|
@constructor._debug("Init sharing #{@network}", {@url, @title, @description})
|
90
90
|
|
91
91
|
|
92
|
-
open_popup: (api_url, params)->
|
92
|
+
open_popup: (api_url, params, popup_attrs = 'width=550,height=420,toolbar=no')->
|
93
93
|
share_url = if params then "#{api_url}?#{$.param(params)}" else api_url
|
94
|
-
|
94
|
+
|
95
|
+
# popup_attrs =
|
96
|
+
# case @network
|
97
|
+
# when "twitter" then "width=550,height=420,toolbar=no"
|
98
|
+
# when "google" then "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600"
|
99
|
+
# when "facebook" then "width=550,height=420,toolbar=no"
|
100
|
+
# when "vkontakte" then "width=550,height=420,toolbar=no"
|
101
|
+
|
102
|
+
share_window = window.open share_url, 'Sharing', popup_attrs
|
95
103
|
@callback.before_open_popup(share_url, share_window)
|
96
104
|
|
97
105
|
clearInterval(@interval)
|
@@ -117,3 +125,7 @@ class @SharingTags
|
|
117
125
|
_user_agent: ->
|
118
126
|
window.navigator?.userAgent
|
119
127
|
|
128
|
+
_prepare_params: (params)->
|
129
|
+
result = {}
|
130
|
+
result[key] = value for key, value of params when value? and value != ""
|
131
|
+
result
|
@@ -0,0 +1,75 @@
|
|
1
|
+
%sharing_tags-squared-theme
|
2
|
+
.sharing_tags-buttons__item
|
3
|
+
border: 1px solid
|
4
|
+
box-sizing: border-box
|
5
|
+
|
6
|
+
.sharing_tags-facebook_buttons__item
|
7
|
+
background-color: #5071AA
|
8
|
+
border-color: darken(#5071AA, 2)
|
9
|
+
|
10
|
+
.sharing_tags-google_buttons__item
|
11
|
+
background-color: #dd4b39
|
12
|
+
border-color: darken(#dd4b39, 2)
|
13
|
+
|
14
|
+
.sharing_tags-twitter_buttons__item
|
15
|
+
background-color: #68C6E1
|
16
|
+
border-color: darken(#68C6E1, 2)
|
17
|
+
|
18
|
+
.sharing_tags-buttons__icon
|
19
|
+
.sharing-tags-icon-fill
|
20
|
+
fill: none
|
21
|
+
stroke: none
|
22
|
+
|
23
|
+
.sharing-tags-icon-in
|
24
|
+
fill: #FFFFFF
|
25
|
+
|
26
|
+
//.sharing_tags-buttons__item:hover
|
27
|
+
background-color: #FFFFFF
|
28
|
+
border: 1px solid
|
29
|
+
box-sizing: border-box
|
30
|
+
outline: none
|
31
|
+
|
32
|
+
&.sharing_tags-facebook_buttons__item
|
33
|
+
border-color: #5071AA
|
34
|
+
|
35
|
+
&.sharing_tags-google_buttons__item
|
36
|
+
border-color: #dd4b39
|
37
|
+
|
38
|
+
&.sharing_tags-twitter_buttons__item
|
39
|
+
border-color: #68C6E1
|
40
|
+
|
41
|
+
.sharing_tags-buttons__icon
|
42
|
+
.sharing-tags-icon-in
|
43
|
+
stroke: none
|
44
|
+
|
45
|
+
.sharing-tags-icon-fill
|
46
|
+
fill: none
|
47
|
+
stroke: none
|
48
|
+
|
49
|
+
.gl-sharing-tags-icon-in
|
50
|
+
fill: #dd4b39
|
51
|
+
|
52
|
+
.fb-sharing-tags-icon-in
|
53
|
+
fill: #5071AA
|
54
|
+
|
55
|
+
.tw-sharing-tags-icon-in
|
56
|
+
fill: #68C6E1
|
57
|
+
|
58
|
+
// darker on hover
|
59
|
+
.sharing_tags-buttons__item:hover
|
60
|
+
&.sharing_tags-facebook_buttons__item
|
61
|
+
background-color: darken(#5071AA, 7)
|
62
|
+
|
63
|
+
&.sharing_tags-google_buttons__item
|
64
|
+
background-color: darken(#dd4b39, 7)
|
65
|
+
|
66
|
+
&.sharing_tags-twitter_buttons__item
|
67
|
+
background-color: darken(#68C6E1, 7)
|
68
|
+
|
69
|
+
.sharing_tags-buttons__icon
|
70
|
+
.sharing-tags-icon-fill
|
71
|
+
fill: none
|
72
|
+
stroke: none
|
73
|
+
|
74
|
+
.sharing-tags-icon-in
|
75
|
+
fill: darken(#FFFFFF, 7)
|
@@ -29,6 +29,6 @@
|
|
29
29
|
$center: $right - $half_step
|
30
30
|
$left: $center - $half_step
|
31
31
|
|
32
|
-
$animation_name: '
|
32
|
+
$animation_name: 'animate__button#{$i}'
|
33
33
|
+create_keyframes_animation($animation_name, $left, $center, $right, $scale)
|
34
34
|
+add_animation_on_sharing_button($animation_name, $i, $speed)
|
@@ -13,7 +13,7 @@
|
|
13
13
|
&:last-child
|
14
14
|
margin-right: 0
|
15
15
|
|
16
|
-
a
|
16
|
+
a.sharing_tags-buttons__icon
|
17
17
|
cursor: pointer
|
18
18
|
display: inline-block
|
19
19
|
vertical-align: middle
|
@@ -22,7 +22,9 @@
|
|
22
22
|
|
23
23
|
.sharing_tags-buttons__icon
|
24
24
|
display: inline-block
|
25
|
-
width:
|
26
|
-
height:
|
27
|
-
|
25
|
+
width: 36px
|
26
|
+
height: 36px
|
27
|
+
@media screen and (max-width: 600px) and (min-width: 360px)
|
28
|
+
width: 50px
|
29
|
+
height: 50px
|
28
30
|
|
@@ -1,3 +1,3 @@
|
|
1
1
|
ul.sharing_tags-buttons class="sharing_tags-buttons__#{context.name} #{options[:class]}"
|
2
2
|
- networks.each do |network|
|
3
|
-
li.sharing_tags-buttons__item= render "sharing_tags/button/#{network}"
|
3
|
+
li.sharing_tags-buttons__item class="sharing_tags-#{network}_buttons__item"= render "sharing_tags/button/#{network}"
|
@@ -17,7 +17,7 @@ module SharingTags
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def link_to_facebook_share(name_or_options = nil, &block)
|
20
|
-
share_to name_or_options, :facebook, [:app_id, :provider, :title, :description, :caption, :image], &block
|
20
|
+
share_to name_or_options, :facebook, [:app_id, :provider, :title, :description, :caption, :image, :return_url], &block
|
21
21
|
end
|
22
22
|
|
23
23
|
def link_to_vkontakte_share(name_or_options = nil, &block)
|
@@ -76,7 +76,7 @@ module SharingTags
|
|
76
76
|
link_to "", params.page_url, data: data_attrs, role: "sharing_tags_share", class: classes, target: "_blank", &block
|
77
77
|
end
|
78
78
|
end
|
79
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
79
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -2,7 +2,7 @@ module SharingTags
|
|
2
2
|
class Network
|
3
3
|
class Facebook < Network
|
4
4
|
def self.available_attributes
|
5
|
-
super + %i( app_id provider )
|
5
|
+
super + %i( app_id caption provider return_url)
|
6
6
|
end
|
7
7
|
|
8
8
|
def provider(provider = 'auto', &block)
|
@@ -13,6 +13,10 @@ module SharingTags
|
|
13
13
|
attributes[:app_id] = store_value(app_id, &block)
|
14
14
|
end
|
15
15
|
|
16
|
+
def return_url(url = nil, &block)
|
17
|
+
attributes[:return_url] = store_value(url, &block)
|
18
|
+
end
|
19
|
+
|
16
20
|
def caption(message = nil, &block)
|
17
21
|
attributes[:caption] = store_value(message, &block)
|
18
22
|
end
|
data/lib/sharing_tags/version.rb
CHANGED
@@ -8,7 +8,9 @@ RSpec.describe SharingTags::ActionView::ButtonHelper, type: :helper do
|
|
8
8
|
description "fb desc"
|
9
9
|
share_url "http://c.d"
|
10
10
|
page_url "http://a.b"
|
11
|
+
return_url "http://r.url"
|
11
12
|
image "http://img.png"
|
13
|
+
caption "Caption"
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -17,15 +19,19 @@ RSpec.describe SharingTags::ActionView::ButtonHelper, type: :helper do
|
|
17
19
|
|
18
20
|
it "generate default text share link" do
|
19
21
|
is_expected.to have_tag "a", with: {href: "http://a.b", role: "sharing_tags_share"}
|
20
|
-
is_expected.to have_tag "a", with: {
|
22
|
+
is_expected.to have_tag "a", with: {
|
23
|
+
"data-share-url" => "http://c.d",
|
24
|
+
"data-title" => "fb title",
|
25
|
+
"data-description" => "fb desc",
|
26
|
+
"data-image" => "http://img.png",
|
27
|
+
"data-network" => "facebook",
|
28
|
+
"data-caption" => "Caption",
|
29
|
+
"data-return-url" => "http://r.url"
|
30
|
+
}
|
21
31
|
is_expected.to have_tag "a", with: {class: "sharing_tags-facebook__icon sharing_tags-buttons__icon"}
|
22
32
|
|
23
33
|
is_expected.to have_tag("a", without: {
|
24
|
-
"data-share-url"
|
25
|
-
"data-title" => "fb title",
|
26
|
-
"data-description" => "fb desc",
|
27
|
-
"data-image" => "http://img.png",
|
28
|
-
"data-network" => "facebook"
|
34
|
+
"data-share-url" => "http://c.d"
|
29
35
|
})
|
30
36
|
end
|
31
37
|
|
@@ -25,7 +25,8 @@
|
|
25
25
|
"fb_ui": {
|
26
26
|
"url": "http://fb_ui.url",
|
27
27
|
"app_id": "123",
|
28
|
-
"provider": "fb_ui"
|
28
|
+
"provider": "fb_ui",
|
29
|
+
"network": "facebook"
|
29
30
|
},
|
30
31
|
|
31
32
|
"dialog": {
|
@@ -46,6 +47,7 @@
|
|
46
47
|
"title": "Title full",
|
47
48
|
"description": "Description",
|
48
49
|
"image": "http://image.url",
|
49
|
-
"app_id": "123"
|
50
|
+
"app_id": "123",
|
51
|
+
"return_url": "http://my.site/return_url"
|
50
52
|
}
|
51
53
|
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#=require sharing_tags/share
|
2
|
+
#=require sharing_tags/share/facebook
|
3
|
+
#=require sharing_tags/share/callback
|
4
|
+
|
5
|
+
fixture.preload("facebook.json")
|
6
|
+
|
7
|
+
describe "SharingTags.Share.Callback", ->
|
8
|
+
|
9
|
+
subject = SharingTags.Share.Callback
|
10
|
+
|
11
|
+
beforeEach ->
|
12
|
+
@fb_fixture = fixture.load("facebook.json")[0]
|
13
|
+
@fb = @fb_fixture.fb_ui
|
14
|
+
@share = new SharingTags.Share @fb
|
15
|
+
@callback = new subject(@share)
|
16
|
+
|
17
|
+
|
18
|
+
it "expect get network and context attr from share", ->
|
19
|
+
expect( @callback.network ).toBe "facebook"
|
20
|
+
|
21
|
+
# todo: check all callbacks
|
@@ -188,18 +188,6 @@ describe "SharingTags.FacebookShare", ->
|
|
188
188
|
delete @share.url
|
189
189
|
expect(=> @share._fb_ui()).toThrow(SharingTags.Error(), /Error could not initialize sharing class/)
|
190
190
|
|
191
|
-
describe "loading FB.ui", ->
|
192
|
-
beforeEach ->
|
193
|
-
spyOn(@share.constructor, "init").andCallThrough()
|
194
|
-
spyOn(@share, "_fb_ui").andCallThrough()
|
195
|
-
|
196
|
-
it "expect load FB.ui if FB undefined", ->
|
197
|
-
expect(typeof FB).toBe('undefined')
|
198
|
-
|
199
|
-
@share._fb_ui()
|
200
|
-
expect(@share.constructor.init).toHaveBeenCalled()
|
201
|
-
expect(@share._fb_ui).toHaveBeenCalled()
|
202
|
-
|
203
191
|
describe "#_stream_share", ->
|
204
192
|
beforeEach ->
|
205
193
|
@fb = @fb_fixture.fb_ui
|
@@ -216,7 +204,7 @@ describe "SharingTags.FacebookShare", ->
|
|
216
204
|
|
217
205
|
describe "#_fb_ui_feed", ->
|
218
206
|
beforeEach ->
|
219
|
-
@fb = @fb_fixture.fb_ui_feed
|
207
|
+
@fb = jQuery.extend({}, @fb_fixture.fb_ui_feed)
|
220
208
|
@share = new subject(@fb)
|
221
209
|
window.FB = jasmine.createSpyObj "FB", ['ui', 'init']
|
222
210
|
|
@@ -225,9 +213,28 @@ describe "SharingTags.FacebookShare", ->
|
|
225
213
|
expect(FB.ui).toHaveBeenCalled()
|
226
214
|
expect(FB.ui).toHaveBeenCalledWith(
|
227
215
|
jasmine.objectContaining(
|
228
|
-
link: @fb.url, method: 'feed',
|
229
|
-
description: @fb.description,
|
230
|
-
picture: @fb.image
|
216
|
+
link: @fb.url, method: 'feed', caption: @fb.title,
|
217
|
+
description: @fb.description, name: @fb.caption,
|
218
|
+
picture: @fb.image, redirect_uri: @fb.return_url
|
219
|
+
),
|
220
|
+
jasmine.any(Function)
|
221
|
+
)
|
222
|
+
|
223
|
+
it "expect call FB.ui method with not empty params", ->
|
224
|
+
@fb.return_url = ""
|
225
|
+
@fb.description = ""
|
226
|
+
@share._fb_ui_feed()
|
227
|
+
expect(FB.ui).toHaveBeenCalled()
|
228
|
+
expect(FB.ui).toHaveBeenCalledWith(
|
229
|
+
jasmine.objectContaining(
|
230
|
+
link: @fb.url, method: 'feed', caption: @fb.title,
|
231
|
+
name: @fb.caption, picture: @fb.image
|
232
|
+
),
|
233
|
+
jasmine.any(Function)
|
234
|
+
)
|
235
|
+
expect(FB.ui).not.toHaveBeenCalledWith(
|
236
|
+
jasmine.objectContaining(
|
237
|
+
return_url: @fb.return_url, description: @fb.description
|
231
238
|
),
|
232
239
|
jasmine.any(Function)
|
233
240
|
)
|
@@ -255,7 +262,7 @@ describe "SharingTags.FacebookShare", ->
|
|
255
262
|
it "expect to receive fb_ui provider for sharing with app_id params", ->
|
256
263
|
@share = new subject(@fb_fixture.fb_ui)
|
257
264
|
expect(@share.app_id).toBeDefined()
|
258
|
-
expect(@share.detect_provider()).toBe "
|
265
|
+
expect(@share.detect_provider()).toBe "fb_ui_feed"
|
259
266
|
|
260
267
|
it "expect to receive dialog provider for sharing with app_id and return url params", ->
|
261
268
|
@share = new subject(@fb_fixture.returned)
|
@@ -268,8 +275,4 @@ describe "SharingTags.FacebookShare", ->
|
|
268
275
|
@share = new subject(@fb_fixture.partial)
|
269
276
|
expect(@share.detect_provider()).toBe "sharer"
|
270
277
|
|
271
|
-
it "expect to receive fb_ui provider for sharing with app_id params", ->
|
272
|
-
delete @fb_fixture.partial.provider
|
273
|
-
@share = new subject(@fb_fixture.partial)
|
274
|
-
expect(@share.detect_provider()).toBe "sharer"
|
275
278
|
|
@@ -166,15 +166,14 @@ describe SharingTags::Configuration do
|
|
166
166
|
app_id "APP ID"
|
167
167
|
provider "sharer"
|
168
168
|
caption "Caption"
|
169
|
+
return_url "http://return.com"
|
169
170
|
end
|
170
171
|
end
|
171
172
|
end
|
172
173
|
|
173
|
-
it
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
end
|
178
|
-
|
174
|
+
it { expect(subject.facebook.app_id).to be == "APP ID" }
|
175
|
+
it { expect(subject.facebook.provider).to be == "sharer" }
|
176
|
+
it { expect(subject.facebook.caption).to be == "Caption" }
|
177
|
+
it { expect(subject.facebook.return_url).to be == "http://return.com" }
|
179
178
|
end
|
180
179
|
end
|
@@ -58,4 +58,37 @@ RSpec.describe "sharing_tags/meta_tags", type: :view do
|
|
58
58
|
expect(rendered).to have_tag "meta", with: {property: "og:url", content: "http://a.b"}
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
describe "doesn't render empty params" do
|
63
|
+
before do
|
64
|
+
controller.append_view_path 'app/views'
|
65
|
+
|
66
|
+
SharingTags.configure do
|
67
|
+
share_url "http:://dummy.com"
|
68
|
+
|
69
|
+
facebook do
|
70
|
+
caption { "Facebook caption" }
|
71
|
+
image_url { "http://img.jpg" }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "render caption instead title" do
|
77
|
+
render
|
78
|
+
expect(rendered).to have_tag "meta", with: {property: "og:title", content: "Facebook caption"}
|
79
|
+
end
|
80
|
+
|
81
|
+
it "expect render image meta" do
|
82
|
+
render
|
83
|
+
expect(rendered).to have_tag "meta", with: {property: "og:image", content: "http://img.jpg"}
|
84
|
+
end
|
85
|
+
|
86
|
+
it "shouldn't render empty params" do
|
87
|
+
render
|
88
|
+
expect(rendered).to_not have_tag "meta", with: {property: "og:description"}
|
89
|
+
expect(rendered).to_not have_tag "meta", with: {property: "og:image:type"}
|
90
|
+
expect(rendered).to_not have_tag "meta", with: {property: "og:image:width"}
|
91
|
+
expect(rendered).to_not have_tag "meta", with: {property: "og:image:height"}
|
92
|
+
end
|
93
|
+
end
|
61
94
|
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.
|
4
|
+
version: 0.0.14
|
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-
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -340,6 +340,7 @@ files:
|
|
340
340
|
- app/assets/javascripts/sharing_tags/share/facebook.js.coffee
|
341
341
|
- app/assets/stylesheets/sharing_tags.css.sass
|
342
342
|
- app/assets/stylesheets/sharing_tags/icons.css.sass
|
343
|
+
- app/assets/stylesheets/sharing_tags/themes.css.sass
|
343
344
|
- app/assets/stylesheets/sharing_tags/wave_animation.css.sass
|
344
345
|
- app/views/sharing_tags/button/_facebook.html.slim
|
345
346
|
- app/views/sharing_tags/button/_google.html.slim
|
@@ -435,6 +436,7 @@ files:
|
|
435
436
|
- spec/helpers/meta_tags_helper_spec.rb
|
436
437
|
- spec/javascripts/fixtures/facebook.json
|
437
438
|
- spec/javascripts/fixtures/vkontakte.json
|
439
|
+
- spec/javascripts/sharing_tags/share/callback_spec.coffee
|
438
440
|
- spec/javascripts/sharing_tags/share/facebook_spec.coffee
|
439
441
|
- spec/javascripts/sharing_tags/share/vkontakte_spec.coffee
|
440
442
|
- spec/javascripts/sharing_tags/share_spec.coffee
|
@@ -537,6 +539,7 @@ test_files:
|
|
537
539
|
- spec/helpers/meta_tags_helper_spec.rb
|
538
540
|
- spec/javascripts/fixtures/facebook.json
|
539
541
|
- spec/javascripts/fixtures/vkontakte.json
|
542
|
+
- spec/javascripts/sharing_tags/share/callback_spec.coffee
|
540
543
|
- spec/javascripts/sharing_tags/share/facebook_spec.coffee
|
541
544
|
- spec/javascripts/sharing_tags/share/vkontakte_spec.coffee
|
542
545
|
- spec/javascripts/sharing_tags/share_spec.coffee
|