Add meta to head for fb share

This commit is contained in:
Christophe Vilayphiou 2012-08-08 03:10:26 +08:00
parent 1c62c1a799
commit 3cb182ff8e
3 changed files with 16 additions and 9 deletions

View File

@ -140,7 +140,7 @@ module ApplicationHelper
stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n" stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n" stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
end end
stylesheets << "<link href='/assets/social-share-button.scss' rel='stylesheet' type='text/css' />\n" stylesheets << "<link href='/assets/social-share-button.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css
stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n" stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
@ -162,7 +162,7 @@ module ApplicationHelper
end end
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.coffee'></script>\n" javascripts << "<script type='text/javascript' src='/assets/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>"
@ -214,4 +214,15 @@ module ApplicationHelper
object.strftime("%Y-%m-%d") object.strftime("%Y-%m-%d")
end end
def share_links(object)
js = ''
js << "<meta property='og:title' content='#{object.title}' />\n" rescue ''
js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue ''
js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue ''
content_tag :div, :class => 'fb' do
concat social_share_button_tag
concat javascript_tag "$('head').append('#{j js}');"
end
end
end end

View File

@ -36,6 +36,5 @@
</div> </div>
<% end %> <% end %>
</div> </div>
<div class="fb">
<%= render "shared/addthis_toolbox"%> <%= share_links(@news_bulletin) %>
</div>

View File

@ -39,7 +39,4 @@
<% end %> <% end %>
</div> </div>
<div class="fb"> <%= share_links(@news_bulletin) %>
<%= social_share_button_tag(@news_bulletin.title) %>
<%#= render "shared/addthis_toolbox"%>
</div>