social-share-button 0.1.8 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bd4d327b79f18c54462a46ad663173b69e96e8f
4
- data.tar.gz: e4f3bee8d4d26eb19dc82c07c7f37481ba0bc7d8
3
+ metadata.gz: 0c12247c26eea96c0c8416014f259aae5b8be658
4
+ data.tar.gz: b0f6278cd3a98721f4ac5bf4b2dec23532123e33
5
5
  SHA512:
6
- metadata.gz: b37b62193465fb49f85cb9e54bb0a4ef894b396edd1ba8b37ae4aa5be0419318a74259ea6cd4fc9c3368d14033526e1d0b2e0e71283b682af6f87e37d7430cb1
7
- data.tar.gz: c4394f1d2c67848dda2978c3395dca8fb72cacf908e8e24ba68df8c1ce8e1f3371cd63e8ca85ab58a8c3b38681733406f5e34b4160347e1f9b7ebc5f07fd2b95
6
+ metadata.gz: 7c53ef2a438ec44b442a4deb10b380d2888abc46be9db4e96a257c6775d15217fad090a05acccf81b0cf962646db53cf6d36fd1eca803fdd4f6211d9fa409e9b
7
+ data.tar.gz: f414dc63e0ceb821a230447ab6be8d3ee2bdc603c5ee83d1160959f8d91150188c2c0fefbd845cfcf87ea81badb9665df29ed869773d865adcdf9094183a61e7
@@ -1,3 +1,8 @@
1
+ == 0.1.9
2
+
3
+ * Add `data-via` to allow `{ via: "MyTwitter" }`
4
+ * Add the special title for the corresponding social network by `{ 'data-twitter-title' => 'TheTitleForTwitter'}`
5
+
1
6
  == 0.1.8
2
7
 
3
8
  * Allow you custom appKey.
data/README.md CHANGED
@@ -72,6 +72,18 @@ Then you can use `social_share_button_tag` helper in views, for example `app/vie
72
72
  <%= social_share_button_tag(@post.title) %>
73
73
  ```
74
74
 
75
+ Apart from the default title, you can specify the title for the special social network:
76
+
77
+ ```erb
78
+ <%= social_share_button_tag(@post.title, 'data-twitter-title' => 'TheTitleForTwitter') %>
79
+ ```
80
+
81
+ For Popup window use this custom popup attribute:
82
+
83
+ ```erb
84
+ <%= social_share_button_tag(@post.title, :popup => "true")
85
+ ```
86
+
75
87
  And you can custom rel attribute:
76
88
 
77
89
  ```erb
@@ -84,9 +96,8 @@ You can also specify the URL that it links to:
84
96
  <%= social_share_button_tag(@post.title, :url => "http://myapp.com/foo/bar") %>
85
97
  ```
86
98
 
87
-
88
99
  ```erb
89
- <%= social_share_button_tag(@post.title, :url => "http://myapp.com/foo/bar", :image => "http://foo.bar/images/a.jpg", desc: "The summary of page") %>
100
+ <%= social_share_button_tag(@post.title, :url => "http://myapp.com/foo/bar", :image => "http://foo.bar/images/a.jpg", desc: "The summary of page", via: "MyTwitterName") %>
90
101
  ```
91
102
 
92
103
  For the Tumblr there are an extra settings, prefixed with :'data-*'
@@ -1,51 +1,57 @@
1
1
  window.SocialShareButton =
2
- openUrl : (url) ->
3
- window.open(url)
4
- false
2
+ openUrl : (url,popup) ->
3
+ if popup == "true"
4
+ window.open(url,'popup','height=500,width=500')
5
+ else
6
+ window.open(url)
7
+ false
5
8
 
6
9
  share : (el) ->
7
10
  site = $(el).data('site')
8
11
  appkey = $(el).data('appkey') || ''
9
12
  $parent = $(el).parent()
10
- title = encodeURIComponent($parent.data('title') || '')
13
+ title = encodeURIComponent($(el).data(site + '-title') || $parent.data('title') || '')
11
14
  img = encodeURIComponent($parent.data("img") || '')
12
15
  url = encodeURIComponent($parent.data("url") || '')
13
16
  via = encodeURIComponent($parent.data("via") || '')
14
17
  desc = encodeURIComponent($parent.data("desc") || ' ')
15
-
18
+ popup = encodeURIComponent($parent.data("popup") || 'false')
19
+
16
20
  if url.length == 0
17
21
  url = encodeURIComponent(location.href)
18
22
  switch site
19
23
  when "email"
20
24
  location.href = "mailto:?to=&subject=#{title}&body=#{url}"
21
25
  when "weibo"
22
- SocialShareButton.openUrl("http://service.weibo.com/share/share.php?url=#{url}&type=3&pic=#{img}&title=#{title}&appkey=#{appkey}")
26
+ SocialShareButton.openUrl("http://service.weibo.com/share/share.php?url=#{url}&type=3&pic=#{img}&title=#{title}&appkey=#{appkey}",popup)
23
27
  when "twitter"
24
- SocialShareButton.openUrl("https://twitter.com/intent/tweet?url=#{url}&text=#{title}&via=#{via}")
28
+ via_str = ''
29
+ via_str = "&via=#{via}" if via.length > 0
30
+ SocialShareButton.openUrl("https://twitter.com/intent/tweet?url=#{url}&text=#{title}#{via_str}",popup)
25
31
  when "douban"
