Module Facebooker::Rails::Helpers
In: lib/facebooker/rails/helpers.rb

Facebook specific helpers for creating FBML

All helpers that take a user as a parameter will get the Facebook UID from the facebook_id attribute if it exists. It will use to_s if the facebook_id attribute is not present.

Methods

Constants

FB_DIALOG_BUTTON_VALID_OPTION_KEYS = [:close_dialog, :href, :form_id, :clickrewriteurl, :clickrewriteid, :clickrewriteform]
FB_NAME_OPTION_KEYS_TO_TRANSFORM = {:first_name_only => :firstnameonly, :last_name_only => :lastnameonly, :show_network => :shownetwork, :use_you => :useyou, :if_cant_see => :ifcantsee, :subject_id => :subjectid}
FB_NAME_VALID_OPTION_KEYS = [:firstnameonly, :linked, :lastnameonly, :possessive, :reflexive, :shownetwork, :useyou, :ifcantsee, :capitalize, :subjectid]
FB_PRONOUN_OPTION_KEYS_TO_TRANSFORM = {:use_you => :useyou, :use_they => :usethey}
FB_PRONOUN_VALID_OPTION_KEYS = [:useyou, :possessive, :reflexive, :objective, :usethey, :capitalize]
FB_REF_VALID_OPTION_KEYS = [:url, :handle]
FB_PHOTO_VALID_OPTION_KEYS = [:uid, :size, :align]
VALID_FB_SHARED_PHOTO_SIZES = [:thumb, :small, :normal, :square]
VALID_FB_PHOTO_SIZES = VALID_FB_SHARED_PHOTO_SIZES
VALID_FB_PROFILE_PIC_SIZES = VALID_FB_SHARED_PHOTO_SIZES
VALID_PERMISSIONS = [:email, :offline_access, :status_update, :photo_upload, :create_listing]
FB_TAB_ITEM_VALID_OPTION_KEYS = [:align, :selected]
VALID_FB_SHARED_ALIGN_VALUES = [:left, :right]
VALID_FB_PHOTO_ALIGN_VALUES = VALID_FB_SHARED_ALIGN_VALUES
VALID_FB_TAB_ITEM_ALIGN_VALUES = VALID_FB_SHARED_ALIGN_VALUES

Public Instance methods

Create a facebook form using <fb:editor>

It yields a form builder that will convert the standard rails form helpers into the facebook specific version.

Example:

 <% facebook_form_for(:poke,@poke,:url => create_poke_path) do |f| %>
   <%= f.text_field :message, :label=>"message" %>
   <%= f.buttons "Save Poke" %>
 <% end %>

 will generate

 <fb:editor action="/pokes/create">
   <fb:editor-text name="poke[message]" id="poke_message" value="" label="message" />
   <fb:editor-buttonset>
    <fb:editor-button label="Save Poke"
   </fb:editor-buttonset>
 </fb:editor>

Render flash values as <fb:message> and <fb:error> tags

values in flash[:notice] will be rendered as an <fb:message>

values in flash[:error] will be rendered as an <fb:error> TODO: Allow flash[:info] to render fb_explanation

Return the URL for the about page of the application

Renders an action using the <fb:action> tag

Embed a discussion board named xid on the current page

Create a comment area All the data for this content area is stored on the facebook servers. See: wiki.developers.facebook.com/index.php/Fb:comments for full details

Render a <fb:create-button> tag For use inside <fb:dashboard>

Create a dashboard. It can contain fb_action, fb_help, and fb_create_button

For Example:

  <% fb_dashboard do %>
    <%= APP_NAME %>
    <%= fb_action 'My Matches', search_path %>
    <%= fb_help 'Feedback', "http://www.facebook.com/apps/application.php?id=6236036681" %>
    <%= fb_create_button 'Invite Friends', main_path %>
  <% end %>

Create an fb:dialog id must be a unique name e.g. "my_dialog" cancel_button is true or false

Render fb:else tag Must be used within if block such as fb_if_is_user or fb_if_is_app_user . See example in fb_if_is_app_user

Render an <fb:error> tag If message and text are present then this will render fb:error and fb:message tag TODO: Optionally takes a decoration tag with value of ‘no_padding’ or ‘shorten‘

Render an <fb:explanation> tag If message and text are present then this will render fb:error and fb:message tag TODO: Optionally takes a decoration tag with value of ‘no_padding’ or ‘shorten‘

Create a Google Analytics tag

uacct: Your Urchin/Google Analytics account ID.

Render a <fb:help> tag For use inside <fb:dashboard>

 Render if-is-app-user tag
 This tag renders the enclosing content only if the user specified has accepted the terms of service for the application.
 Use fb_if_user_has_added_app to determine wether the user has added the app.
 Example:
 <% fb_if_is_app_user(@facebook_user) do %>
                           Thanks for accepting our terms of service!
                         <% fb_else do %>
                           Hey you haven't agreed to our terms.  <%= link_to("Please accept our terms of service.", :action => "terms_of_service") %>
                         <% end %>

<% end %>

