Posted by eddie
on Saturday, September 29
In case you haven't seen it,
Visual Bookshelf is one of our Facebook social-shopping applications.
Visual Bookshelf allows you to:
- Show off the books you're reading now, have read, or want to read
- Find people with similar book interests
- Receive computer-generated recommendations
- Find new books to read by browsing your friends' shelves
- Comment on others' shelves
- Leave book reviews
There were some problems with the experience that my users asked me to fix. Their collective requirements:
- Must be able to view all books added all at once
- Must be able to sort on Author and/or Title
- Must be able to filter by category (read, reading, want to read)
- Must be able to search own bookshelf
These requirements were a little tricky to meet. Managing large lists of data without resorting to pagination is something that comes up a lot, so I thought I would share the direction I chose. As a side-effect, users can now easily syndicate their bookshelves to other web properties by simply cutting and pasting an IFRAME snippet. Below is the widget for my own collection, rendered using this new snippet.
If you already use Facebook, feel free to
give it a try. You can get your own syndication widget code by clicking the link under your book rolodex on your Visual Bookshelf home page.
Posted by eddie
on Friday, August 24
Minor mention of our
Visual CD Rack, a sister app of our bigger
bookshelf application...
Read the article
Posted by val
on Wednesday, August 15
Developing applications for Facebook is a pain. The tunnel approach helps a lot to ease that pain but even then I prefer to start a FB app as a regular application, polish the logic, and then convert it to the Facebook one by adding FBML and such. At the early stages of the development I have the mocked parameter in config/facebook.yml set to true and keep this code in config/initializers/facebook.rb:
PERSON_PROFILE_URL = "http://www.facebook.com/profile.php"
FACEBOOK_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/facebook.yml")[RAILS_ENV] || {}
if FACEBOOK_CONFIG['mocked']
class Facebook::FBMLController
require 'ostruct'
FB_SESSION = OpenStruct.new(:session_user_id => 1, :session_key => "12345", :is_valid? => true)
def fbsession; FB_SESSION; end
def require_facebook_install; true; end
def redirect_to(url); super; end
def url_for(*params); super; end
end
module Facebook::Acts::FbUser
module InstanceMethods
def friends
(self.class.find(:all) - [ self ]).collect(&:uid)
end
end
end
end
It mocks out just enough of Facebook on Rails functionality to use FBMLController and acts_as_fb_user from the beginning without Facebook backend.
Posted by val
on Tuesday, August 14
Some facebook applications might have multiple entries. For example, a user might be adding an application (action – new) or replying to an invitation (action – reply, param – id). Since the UI for Facebook application configuration allows to provide only static Post-Add URL it might seem like there is no way to route users back to the original action if they tried to reach when the application has not been installed for them. Luckily, we have full control on the destination via the next paramater of the post install URL. All we need is to build a URL using the incoming call parameters with the exclusion of Facebook-specific ones.
This is an example for Facebook on Rails based code that might go to the application controller:
class ApplicationController < Facebook::FBMLController
protected
before_filter :require_facebook_install
def require_facebook_install
if in_canvas? && !fbsession.is_valid?
redirect_to fbsession.get_install_url(:next => url_for(post_install_params))
false
end
end
def post_install_params
params.merge(:init => true).delete_if { |k, v| k.starts_with?('fb_sig') }
end
end
Notice that the code sets the init parameter so it can be used to identify a post install call
Posted by val
on Tuesday, August 14
Sometimes it is useful to do some action on a Facebook user right after your application has been installed by the user. For example, you might want to push some default FBML to user’s profile in case he does not complete the action you expect him to do after installation. Facebook application configuration allows to provide Post-Add URL to route users to the destination url after the application install. It could be a dedicated post_add action or, in case of a default action where you have some code in the controller and since Facebook limits amount of redirects you can use, it could be a parameter to the url, like &init=true, used to identify that it was a post-install action and execute on it.