social_share_hub 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
1
+ window.SocialShareHub =
2
+ openUrl : (url, title) ->
3
+ window.open(url, title, 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no')
4
+ false
5
+
6
+ share : (el) ->
7
+ site = $(el).data('site')
8
+ title = encodeURIComponent($(el).parent().data('title'))
9
+ img = encodeURIComponent($(el).parent().data("img"))
10
+ url = encodeURIComponent(location.href)
11
+ switch site
12
+ when "weibo"
13
+ SocialShareHub.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8")
14
+ when "twitter"
15
+ SocialShareHub.openUrl("https://twitter.com/home?status=#{title}: #{url}")
16
+ when "douban"
17
+ SocialShareHub.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&v=1&r=1")
18
+ when "facebook"
19
+ SocialShareHub.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{url}")
20
+ when "qq"
21
+ SocialShareHub.openUrl("http://v.t.qq.com/share/share.php?url=#{url}&title=#{title}&pic=#{img}")
22
+ when "renren"
23
+ SocialShareHub.openUrl("http://share.renren.com/share/buttonshare?link=#{url}&title=#{title}")
24
+ false
@@ -33,9 +33,10 @@
33
33
  margin-right: 3px;
34
34
  }
35
35
 
36
- .social_share_hub_douban { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") 0px 0px no-repeat; }
37
- .social_share_hub_douban.disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -24px 0px no-repeat; }
38
- .social_share_hub_renren { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -48px 0px no-repeat; }
39
- .social_share_hub_renren.disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -72px 0px no-repeat; }
40
- .social_share_hub_weibo { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -96px 0px no-repeat; }
41
- .social_share_hub_weibo_disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -120px 0px no-repeat; }
36
+ .social_share_hub_douban { width: 24px; height: 24px; background: image-url("sprites/sprites.png") 0px 0px no-repeat; }
37
+ .social_share_hub_douban_disabled { width: 24px; height: 24px; background: image-url("sprites/sprites.png") -24px 0px no-repeat; }
38
+ .social_share_hub_qq { width: 24px; height: 24px; background: image-url("sprites/sprites.png") -48px 0px no-repeat; }
39
+ .social_share_hub_renren { width: 24px; height: 24px; background: image-url("sprites/sprites.png") -72px 0px no-repeat; }
40
+ .social_share_hub_renren_disabled { width: 24px; height: 24px; background: image-url("sprites/sprites.png") -96px 0px no-repeat; }
41
+ .social_share_hub_weibo { width: 24px; height: 24px; background: url("sprites/sprites.png") -120px 0px no-repeat; }
42
+ .social_share_hub_weibo_disabled { width: 24px; height: 24px; background: image-url("sprites/sprites.png") -144px 0px no-repeat; }
@@ -1,4 +1,4 @@
1
- en:
1
+ zh-CN:
2
2
  social_share_hub:
3
3
  share_to: Share to %{name}
4
4
  weibo: Sina Weibo
@@ -19,5 +19,5 @@ module SocialShareHub
19
19
  end
20
20
 
21
21
  SocialShareHub.configure do |conf|
22
- conf.allowed_sites = %w(twitter facebook weibo douban qq renren)
22
+ conf.allowed_sites = %w(weibo douban qq renren)
23
23
  end
@@ -1,36 +1,21 @@
1
1
  module SocialShareHub
2
2
  module Helper
3
- def social_share_hub_tag(message, link, options = {})
3
+ def social_share_hub_tag(message, options = {})
4
4
  html = []
5
- html << "<div class='social-share-hub clearfix'>"
5
+
6
+ html << "<div class='social-share-hub clearfix'' data-title='#{message}' data-img='#{options[:image]}'>"
6
7
 
7
8
  SocialShareHub.config.allowed_sites.each do |name|
8
- title = t "social_share_hub.share_to", :name => t("social_share_hub.#{name.downcase}")
9
+ link_title = t("social_share_hub.share_to", :name => t("social_share_hub.#{name.downcase}"))
9
10
 
10
- case name.to_sym
11
- when :weibo
12
- html << social_share_hub_weibo_link(message, link, options)
13
- when :douban
14
- html << social_share_hub_douban_link(message, link, options)
15
- when :renren
16
- html << social_share_hub_renren_link(message, link, options)
17
- end
18
-
11
+ html << link_to("","#",
12
+ :"data-site" => name,
13
+ :class => "social_share_hub_#{name}",
14
+ :onclick => "return SocialShareHub.share(this);",
15
+ :title => link_title)
19
16
  end
