Change for getting url from key
This commit is contained in:
parent
f7e6703d5f
commit
db16fdc7b5
app
assets/javascripts/lib
controllers
helpers
vendor/built_in_modules
announcement/app/views/panel/announcement/front_end/bulletins
news/app/views/panel/news/front_end/news_bulletins
|
@ -9,7 +9,6 @@ window.SocialShareButton =
|
||||||
img = encodeURIComponent($(el).parent().data("img"))
|
img = encodeURIComponent($(el).parent().data("img"))
|
||||||
fb_url = encodeURIComponent($(el).parent().data("fb_url"))
|
fb_url = encodeURIComponent($(el).parent().data("fb_url"))
|
||||||
url = encodeURIComponent(location.href)
|
url = encodeURIComponent(location.href)
|
||||||
fb_full_url = encodeURIComponent("#{fb_url}?orig_host=#{location.host}&orig_path=#{location.pathname}")
|
|
||||||
switch site
|
switch site
|
||||||
when "weibo"
|
when "weibo"
|
||||||
SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8")
|
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"
|
when "douban"
|
||||||
SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}")
|
SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}")
|
||||||
when "facebook"
|
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"
|
when "qq"
|
||||||
SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}")
|
SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}")
|
||||||
when "tqq"
|
when "tqq"
|
||||||
|
|
|
@ -110,7 +110,9 @@ class ApplicationController < ActionController::Base
|
||||||
def render_share
|
def render_share
|
||||||
object_class = params[:model].classify.constantize
|
object_class = params[:model].classify.constantize
|
||||||
@object = object_class.find(params[:id])
|
@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
|
render 'shared/render_share', :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -215,13 +215,13 @@ module ApplicationHelper
|
||||||
object.strftime("%Y-%m-%d")
|
object.strftime("%Y-%m-%d")
|
||||||
end
|
end
|
||||||
|
|
||||||
def share_links(object)
|
def share_links(object, key)
|
||||||
js = ''
|
js = ''
|
||||||
js << "<meta property='og:title' content='#{object.title}' />\n" rescue ''
|
js << "<meta property='og:title' content='#{object.title}' />\n" rescue ''
|
||||||
js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue ''
|
js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue ''
|
||||||
js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue ''
|
js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue ''
|
||||||
content_tag :div, :class => 'fb' do
|
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}');"
|
# concat javascript_tag "$('head').append('#{j js}');"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,4 +37,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= share_links(@news_bulletin) %>
|
<%= share_links(@bulletin, 'announcement') %>
|
||||||
|
|
|
@ -39,4 +39,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= share_links(@news_bulletin) %>
|
<%= share_links(@news_bulletin, 'news') %>
|
||||||
|
|
Loading…
Reference in New Issue