hella open graph tags
added some basic open graph tags to the posts#show page.
This commit is contained in:
parent
d0b7833dba
commit
307ee15884
4 changed files with 43 additions and 1 deletions
38
app/helpers/open_graph_helper.rb
Normal file
38
app/helpers/open_graph_helper.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
module OpenGraphHelper
|
||||
def og_title(post)
|
||||
meta_tag_with_property('og:title', post_page_title(post))
|
||||
end
|
||||
|
||||
def og_type(post)
|
||||
meta_tag_with_property('og:type', 'article')
|
||||
end
|
||||
|
||||
def og_url(post)
|
||||
meta_tag_with_property('og:url', post_url(post))
|
||||
end
|
||||
|
||||
def og_image(post)
|
||||
if post.photos.present?
|
||||
img_url = post.photos.first.url(:thumb_medium)
|
||||
meta_tag_with_property('og:image', img_url)
|
||||
end
|
||||
end
|
||||
|
||||
def og_site_name
|
||||
meta_tag_with_property('og:site_name', 'Diaspora*')
|
||||
end
|
||||
|
||||
def og_description(post)
|
||||
meta_tag_with_property('og:description', post_page_title(post))
|
||||
end
|
||||
|
||||
def og_page_specific_tags(post)
|
||||
[og_title(post), og_type(post),
|
||||
og_url(post), og_image(post),
|
||||
og_description(post)].join(' ').html_safe
|
||||
end
|
||||
|
||||
def meta_tag_with_property(name, content)
|
||||
content_tag(:meta, '', :property => name, :content => content)
|
||||
end
|
||||
end
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
%meta{:name => "description", :content => "Diaspora*"}
|
||||
%meta{:name => "author", :content => "Diaspora, Inc."}
|
||||
= og_site_name
|
||||
|
||||
%link{:rel => 'shortcut icon', :href => "#{image_path('favicon.png')}" }
|
||||
%link{:rel => 'apple-touch-icon', :href => "#{image_path('apple-touch-icon.png')}"}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
%meta{:name => "MobileOptimized", :content => "320"}
|
||||
/ Force cleartype on WP7
|
||||
%meta{'http-equiv' => "cleartype", :content => 'on'}
|
||||
|
||||
= og_site_name
|
||||
/ Home screen icon (sized for retina displays)
|
||||
%link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'}
|
||||
/ For Nokia devices
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
/%link{:rel => "apple-touch-startup-image", :href => "/images/apple-splash.png"}
|
||||
|
||||
/ Stylesheets
|
||||
|
||||
= stylesheet_link_tag :mobile, :format => 'all'
|
||||
= yield(:custom_css)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
%link{:rel => 'shortcut icon', :href => '/favicon.png'}
|
||||
%link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'}
|
||||
|
||||
= og_site_name
|
||||
%title
|
||||
= page_title yield(:page_title)
|
||||
|
||||
|
|
@ -46,6 +47,7 @@
|
|||
= current_user_atom_tag
|
||||
- if @post.present?
|
||||
%link{:rel => 'alternate', :type => "application/json+oembed", :href => "#{oembed_url(:url => post_url(@post))}"}
|
||||
= og_page_specific_tags(@post)
|
||||
|
||||
= yield(:head)
|
||||
= csrf_meta_tag
|
||||
|
|
|
|||
Loading…
Reference in a new issue