20
17
  html << "</div>"
21
18
  raw html.join("\n")
22
19
  end
23
-
24
- def social_share_hub_weibo_link(message, link, options)
25
- "<a class=\"social_share_hub_weibo\" href=\"javascript:void((function(s,d,e){var f='http://v.t.sina.com.cn/share/share.php?url=',u=d.location,l=d.title,p=[e('#{link}'),'&title=',e('#{message}')].join('');function%20a(){if(!window.open([f,p].join(''),'weibo',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent));\" title=\"Sina Weibo\">&nbsp;</a>".html_safe
26
- end
27
-
28
- def social_share_hub_douban_link(message, link, options)
29
- "<a class=\"social_share_hub_douban\" href=\"javascript:void(function(){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e('#{link}')+'&title='+e('#{message}')+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()\" title=\"Douban\">&nbsp;</a>".html_safe
30
- end
31
-
32
- def social_share_hub_renren_link(message, link, options)
33
- "<a class=\"social_share_hub_renren\" href=\"javascript:void((function(s,d,e){if(/renren\.com/.test(d.location))return;var f='http://share.renren.com/share/buttonshare?link=',u=d.location,l=d.title,p=[e('#{link}'),'&title=',e(l)].join('');function%20a(){if(!window.open([f,p].join(''),'xnshare',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent));\" title=\"Renren\">&nbsp;</a>".html_safe
34
- end
35
20
  end
36
21
  end
@@ -1,3 +1,3 @@
1
1
  module SocialShareHub
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -12,4 +12,4 @@ module SocialShareHub
12
12
  end
13
13
  end
14
14
 
15
- ActionView::Base.send :include, SocialShareHub::Helper
15
+ ActionView::Base.send :include, SocialShareHub::Helper
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["Jerry Shen"]
6
6
  gem.email = ["jerry@ekohe.com"]
7
7
  gem.description = %q{Social Share Hub}
8
- gem.summary = %q{Social Share Hub}
8
+ gem.summary = %q{Social Share Hub, quick share buttons for social websites}
9
9
  gem.homepage = ""
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_share_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -25,17 +25,17 @@ files:
25
25
  - Rakefile
26
26
  - app/assets/images/sprites/douban.png
27
27
  - app/assets/images/sprites/douban_disabled.png
28
+ - app/assets/images/sprites/q_weibo.png
28
29
  - app/assets/images/sprites/renren.png
29
30
  - app/assets/images/sprites/renren_disabled.png
30
- - app/assets/images/sprites/social_share_hub_sprites.png
31
+ - app/assets/images/sprites/sprites.png
31
32
  - app/assets/images/sprites/weibo.png
32
33
  - app/assets/images/sprites/weibo_disabled.png
34
+ - app/assets/javascripts/social_share_hub.coffee
33
35
  - app/assets/stylesheets/social_share_hub.css.scss
34
- - config/locales/social_share_hub.en.yml
35
- - config/locales/social_share_hub.zh-CN.yml
36
- - config/locales/social_share_hub.zh-TW.yml
37
36
  - lib/generators/social_share_hub/install_generator.rb
38
37
  - lib/generators/social_share_hub/templates/config/initializers/social_share_hub.rb
38
+ - lib/generators/social_share_hub/templates/config/locales/social_share_hub.zh-CN.yml
39
39
  - lib/social_share_hub.rb
40
40
  - lib/social_share_hub/config.rb
41
41
  - lib/social_share_hub/engine.rb
@@ -66,5 +66,5 @@ rubyforge_project:
66
66
  rubygems_version: 1.8.16
67
67
  signing_key:
68
68
  specification_version: 3
69
- summary: Social Share Hub
69
+ summary: Social Share Hub, quick share buttons for social websites
70
70
  test_files: []
@@ -1,9 +0,0 @@
1
- en:
2
- social_share_hub:
3
- share_to: Share to %{name}
4
- weibo: Sina Weibo
5
- twitter: Twitter
6
- facebook: Facebook
7
- douban: Douban
8
- qq: QQ
9
- renren: Renren
@@ -1,9 +0,0 @@
1
- en:
2
- social_share_hub:
3
- share_to: Share to %{name}
4
- weibo: Sina Weibo
5
- twitter: Twitter
6
- facebook: Facebook
7
- douban: Douban
8
- qq: QQ
9
- renren: Renren