Fix fb share, redirect with js when the page is not requested by fb but by user

This commit is contained in:
Christophe Vilayphiou 2012-08-08 10:12:21 +08:00
parent db16fdc7b5
commit e9de0e24b4
3 changed files with 8 additions and 4 deletions

View File

@ -112,7 +112,7 @@ class ApplicationController < ActionController::Base
@object = object_class.find(params[:id]) @object = object_class.find(params[:id])
module_app = ModuleApp.first(:conditions => {:key => params[:key]}) 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 @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}" @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}"
render 'shared/render_share', :layout => false render 'shared/render_share', :layout => false
end end

View File

@ -163,7 +163,7 @@ module ApplicationHelper
javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n" javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n" javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n" # javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.coffee'></script>\n" javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/event.js'></script>\n" javascripts << "<script type='text/javascript' src='/assets/event.js'></script>\n"
page.design.javascripts.each do |js| page.design.javascripts.each do |js|
# javascripts << "<script type='text/javascript' src='#{js.file.url}'></script>" # javascripts << "<script type='text/javascript' src='#{js.file.url}'></script>"

View File

@ -3,8 +3,12 @@
<head> <head>
<meta property="og:title" content="<%= @object.title %>" /> <meta property="og:title" content="<%= @object.title %>" />
<meta property="og:description" content="<%= strip_tags @object.subtitle %>" /> <meta property="og:description" content="<%= strip_tags @object.subtitle %>" />
<meta property="og:url" content="<%= @orig_url %>" /> <meta property="og:image" content="<%= ('http://' + request.env['HTTP_HOST'] + @object.image.url) unless @object.image.blank? %>" />
<meta property="og:image" content="<%= 'http://' + request.env['HTTP_HOST'] + @object.image.url %>" /> <script type="text/javascript">
<!--
window.location = "<%= @orig_url %>"
//-->
</script>
</head> </head>
<body> <body>
</body> </body>