26
- SocialShareButton.openUrl("http://shuo.douban.com/!service/share?href=#{url}&name=#{title}&image=#{img}&sel=#{desc}")
32
+ SocialShareButton.openUrl("http://shuo.douban.com/!service/share?href=#{url}&name=#{title}&image=#{img}&sel=#{desc}",popup)
27
33
  when "facebook"
28
- SocialShareButton.openUrl("http://www.facebook.com/sharer.php?u=#{url}")
34
+ SocialShareButton.openUrl("http://www.facebook.com/sharer.php?u=#{url}",popup)
29
35
  when "qq"
30
- SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}&summary=#{desc}&site=#{appkey}")
36
+ SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}&summary=#{desc}&site=#{appkey}", popup)
31
37
  when "tqq"
32
- SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}&appkey=#{appkey}")
38
+ SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}&appkey=#{appkey}", popup)
33
39
  when "baidu"
34
- SocialShareButton.openUrl("http://hi.baidu.com/pub/show/share?url=#{url}&title=#{title}&content=#{desc}")
40
+ SocialShareButton.openUrl("http://hi.baidu.com/pub/show/share?url=#{url}&title=#{title}&content=#{desc}", popup)
35
41
  when "kaixin001"
36
- SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}&aid=#{appkey}")
42
+ SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}&aid=#{appkey}", popup)
37
43
  when "renren"
38
- SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&srcUrl=#{url}&title=#{title}&pic=#{img}&description=#{desc}")
44
+ SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&srcUrl=#{url}&title=#{title}&pic=#{img}&description=#{desc}", popup)
39
45
  when "google_plus"
40
- SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}")
46
+ SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}", popup)
41
47
  when "google_bookmark"
42
- SocialShareButton.openUrl("https://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{url}&title=#{title}")
48
+ SocialShareButton.openUrl("https://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{url}&title=#{title}", popup)
43
49
  when "delicious"
44
- SocialShareButton.openUrl("http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{img}")
50
+ SocialShareButton.openUrl("http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{img}", popup)
45
51
  when "plurk"
46
- SocialShareButton.openUrl("http://www.plurk.com/?status=#{title}: #{url}&qualifier=shares")
52
+ SocialShareButton.openUrl("http://www.plurk.com/?status=#{title}: #{url}&qualifier=shares", popup)
47
53
  when "pinterest"
48
- SocialShareButton.openUrl("http://www.pinterest.com/pin/create/button/?url=#{url}&media=#{img}&description=#{title}")
54
+ SocialShareButton.openUrl("http://www.pinterest.com/pin/create/button/?url=#{url}&media=#{img}&description=#{title}", popup)
49
55
  when "tumblr"
50
56
  get_tumblr_extra = (param) ->
51
57
  cutom_data = $(el).attr("data-#{param}")
@@ -74,5 +80,5 @@ window.SocialShareButton =
74
80
 
75
81
  "/#{path}?#{params}"
76
82
 
77
- SocialShareButton.openUrl("http://www.tumblr.com/share#{tumblr_params()}")
83
+ SocialShareButton.openUrl("http://www.tumblr.com/share#{tumblr_params()}", popup)
78
84
  false
@@ -5,17 +5,19 @@ module SocialShareButton
5
5
  extra_data = {}
6
6
  rel = opts[:rel]
7
7
  html = []
8
- html << "<div class='social-share-button' data-title='#{h title}' data-img='#{opts[:image]}' data-url='#{opts[:url]}' data-desc='#{opts[:desc]}'>"
9
-
8
+ html << "<div class='social-share-button' data-title='#{h title}' data-img='#{opts[:image]}'"
9
+ html << "data-url='#{opts[:url]}' data-desc='#{opts[:desc]}' data-popup='#{opts[:popup]}' data-via='#{opts[:via]}'>"
10
+
10
11
  SocialShareButton.config.allow_sites.each do |name|
11
12
  extra_data = opts.select { |k, _| k.to_s.start_with?('data') } if name.eql?('tumblr')
13
+ special_data = opts.select { |k, _| k.to_s.start_with?('data-' + name) }
12
14
 
13
15
  link_title = t "social_share_button.share_to", :name => t("social_share_button.#{name.downcase}")
14
16
  html << link_to("","#", {:rel => ["nofollow", rel],
15
17
  "data-site" => name,
16
18
  :class => "social-share-button-#{name}",
17
19
  :onclick => "return SocialShareButton.share(this);",
18
- :title => h(link_title)}.merge(extra_data))
20
+ :title => h(link_title)}.merge(extra_data).merge(special_data))
19
21
  end
20
22
  html << "</div>"
21
23
  raw html.join("\n")
@@ -1,3 +1,3 @@
1
1
  module SocialShareButton
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social-share-button
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-18 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -97,10 +97,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.2.2
100
+ rubygems_version: 2.4.8
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Helper for add social share feature in your Rails app. Twitter, Facebook,
104
104
  Weibo, Douban, QQ, Tumblr ...
105
105
  test_files: []
106
- has_rdoc: