add url generate

This commit is contained in:
Matthew K. Fu JuYuan 2012-09-18 17:37:52 +08:00
parent c813a6143b
commit 1240064e23
1 changed files with 5 additions and 1 deletions

View File

@ -222,11 +222,15 @@ module ApplicationHelper
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}?key=#{key}", :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,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
def generate_fb_url(object,key)
"http://#{request.env['HTTP_HOST']}/share/#{object.class.to_s.underscore}/#{object.id}?key=#{key}"
end
def wrap_string_with(str,options={}) def wrap_string_with(str,options={})
line_width = options[:line_width] || 12 line_width = options[:line_width] || 12
wrap_mark = options[:wrap_mark] || "<br />" wrap_mark = options[:wrap_mark] || "<br />"