<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>init.rb</filename>
    </added>
    <added>
      <filename>lib/spakit.rb</filename>
    </added>
    <added>
      <filename>lib/spakit_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -0,0 +1,134 @@
+Author:: Wen-Tien Chang(mailto:ihower@gmail.com), hlb(mailto:hlb@handlino.com)
+Copyright:: Copyright (c) 2007 Handlino Inc.
+License:: Distributed under the New BSD License
+
+== Description ==
+Spakit is a plugin that makes it very easy to turn your Rails App
+Into a &quot;single page application&quot; (SPA).
+
+To enable SPA, simply install the plug-in, create a spakit layout and use Spakit helper.
+Don't need modify any model/controller code... ;)
+
+Spakit will send xhr request(i.e. prototype's Ajax.Updater ) with ?layout=spakit, 
+and controller return HTML with spakit layout. Note that spakit_form_for not support file upload submit.
+
+By the way, Message plugin is another SPA plugin,using different approach.
+
+== Usage ==
+
+For now, Spakit provide three helper:
+
+ * spakit_link_to, just like remote_link_to
+ * spakit_form_for, just like form_for, but you must specify :url
+ * spakit_form_tag, just like form_tag
+
+by default spakit will replace HTML element called #content.
+
+== Layout code example ==
+You should write flash message here because we often place that in application layout.
+
+# /view/layouts/spakit.rhtml
+
+&lt;p&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;
+&lt;%= yield %&gt;
+
+== History Bookmarks ==
+
+We recommend Really Simple History(RSH) library to handle browser forward/back.
+
+Example code:
+
+# environment.rb
+
+module SpakitHelper
+  @@spa_options = {
+    :update =&gt; 'content-region',
+    :loading =&gt; 'SPA.loading',
+    :complete =&gt; 'SPA.complete'
+  }
+end
+
+# application.js
+# We use jquery syntax, you can use prototype to define your function.
+
+var $j = jQuery.noConflict();
+
+(function($) {
+    SPA = {
+        currentHash: null,
+        currentLocation: null,
+        init: function() {
+            if ( $('#waiting-message').length == 0 ) {
+                $('&lt;div id=&quot;waiting-message&quot;&gt;&lt;img src=&quot;/images/ajax-loader.gif&quot;&gt;&lt;/div&gt;').appendTo('#bd');
+                $('#waiting-message').hide();
+            }
+        },
+        loading: function() {
+            this.init();
+            $('#waiting-message').show();
+        },
+        hide: function() {
+            $('#waiting-message').hide();
+        },
+        historyChange: function(newLocation, historyData, isFresh) {
+            if (isFresh == null) {
+                if (historyStorage.hasKey(newLocation)) {
+                    if (newLocation == &quot;start&quot;) {
+                        newLocation = location.pathname;
+                    }
+
+                    $.ajax({
+                        type: &quot;GET&quot;,
+                        url: newLocation,
+                        data: { layout: &quot;spakit&quot; },
+                        beforeSend: function(){ SPA.loading(); },
+                        complete: function(res, status){
+                            if ( status == &quot;success&quot; || status == &quot;notmodified&quot; ) {
+                                $('#content-region').html(res.responseText);
+                            }
+                            SPA.hide();
+                        }
+                    });
+                }
+            } else {
+                /* new data */
+                dhtmlHistory.add(newLocation, historyData);
+            }
+        },
+        complete: function(newLocation) {
+            this.historyChange(newLocation, &quot;&quot;, true);
+            this.hide();
+        }
+    };
+    
+    SPA.currentHash = window.location.hash;
+    if (SPA.currentHash.length) {
+        if (SPA.currentHash.charAt(0) == '#' &amp;&amp; SPA.currentHash.charAt(1) == '/') {
+            SPA.currentLocation = SPA.currentHash.slice(1);
+        }
+    }
+
+    $(document).ready(function(){
+        dhtmlHistory.initialize();
+        if (SPA.currentLocation) {
+            if (SPA.currentLocation != '#start') {
+                window.location.href = SPA.currentLocation;
+            }
+        } else {
+            dhtmlHistory.addListener(SPA.historyChange);
+            if (dhtmlHistory.isFirstLoad()) {
+                dhtmlHistory.add(&quot;start&quot;, &quot;&quot;);
+            }
+        }
+    });
+
+})(jQuery);
+
+window.dhtmlHistory.create({
+    toJSON: function(o) {
+        return JSON.stringify(o);
+    },
+    fromJSON: function(s) {
+        return JSON.parse(s);
+    }
+});
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2aec2f444093983d2db49e312ad4526f0f7fee01</id>
    </parent>
  </parents>
  <author>
    <name>Wen-Tien Chang</name>
    <email>ihower@ihower.local</email>
  </author>
  <url>http://github.com/ihower/spakit/commit/bcc0c3bcdbca4e7c0e18f76e305dde731ffb4b86</url>
  <id>bcc0c3bcdbca4e7c0e18f76e305dde731ffb4b86</id>
  <committed-date>2008-04-04T00:18:29-07:00</committed-date>
  <authored-date>2008-04-04T00:18:29-07:00</authored-date>
  <message>initial import</message>
  <tree>825503befbf61ab21e583ad5a85cdf33ebe2e43c</tree>
  <committer>
    <name>Wen-Tien Chang</name>
    <email>ihower@ihower.local</email>
  </committer>
</commit>