Render fb:if-is-user tag This tag only renders enclosing content if the user is one of those specified user can be a single user or an Array of users Example: <% fb_if_is_user(@check_user) do %>

                             <%= fb_name(@facebook_user) %> are one of the users. <%= link_to("Check the other side", :action => "friend") %>
                        <% fb_else do %>
                          <%= fb_name(@facebook_user) %>  are not one of the users  <%= fb_name(@check_user) %>
                            <%= link_to("Check the other side", :action => "you") %>
                        <% end %>

<% end %>

 Render if-user-has-added-app tag
 This tag renders the enclosing content only if the user specified has installed the application

 Example:
 <% fb_if_user_has_added_app(@facebook_user) do %>
                           Hey you are an app user!
                         <% fb_else do %>
                           Hey you aren't an app user.  <%= link_to("Add App and see the other side.", :action => "added_app") %>
                         <% end %>

<% end %>

Create an fb:request-form with an fb_multi_friend_selector inside

The content of the block are used as the message on the form,

For example:

 <% fb_multi_friend_request("Poke","Choose some friends to Poke",create_poke_path) do %>
   If you select some friends, they will see this message.
   <%= fb_req_choice("They will get this button, too",new_poke_path) %>
 <% end %>

Render an <fb:multi-friend-selector> with the passed in welcome message Full version shows all profile pics for friends. See: wiki.developers.facebook.com/index.php/Fb:multi-friend-selector for options Note: I don‘t think the block is used here.

Render a condensed <fb:multi-friend-selector> with the passed in welcome message Condensed version show checkboxes for each friend. See: wiki.developers.facebook.com/index.php/Fb:multi-friend-selector_%28condensed%29 for options Note: I don‘t think the block is used here.

Render an fb:name tag for the given user This renders the name of the user specified. You can use this tag as both subject and object of a sentence. See wiki.developers.facebook.com/index.php/Fb:name for full description. Use this tag on FBML pages instead of retrieving the user‘s info and rendering the name explicitly.

Content for the narrow profile box goes in this tag

Render an fb:photo tag. photo is either a Facebooker::Photo or an id of a Facebook photo or an object that responds to photo_id. See: wiki.developers.facebook.com/index.php/Fb:photo for complete list of options.

Render an <fb:profile-pic> for the specified user.

You can optionally specify the size using the :size=> option.

Valid sizes are :thumb, :small, :normal and :square

Render an <fb:pronoun> tag for the specified user Options give flexibility for placing in any part of a sentence. See wiki.developers.facebook.com/index.php/Fb:pronoun for complete list of options.

Render an fb:ref tag. Options must contain either url or handle.

  • url The URL from which to fetch the FBML. You may need to call fbml.refreshRefUrl to refresh cache
  • handle The string previously set by fbml.setRefHandle that identifies the FBML

See wiki.developers.facebook.com/index.php/Fb:ref for complete description

Render a button in a request using the <fb:req-choice> tag url must be an absolute url This should be used inside the block of an fb_multi_friend_request

Create an fb:request-form without a selector

The block passed to this tag is used as the content of the form

The message param is the name sent to content_for that specifies the body of the message

For example,

 <% content_for("invite_message") do %>
   This gets sent in the invite. <%= fb_req_choice("with a button!",new_poke_path) %>
 <% end %>
 <% fb_request_form("Poke","invite_message",create_poke_path) do %>
   Send a poke to: <%= fb_friend_selector %> <br />
   <%= fb_request_form_submit %>
 <% end %>

Create a submit button for an <fb:request-form> If the request is for an individual user you can optionally Provide the user and a label for the request button. For example

  <% content_for("invite_user") do %>
    This gets sent in the invite. <%= fb_req_choice("Come join us!",new_invite_path) %>
  <% end %>
  <% fb_request_form("Invite","invite_user",create_invite_path) do %>
    Invite <%= fb_name(@facebook_user.friends.first.id)%> to the party <br />
    <%= fb_request_form_submit(@facebook_user.friends.first.id,"Invite %n") %>
  <% end %>

See: wiki.developers.facebook.com/index.php/Fb:request-form-submit for options

Render an <fb:success> tag If message and text are present then this will render fb:error and fb:message tag TODO: Optionally takes a decoration tag with value of ‘no_padding’ or ‘shorten‘

Render an fb:tab_item tag. Use this in conjunction with fb_tabs Options can contains :selected => true to indicate that a tab is the current tab. See: wiki.developers.facebook.com/index.php/Fb:tab-item for complete list of options

Render an fb:tabs tag containing some number of fb:tab_item tags. Example: <% fb_tabs do %>

            <%= fb_tab_item("Home", "home") %>
                  <%= fb_tab_item("Office", "office") %>

<% end %>

Adds a title to the title bar

Facebook | App Name | This is the canvas page window title

title: This is the canvas page window

Create a Facebook wall. It can contain fb_wall_posts

For Example:

  <% fb_wall do %>
    <%= fb_wall_post(@user,"This is my message") %>
    <%= fb_wall_post(@otheruser,"This is another message") %>
  <% end %>
fb_wall_post(user,message)

Alias for fb_wallpost

Render an <fb:wallpost> tag TODO: Optionally takes a time parameter t = int The current time, which is displayed in epoch seconds.

Content for the wide profile box goes in this tag

Protected Instance methods

[Validate]