Permalink
Browse files

Use social-share-button gem to instead old code.

  • Loading branch information...
1 parent 7cda366 commit a889b407e992a15a003bc5fc3525b7a0db78fb0d @huacnlee huacnlee committed Jan 4, 2012
View
@@ -60,6 +60,8 @@ gem "daemon-spawn", "~> 0.4.2"
gem "unicorn"
# 用于组合小图片
gem "sprite-factory", "1.4.1"
+# 分享功能
+gem "social-share-button", "~> 0.0.1"
# Simple form last commit: 2011-12-03
gem 'simple_form', :git => "git://github.com/plataformatec/simple_form.git"
gem 'bootstrap-rails', :require => 'bootstrap-rails', :git => 'git://github.com/xdite/bootstrap-rails.git'
View
@@ -270,6 +270,7 @@ GEM
rack (~> 1.3, >= 1.3.4)
rack-protection (~> 1.1, >= 1.1.2)
tilt (~> 1.3, >= 1.3.3)
+ social-share-button (0.0.1)
sprite-factory (1.4.1)
sprockets (2.0.3)
hike (~> 1.2)
@@ -354,6 +355,7 @@ DEPENDENCIES
sass-rails (~> 3.1.4)
settingslogic (~> 2.0.6)
simple_form!
+ social-share-button (~> 0.0.1)
sprite-factory (= 1.4.1)
sunspot_rails (~> 1.3.0)
sunspot_solr
View
@@ -62,7 +62,6 @@ Dalli requires memcached 1.4.x +
## Common Partial
-* common/share : for social share
* common/user\_nav : user\_navigation_bar
## Facebook Share
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
@@ -12,19 +12,7 @@ window.App =
openUrl : (url) ->
window.open(url)
-
- shareTo : (site, title) ->
- url = encodeURIComponent(location.href)
- title = encodeURIComponent(title)
- switch site
- when "weibo"
- App.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&title=#{title}&source=ruby-china.org&content=utf-8")
- when "twitter"
- App.openUrl("https://twitter.com/home?status=#{title}: #{url} @ruby_china")
- when "douban"
- App.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&v=1&r=1")
- when "facebook"
- App.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{url}")
+
likeable : (el) ->
likeable_type = $(el).data("type")
likeable_id = $(el).data("id")
@@ -99,8 +87,5 @@ $(document).ready ->
if $(el.target).val().trim().length > 0
$(el.target).parent().parent().submit()
return false
- $(".share_buttons a").click () ->
- App.shareTo($(this).data("site"), $(this).parent().data('title'))
- return false
$("select").chosen()
@@ -12,4 +12,5 @@
//= require jquery.hotkeys
//= require jquery.chosen
//= require jquery.autogrow-textarea
+//= require social-share-button
//= require app
@@ -4,6 +4,7 @@
*= require wikistyle
*= require jquery.chosen
*= require highlight
+ *= require social-share-button
*= require_tree ./sprites/
*= require_self
*/
@@ -1,24 +0,0 @@
-/*
-
- Creating a sprite from following images:
-
- app/assets/images/sprites/share_icons/douban.png (16x16)
- app/assets/images/sprites/share_icons/facebook.png (16x16)
- app/assets/images/sprites/share_icons/rss.png (16x16)
- app/assets/images/sprites/share_icons/twitter.png (16x16)
- app/assets/images/sprites/share_icons/weibo.png (16x16)
-
- Output files:
- app/assets/images/sprites/share_icons.png
- app/assets/stylesheets/sprites/share_icons.scss
-
- Output size:
- 80x16
-
-
-*/
-.share_icons_douban { width: 16px; height: 16px; background: url(image-path('sprites/share_icons.png')) 0px 0px no-repeat; }
-.share_icons_facebook { width: 16px; height: 16px; background: url(image-path('sprites/share_icons.png')) -16px 0px no-repeat; }
-.share_icons_rss { width: 16px; height: 16px; background: url(image-path('sprites/share_icons.png')) -32px 0px no-repeat; }
-.share_icons_twitter { width: 16px; height: 16px; background: url(image-path('sprites/share_icons.png')) -48px 0px no-repeat; }
-.share_icons_weibo { width: 16px; height: 16px; background: url(image-path('sprites/share_icons.png')) -64px 0px no-repeat; }
@@ -45,7 +45,6 @@
#main .topics .topic h1 { font-size:22px; color:#333; margin-top:6px; text-align: left; line-height:100%;margin-bottom:8px;}
.more { padding:8px; padding-bottom:0; font-size:14px; text-align:right; }
-.share_buttons { height:16px; }
/* topics list in node page */
@@ -1,6 +0,0 @@
-<div class='share_buttons' data-title="<%= title %>">
- <a href="#" rel="nofollow" rel="twipsy" data-site="twitter" class="icon share_icons_twitter" title="<%= t("share.to_twitter") %>"></a>
- <a href="#" rel="nofollow" rel="twipsy" data-site="facebook" class="icon share_icons_facebook" title="<%= t("share.to_facebook") %>"></a>
- <a href="#" rel="nofollow" rel="twipsy" data-site="weibo" class="icon share_icons_weibo" title="<%= t("share.to_weibo") %>"></a>
- <a href="#" rel="nofollow" rel="twipsy" data-site="douban" class="icon share_icons_douban" title="<%= t("share.to_douban") %>"></a>
-</div>
@@ -7,7 +7,7 @@
</div>
<% end %>
<div style="text-align:right;">
- <%= render "common/share", :title => @page.title %>
+ <%= social_share_button_tag(@page.title) %>
</div>
<div class="wikistyle">
@@ -27,7 +27,7 @@
<%= link_to "", topic_path(@topic.id), :method => :delete, :confirm => t("common.confirm_delete"), :class => "icon small_delete", :title => "删除本帖" %>
<% end %>
</div>
- <%= render :partial => "common/share", :locals => {:title => @topic.title, :url => Setting.domain + topic_path(@topic) } %>
+ <%= social_share_button_tag(@topic.title) %>
</div>
</div>
@@ -0,0 +1,3 @@
+SocialShareButton.configure do |config|
+ config.allow_sites = %w(twitter facebook weibo douban)
+end
@@ -89,11 +89,6 @@
comments:
create_comment: "Comment"
no_comment: "No Comment at the moment"
- share:
- to_twitter: "Share to Twitter"
- to_weibo: "Share to Weibo"
- to_douban: "Share to Douban"
- to_facebook: "Share to Facebook"
mail:
login_from: "Sign in from"
this_is_a_notification_mail_please_do_not_reply: "This is an email notification. Please do not reply."
@@ -90,11 +90,6 @@
comments:
create_comment: "发表评论"
no_comment: "暂无评论"
- share:
- to_twitter: "转发到 Twitter"
- to_weibo: "转发到新浪微博"
- to_douban: "转发到豆瓣"
- to_facebook: "转发到 Facebook"
mail:
login_from: "登录页面地址"
this_is_a_notification_mail_please_do_not_reply: "这是一封提醒邮件,请勿直接通过邮件回复."
@@ -88,11 +88,6 @@
comments:
create_comment: "發表評論"
no_comment: "暫無評論"
- share:
- to_twitter: "轉發到 Twitter"
- to_weibo: "轉發到新浪微博"
- to_douban: "轉發到豆瓣"
- to_facebook: "轉發到 Facebook"
mail:
login_from: "登入頁面位址"
this_is_a_notification_mail_please_do_not_reply: "這是一封提醒郵件,請勿直接回覆此郵件。"
@@ -0,0 +1,8 @@
+en:
+ social_share_button:
+ share_to: Share to
+ weibo: Sina Weibo
+ twitter: Twitter
+ facebook: Facebook
+ douban: Douban
+
@@ -0,0 +1,8 @@
+'zh-CN':
+ social_share_button:
+ share_to: 分享到
+ weibo: 新浪微博
+ twitter: Twitter
+ facebook: Facebook
+ douban: 豆瓣
+
@@ -0,0 +1,7 @@
+'zh-TW':
+ social_share_button:
+ share_to: 分享到
+ weibo: 新浪微博
+ twitter: Twitter
+ facebook: Facebook
+ douban: 豆瓣

0 comments on commit a889b40

Please sign in to comment.