diff --git a/app/assets/javascripts/lib/social-share-button.coffee b/app/assets/javascripts/lib/social-share-button.coffee index 8a72a2ac..cec9fcbc 100644 --- a/app/assets/javascripts/lib/social-share-button.coffee +++ b/app/assets/javascripts/lib/social-share-button.coffee @@ -9,7 +9,6 @@ window.SocialShareButton = img = encodeURIComponent($(el).parent().data("img")) fb_url = encodeURIComponent($(el).parent().data("fb_url")) url = encodeURIComponent(location.href) - fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}") switch site when "weibo" SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8") @@ -18,7 +17,7 @@ window.SocialShareButton = when "douban" SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}") when "facebook" - SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_full_url}") + SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}") when "qq" SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}") when "tqq" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7601f91a..88c14bfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,7 +110,9 @@ class ApplicationController < ActionController::Base def render_share object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) - @orig_url = "http://#{params[:orig_host]}/#{params[:orig_path]}" + module_app = ModuleApp.first(:conditions => {:key => params[:key]}) + @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @orig_url = "http://#{request.host}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be2ab270..e9211c76 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -215,13 +215,13 @@ module ApplicationHelper object.strftime("%Y-%m-%d") end - def share_links(object) + def share_links(object, key) js = '' js << "\n" rescue '' js << "\n" rescue '' js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => "http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 2671d2e1..c8cc6bea 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -37,4 +37,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@bulletin, 'announcement') %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index 38a62828..a1d4097b 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -39,4 +39,4 @@ <% end %> -<%= share_links(@news_bulletin) %> +<%= share_links(@news_bulletin, 'news') %>