social-share-button 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  .bundle
4
+ .rvmrc
4
5
  Gemfile.lock
5
6
  pkg/*
@@ -1,3 +1,7 @@
1
+ == 0.1.2
2
+
3
+ * Add tumblr.
4
+
1
5
  == 0.1.1
2
6
 
3
7
  * Add delicious.
data/README.md CHANGED
@@ -16,6 +16,7 @@ This is a gem to helper you quick create a share feature in you Rails apps.
16
16
  * Kaixin001
17
17
  * Google Bookmark
18
18
  * Delicious
19
+ * Tumblr
19
20
 
20
21
  ## Screenshot
21
22
 
@@ -42,7 +43,7 @@ You can config `config/initializes/social_share_button.rb` to choose which site
42
43
 
43
44
  ```ruby
44
45
  SocialShareButton.configure do |config|
45
- config.allow_sites = %w(twitter facebook google_plus weibo douban tqq renren qq kaixin001 baidu)
46
+ config.allow_sites = %w(twitter facebook google_plus weibo douban tqq renren qq kaixin001 baidu tumblr)
46
47
  end
47
48
  ```
48
49
 
@@ -80,6 +81,27 @@ You can also specify the URL that it links to:
80
81
  <%= social_share_button_tag(@post.title, :url => "http://myapp.com/foo/bar") %>
81
82
  ```
82
83
 
84
+ For the Tumblr there are an extra settings, prefixed with :'data-*'
85
+ ```erb
86
+ <%= social_share_button_tag(@post.title, :image => "https://raw.github.com/vkulpa/social-share-button/master/lib/assets/images/sprites/social-share-button/tumblr.png", :'data-type' => 'photo') %>
87
+ <%= social_share_button_tag(@post.title, :'data-source' => "https://raw.github.com/vkulpa/social-share-button/master/lib/assets/images/sprites/social-share-button/tumblr.png", :'data-type' => 'photo') %>
88
+ ```
89
+ Those two above calls are identical.
90
+ Here are the mapping of attributes depending on you data-type parameter
91
+
92
+ <pre>
93
+ | data-type | standard | custom :"data-*" prefixed |
94
+ --------------------------------------------------------------
95
+ | link (default) | title | data-title |
96
+ | | url | data-url |
97
+ | text | title | data-title |
98
+ | photo | title | data-caption |
99
+ | | image | data-source |
100
+ | quote | title | data-quote |
101
+ | | | data-source |
102
+ </pre>
103
+
104
+
83
105
  ## Demo
84
106
 
85
107
  [http://ruby-china.org/wiki/about](http://ruby-china.org/wiki/about)
@@ -5,9 +5,9 @@ window.SocialShareButton =
5
5
 
6
6
  share : (el) ->
7
7
  site = $(el).data('site')
8
- title = encodeURIComponent($(el).parent().data('title'))
9
- img = encodeURIComponent($(el).parent().data("img"))
10
- url = encodeURIComponent($(el).parent().data("url"))
8
+ title = encodeURIComponent($(el).parent().data('title') || '')
9
+ img = encodeURIComponent($(el).parent().data("img") || '')
10
+ url = encodeURIComponent($(el).parent().data("url") || '')
11
11
  if url.length == 0
12
12
  url = encodeURIComponent(location.href)
13
13
  switch site
@@ -35,4 +35,33 @@ window.SocialShareButton =
35
35
  SocialShareButton.openUrl("https://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{url}&title=#{title}")
36
36
  when "delicious"
37
37
  SocialShareButton.openUrl("http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{img}")
38
+ when "tumblr"
39
+ get_tumblr_extra = (param) ->
40
+ cutom_data = $(el).attr("data-#{param}")
41
+ encodeURIComponent(cutom_data) if cutom_data
42
+
43
+ tumblr_params = ->
44
+ path = get_tumblr_extra('type') || 'link'
45
+
46
+ params = switch path
47
+ when 'text'
48
+ title = get_tumblr_extra('title') || title
49
+ "title=#{title}"
50
+ when 'photo'
51
+ title = get_tumblr_extra('caption') || title
52
+ source = get_tumblr_extra('source') || img
53
+ "caption=#{title}&source=#{source}"
54
+ when 'quote'
55
+ quote = get_tumblr_extra('quote') || title
56
+ source = get_tumblr_extra('source') || ''
57
+ "quote=#{quote}&source=#{source}"
58
+ else # actually, it's a link clause
59
+ title = get_tumblr_extra('title') || title
60
+ url = get_tumblr_extra('url') || url
61
+ "name=#{title}&url=#{url}"
62
+
63
+
64
+ "/#{path}?#{params}"
65
+
66
+ SocialShareButton.openUrl("http://www.tumblr.com/share#{tumblr_params()}")
38
67
  false
@@ -14,6 +14,7 @@
14
14
  lib/assets/images/sprites/social-share-button/qq.png (16x16)
15
15
  lib/assets/images/sprites/social-share-button/renren.png (16x16)
16
16
  lib/assets/images/sprites/social-share-button/tqq.png (16x16)
17
+ lib/assets/images/sprites/social-share-button/tumblr.png (16x16)
17
18
  lib/assets/images/sprites/social-share-button/twitter.png (16x16)
18
19
  lib/assets/images/sprites/social-share-button/weibo.png (16x16)
19
20
 
@@ -38,22 +39,24 @@
38
39
  .social-share-button-qq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -48px 0px no-repeat }
39
40
  .social-share-button-renren { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -48px -16px no-repeat }
40
41
  .social-share-button-tqq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -48px -32px no-repeat }
41
- .social-share-button-twitter { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) 0px -48px no-repeat }
42
- .social-share-button-weibo { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -16px -48px no-repeat }
42
+ .social-share-button-tumblr { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) 0px -48px no-repeat }
43
+ .social-share-button-twitter { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -16px -48px no-repeat }
44
+ .social-share-button-weibo { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button.png')) -32px -48px no-repeat }
43
45
 
44
- @media only screen and (-webkit-device-pixel-ratio: 2){
45
- .social-share-button-baidu { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px 0px no-repeat; background-size:64px 64px; }
46
- .social-share-button-delicious { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px 0px no-repeat; background-size:64px 64px; }
47
- .social-share-button-douban { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -16px no-repeat; background-size:64px 64px; }
48
- .social-share-button-email { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -16px no-repeat; background-size:64px 64px; }
49
- .social-share-button-facebook { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px 0px no-repeat; background-size:64px 64px; }
50
- .social-share-button-flickr { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px -16px no-repeat; background-size:64px 64px; }
51
- .social-share-button-google_bookmark { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -32px no-repeat; background-size:64px 64px; }
52
- .social-share-button-google_plus { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -32px no-repeat; background-size:64px 64px; }
53
- .social-share-button-kaixin001 { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px -32px no-repeat; background-size:64px 64px; }
54
- .social-share-button-qq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px 0px no-repeat; background-size:64px 64px; }
55
- .social-share-button-renren { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px -16px no-repeat; background-size:64px 64px; }
56
- .social-share-button-tqq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px -32px no-repeat; background-size:64px 64px; }
57
- .social-share-button-twitter { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -48px no-repeat; background-size:64px 64px; }
58
- .social-share-button-weibo { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -48px no-repeat; background-size:64px 64px; }
46
+ @media only screen and (-webkit-device-pixel-ratio: 2) {
47
+ .social-share-button-baidu { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px 0px no-repeat; background-size:64px 64px; }
48
+ .social-share-button-delicious { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px 0px no-repeat; background-size:64px 64px; }
49
+ .social-share-button-douban { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -16px no-repeat; background-size:64px 64px;}
50
+ .social-share-button-email { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -16px no-repeat; background-size:64px 64px;}
51
+ .social-share-button-facebook { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px 0px no-repeat; background-size:64px 64px;}
52
+ .social-share-button-flickr { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px -16px no-repeat; background-size:64px 64px;}
53
+ .social-share-button-google_bookmark { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -32px no-repeat; background-size:64px 64px;}
54
+ .social-share-button-google_plus { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -32px no-repeat; background-size:64px 64px;}
55
+ .social-share-button-kaixin001 { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px -32px no-repeat; background-size:64px 64px;}
56
+ .social-share-button-qq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px 0px no-repeat; background-size:64px 64px;}
57
+ .social-share-button-renren { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px -16px no-repeat; background-size:64px 64px;}
58
+ .social-share-button-tqq { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -48px -32px no-repeat; background-size:64px 64px;}
59
+ .social-share-button-tumblr { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) 0px -48px no-repeat; background-size:64px 64px;}
60
+ .social-share-button-twitter { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -16px -48px no-repeat; background-size:64px 64px;}
61
+ .social-share-button-weibo { display:inline-block; width: 16px; height: 16px; background: url(image-path('sprites/social-share-button@2x.png')) -32px -48px no-repeat; background-size:64px 64px;}
59
62
  }
@@ -1,3 +1,3 @@
1
1
  SocialShareButton.configure do |config|
2
- config.allow_sites = %w(twitter facebook google_plus weibo douban tqq renren qq kaixin001 baidu google_bookmark delicious huaban)
3
- end
2
+ config.allow_sites = %w(twitter facebook google_plus weibo douban tqq renren qq kaixin001 baidu google_bookmark delicious huaban tumblr)
3
+ end
@@ -13,3 +13,4 @@ en:
13
13
  renren: Renren.com
14
14
  google_plus: Google+
15
15
  google_bookmark: Google Bookmark
16
+ tumblr: Tumblr
@@ -13,3 +13,4 @@
13
13
  renren: 人人网
14
14
  google_plus: Google+
15
15
  google_bookmark: Google 收藏
16
+ tumblr: Tumblr
@@ -13,3 +13,4 @@
13
13
  renren: 人人網
14
14
  google_plus: Google+
15
15
  google_bookmark: Google 收藏
16
+ tumblr: Tumblr
@@ -2,17 +2,20 @@
2
2
  module SocialShareButton
3
3
  module Helper
4
4
  def social_share_button_tag(title = "", opts = {})
5
+ extra_data = {}
5
6
  rel = opts[:rel]
6
7
  html = []
7
8
  html << "<div class='social-share-button' data-title='#{title}' data-img='#{opts[:image]}' data-url='#{opts[:url]}'>"
8
9
 
9
10
  SocialShareButton.config.allow_sites.each do |name|
11
+ extra_data = opts.select { |k, _| k.to_s.start_with?('data') } if name.eql?('tumblr')
12
+
10
13
  link_title = t "social_share_button.share_to", :name => t("social_share_button.#{name.downcase}")
11
- html << link_to("","#", :rel => "nofollow #{rel}",
12
- "data-site" => name,
13
- :class => "social-share-button-#{name}",
14
- :onclick => "return SocialShareButton.share(this);",
15
- :title => h(link_title))
14
+ html << link_to("","#", {:rel => ["nofollow", rel],
15
+ "data-site" => name,
16
+ :class => "social-share-button-#{name}",
17
+ :onclick => "return SocialShareButton.share(this);",
18
+ :title => h(link_title)}.merge(extra_data))
16
19
  end
17
20
  html << "</div>"
18
21
  raw html.join("\n")
@@ -1,3 +1,3 @@
1
1
  module SocialShareButton
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Jason Lee"]
9
9
  s.email = ["huacnlee@gmail.com"]
10
10
  s.homepage = "http://github.com/huacnlee/social-share-button"
11
- s.summary = %q{Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban, QQ ...}
12
- s.description = %q{Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban, QQ ...}
11
+ s.summary = %q{Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban, QQ, Tumblr ...}
12
+ s.description = %q{Helper for add social share feature in your Rails app. Twitter, Facebook, Weibo, Douban, QQ, Tumblr ...}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social-share-button
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-26 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -28,7 +28,7 @@ dependencies:
28
28
  version: '0'
29
29
  none: false
30
30
  description: Helper for add social share feature in your Rails app. Twitter, Facebook,
31
- Weibo, Douban, QQ ...
31
+ Weibo, Douban, QQ, Tumblr ...
32
32
  email:
33
33
  - huacnlee@gmail.com
34
34
  executables: []
@@ -54,6 +54,7 @@ files:
54
54
  - lib/assets/images/sprites/social-share-button/qq.png
55
55
  - lib/assets/images/sprites/social-share-button/renren.png
56
56
  - lib/assets/images/sprites/social-share-button/tqq.png
57
+ - lib/assets/images/sprites/social-share-button/tumblr.png
57
58
  - lib/assets/images/sprites/social-share-button/twitter.png
58
59
  - lib/assets/images/sprites/social-share-button/weibo.png
59
60
  - lib/assets/images/sprites/social-share-button@2x.png
@@ -69,6 +70,7 @@ files:
69
70
  - lib/assets/images/sprites/social-share-button@2x/qq.png
70
71
  - lib/assets/images/sprites/social-share-button@2x/renren.png
71
72
  - lib/assets/images/sprites/social-share-button@2x/tqq.png
73
+ - lib/assets/images/sprites/social-share-button@2x/tumblr.png
72
74
  - lib/assets/images/sprites/social-share-button@2x/twitter.png
73
75
  - lib/assets/images/sprites/social-share-button@2x/weibo.png
74
76
  - lib/assets/javascripts/social-share-button.coffee
@@ -85,7 +87,7 @@ files:
85
87
  - lib/social_share_button/helper.rb
86
88
  - lib/social_share_button/railtie.rb
87
89
  - lib/social_share_button/version.rb
88
- - psd/icon_templet.psd
90
+ - psd/icon.psd
89
91
  - social-share-button.gemspec
90
92
  homepage: http://github.com/huacnlee/social-share-button
91
93
  licenses: []
@@ -111,5 +113,5 @@ rubygems_version: 1.8.24
111
113
  signing_key:
112
114
  specification_version: 3
113
115
  summary: Helper for add social share feature in your Rails app. Twitter, Facebook,
114
- Weibo, Douban, QQ ...
116
+ Weibo, Douban, QQ, Tumblr ...
115
117
  test_files: []