<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/story/not_signed_in.haml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,11 @@
 class StoryController &lt; ApplicationController
   include ActorRole
   
-  before_filter :require_facebook_user, :except =&gt; [:feed_action]
+  before_filter :require_facebook_user, :except =&gt; [:feed_action, :not_signed_in]
+  
+  def not_signed_in
+    
+  end
   
   def one_line_api
     begin</diff>
      <filename>app/controllers/story_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,10 +11,16 @@
 %h3
   Using javascript to build a form
 %p
-  The comment is built using javascript and opens when
-  = link_to_function &quot;triggered&quot;, &quot;open_feed_form()&quot;
+  The comment is built using javascript
+  %br
+  %i
+    = @user.first_name
+    wants to use the force.
+  %br
+  = text_field_tag &quot;js_comment&quot;, &quot;Go see this movie!&quot;, :id =&gt; &quot;js_comment&quot;
+  %button{:onclick =&gt; &quot;open_feed_form()&quot;} Submit
 %h3
-  Using an iFrame from Facebook - a video is included in this post
+  Using an iFrame from Facebook
 %p
   %fb:serverfbml{ :style =&gt; &quot;width: 755px;&quot; }
     %script{:type =&gt; &quot;text/fbml&quot;}
@@ -30,6 +36,7 @@
 = javascript_tag &quot;window.story_template_id = '#{ZackPublisher.find_bundle_id('story_action')}';&quot;
 %script
   function open_feed_form() {
-  var data = {&quot;role&quot;: &quot;use the force&quot;, &quot;comment&quot;: &quot;This comment was specified with javascript.&quot;};
+  var video_data = {&quot;video_src&quot;: &quot;http://www.youtube.com/v/OssgMY_mkMc&amp;hl=en&amp;fs=1&quot;, &quot;preview_img&quot;: &quot;http://zacknmiri.com/images/f1.znm.png&quot;};
+  var data = {&quot;video&quot;: video_data, &quot;role&quot;: &quot;use the force&quot;, &quot;comment&quot;: document.getElementById(&quot;js_comment&quot;).value};
   FB.Connect.showFeedDialog(window.story_template_id, data, null, null, null, FB.RequireConnect.promptConnect);
   }
\ No newline at end of file</diff>
      <filename>app/views/story/index.haml</filename>
    </modified>
    <modified>
      <diff>@@ -9,4 +9,4 @@
       = seperator
       = link_to &quot;Story Publisher&quot;, :controller =&gt; &quot;story&quot;, :action =&gt; &quot;index&quot;
       = seperator
-      = link_to &quot;Sign Out&quot;, :controller =&gt; &quot;zack&quot;, :action =&gt; &quot;sign_out&quot;
\ No newline at end of file
+      = link_to_function &quot;Sign Out from Facebook&quot;, &quot;FB.Connect.logoutAndRedirect('/')&quot;
\ No newline at end of file</diff>
      <filename>app/views/zack/_footer.haml</filename>
    </modified>
    <modified>
      <diff>@@ -2,3 +2,4 @@
 = javascript_tag &quot;window.api_key = '#{Facebooker.api_key}';&quot;
 = javascript_tag &quot;window.xd_receiver_location = '#{ENV['XD_RECEIVER_LOCATION']}';&quot;
 = javascript_tag &quot;window.facebook_authenticate_location = '#{ENV['FACEBOOK_AUTHENTICATE_LOCATION']}';&quot;
+= javascript_tag &quot;window.facebook_signed_in_url = '#{ENV['FACEBOOK_SIGNED_IN_URL']}';&quot;</diff>
      <filename>app/views/zack/_js_constants.haml</filename>
    </modified>
    <modified>
      <diff>@@ -2,4 +2,5 @@
 .fbconnect
   %fb:login-button{:onclick=&gt;&quot;facebook_button_onclick()&quot;}
 .clearing
-= image_tag &quot;f1.znm.png&quot;
\ No newline at end of file
+= image_tag &quot;f1.znm.png&quot;
+= javascript_tag &quot;window.onload = function() { facebook_onload(false); };&quot;
\ No newline at end of file</diff>
      <filename>app/views/zack/index.haml</filename>
    </modified>
    <modified>
      <diff>@@ -69,6 +69,7 @@ end
 
 ENV['XD_RECEIVER_LOCATION'] = &quot;/zack/connect/xd_receiver.htm&quot;
 ENV['FACEBOOK_AUTHENTICATE_LOCATION'] = &quot;/zack/authenticate&quot;
+ENV['FACEBOOK_SIGNED_IN_URL'] = &quot;/zack/choose_role&quot;
 
 #File: lib/extensions.rb
 module Facebooker</diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,34 @@
+/*
+ * The facebook_onload statement is printed out in the PHP. If the user's logged in
+ * status has changed since the last page load, then refresh the page to pick up
+ * the change.
+ *
+ * This helps enforce the concept of &quot;single sign on&quot;, so that if a user is signed into
+ * Facebook when they visit your site, they will be automatically logged in -
+ * without any need to click the login button.
+ *
+ * @param already_logged_into_facebook  reports whether the server thinks the user
+ *                                      is logged in, based on their cookies
+ *
+ */
+function facebook_onload(already_logged_into_facebook) {
+  // user state is either: has a session, or does not.
+  // if the state has changed, detect that and reload.
+  FB.ensureInit(function() {
+      FB.Facebook.get_sessionState().waitUntilReady(function(session) {
+          var is_now_logged_into_facebook = session ? true : false;
+
+          // if the new state is the same as the old (i.e., nothing changed)
+          // then do nothing
+          if (is_now_logged_into_facebook == already_logged_into_facebook) {
+            return;
+          }
+
+          // otherwise, refresh to pick up the state change
+          window.location = window.facebook_signed_in_url;
+        });
+    });
+}
 
 /*
  * Ensure Facebook app is initialized and call callback afterward</diff>
      <filename>public/javascripts/zack.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7ebccbfdac91d81fd84f7020e875255cf7fa4b59</id>
    </parent>
  </parents>
  <author>
    <name>Chris Hobbs</name>
    <email>chris@spongecell.com</email>
  </author>
  <url>http://github.com/ckhsponge/zacknmiri/commit/4653c6fef38a39b6241bba926184ef58ea402ebe</url>
  <id>4653c6fef38a39b6241bba926184ef58ea402ebe</id>
  <committed-date>2008-12-11T16:11:38-08:00</committed-date>
  <authored-date>2008-12-11T16:11:38-08:00</authored-date>
  <message>auto sign-in and more story work</message>
  <tree>631fe190c09a60ca92199f0976e968336343198e</tree>
  <committer>
    <name>Chris Hobbs</name>
    <email>chris@spongecell.com</email>
  </committer>
</commit>
