Easily generate facebook opengraph data from your models
This version it is a fork of (https://github.com/capotej/has_opengraph). It works only with Rails 3.x (automatically safe_html!), and it supports:
- facebook like button
- facebook send button
- facebook comments
From your rails directory rails plugin install http://github.com/openmosix/has_opengraph.git
class Movie < ActiveRecord::Base
has_opengraph :title => :name,
:url => :get_url,
:image => :cover_image_url,
:description => :desc,
:type => "movie",
:site_name => "moviesite.com"
def get_url
self.permalink
end
end
<html>
<head>
<%= yield :fb %>
</head>
<body>
<%= yield %>
</body>
</html>
<% content_for :fb do %>
@movie.draw_opengraph
<% end %>
<div class="movie">
<h1><%= @movie.title %></h1>
</div>
<div class="movie-comments">
<span><%= @movie.like_button %></span>
</div>
<div class="movie-comments">
<span><%= @movie.like_button(:width=>300, :show_faces => false, :layout => "button_count", :action => "recommend", :font=>"tahoma") %></span>
</div>
Parameters:
:width
The width of the like box, in pixel. Default: 450.
:show_faces
Show the faces of friends that liked the item. Boolean true/false. Default: true.
:layout
Layout type of the like button. Allowed values: "button_count", "box_count","standard". Default: "standard"
:action
The verb of the like button. Allowed values: "recommend", "like". Default: "like"
:font
The type of font being used. Allowed values: "tahoma", "arial", "lucida grande", "segoe ui", "trebuchet ms", "verdana"
:colorscheme
The type of color scheme used to render the like box. Allowed values: "dark", "light".Default: "light"
:send_button
Enable the send button. Boolean true/false. Default: false.
<div class="movie-comments">
<span><%= @movie.like_button(:send_button => true) %></span>
</div>
<div class="movie-comments">
<span><%= @movie.comments( :width=>600 ) %></span>
</div>
Parameters:
:width
The width of the like box, in pixel. Default: 450.
:num_posts
The number of comments to display below the comments box. Default: 3.
:colorscheme
The type of color scheme used to render the like box. Allowed values: "dark", "light".Default: "light"
Copyright (c) 2010 Julio Capote, released under the MIT license