<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,9 @@
 What's new in Kawaii?
 
+November 7, 2008:
+- Fixed: bug that prevented the 'Save Snippet' button from appearing on the initial tab
+- Added ability to store snippets locally in an ActiveRecord model (KawaiiSnippet)
+
 August 11, 2008:
 
 - Client-side pagination is in place for the datatable, so you can return many results.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -60,6 +60,13 @@ please add in the following keys to the YAML file:
   
 &quot;bucket_name&quot; is the location where the snippet files will be saved.
 
+If you wish to store your snippets locally, please add in the following
+to the YAML file
+
+  snippet_storage: local
+  
+** Don't forget to run the migration before accessing Kawaii **
+
 4. Restart your application, and open a browser window to 
 http://localhost:3000/kawaii
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -27,6 +27,12 @@ class KawaiiGenerator &lt; Rails::Generator::Base
       # Controllers
       m.directory File.join('app/controllers')
       m.file 'controllers/kawaii_controller.rb', File.join('app/controllers', &quot;kawaii_controller.rb&quot;)
+      
+      # Local Snippets
+      m.directory File.join('app/models')
+      m.file 'lib/kawaii_snippets.rb', File.join('lib', 'kawaii_snippets.rb')
+      m.file 'models/kawaii_snippet.rb', File.join('app/models', 'kawaii_snippet.rb')
+      m.migration_template 'migrations/create_kawaii_snippets.rb', 'db/migrate', {:migration_file_name =&gt; 'create_kawaii_snippets'}
 
       # Views
       m.directory File.join('app/views/kawaii')
@@ -68,8 +74,7 @@ class KawaiiGenerator &lt; Rails::Generator::Base
       m.file 'stylesheets/kawaii/transparent.gif', File.join('public/stylesheets/kawaii', &quot;transparent.gif&quot;)
       
       # Too cute handlers
-    end
-    
+    end    
   end
-  
+
 end</diff>
      <filename>kawaii_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,9 +23,16 @@ class KawaiiController &lt; ApplicationController
   def load_snippet
     get_bucket
     @snippet = @bucket[params[:id]]
-    
-    render :update do |page|
-      page.call 'Kawaii.add_tab', params[:id], @snippet.value
+    if @snippet
+      render :update do |page|
+        page.call 'Kawaii.add_tab', params[:id], @snippet.value
+      end
+    else
+      @snippets = @bucket.objects
+      render :update do |page|
+        page.alert 'The selected snippet could not be loaded'
+        page.replace_html 'snippets', :partial =&gt; 'snippets'
+      end
     end
   end
   
@@ -39,8 +46,13 @@ class KawaiiController &lt; ApplicationController
   end
   
   def save_query
-    AWS::S3::S3Object.store(params[:snippet_name], params[:query], bucket_name)
+    if KAWAII_OPTIONS['snippet_storage'] == 'local'
+      KawaiiSnippet.create(:key =&gt; params[:snippet_name], :value =&gt; params[:query])
+    else
+      AWS::S3::S3Object.store(params[:snippet_name], params[:query], bucket_name)
+    end
     get_bucket
+    @snippets = @bucket.objects
     render :update do |page|
       page.replace_html 'snippets', :partial =&gt; 'snippets'
       page.hide 'saving_snippet'
@@ -97,10 +109,14 @@ class KawaiiController &lt; ApplicationController
   
   def get_bucket
     if KAWAII_OPTIONS['snippets_enabled']
-      begin
-        @bucket = AWS::S3::Bucket.find(bucket_name)
-      rescue AWS::S3::NoSuchBucket
-        @bucket = AWS::S3::Bucket.create(bucket_name)
+      if KAWAII_OPTIONS['snippet_storage'] == 'local'
+        @bucket = KawaiiSnippets.new
+      else
+        begin
+          @bucket = AWS::S3::Bucket.find(bucket_name)
+        rescue AWS::S3::NoSuchBucket
+          @bucket = AWS::S3::Bucket.create(bucket_name)
+        end
       end
     end    
   end</diff>
      <filename>templates/controllers/kawaii_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,16 +7,20 @@ KAWAII_OPTIONS = YAML.load_file(&quot;#{RAILS_ROOT}/config/kawaii.yml&quot;)
 
 # If snippets are enabled
 if KAWAII_OPTIONS['snippets_enabled']
+
+  if KAWAII_OPTIONS['snippet_storage'] == 'local'
+    # We're using local snippets so there's nothing to connect to...
+  else  
+    unless KAWAII_OPTIONS['access_key_id'] and KAWAII_OPTIONS['secret_access_key'] and KAWAII_OPTIONS['bucket_name']
+      raise &quot;If you want to enable snippets, you must add access_key_id, secret_access_key and bucket_name to kawaii.yml!&quot;
+    end
   
-  unless KAWAII_OPTIONS['access_key_id'] and KAWAII_OPTIONS['secret_access_key'] and KAWAII_OPTIONS['bucket_name']
-    raise &quot;If you want to enable snippets, you must add access_key_id, secret_access_key and bucket_name to kawaii.yml!&quot;
-  end
-  
-  require 'aws/s3'
+    require 'aws/s3'
 
-  AWS::S3::Base.establish_connection!(
-      :access_key_id     =&gt; KAWAII_OPTIONS['access_key_id'],
-      :secret_access_key =&gt; KAWAII_OPTIONS['secret_access_key']
-  )
+    AWS::S3::Base.establish_connection!(
+        :access_key_id     =&gt; KAWAII_OPTIONS['access_key_id'],
+        :secret_access_key =&gt; KAWAII_OPTIONS['secret_access_key']
+    )
+  end  
   
 end</diff>
      <filename>templates/initializers/kawaii.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,6 @@ Kawaii = {
     this.tab_view = new YAHOO.widget.TabView('console_tabs');
     this.tab_number = 1
     this.wrap_results = true
-    this.add_tab()
     
     this.snippets_enabled = ($('snippets') != null)
     
@@ -16,6 +15,8 @@ Kawaii = {
       $('snippets').show()
       new Ajax.Request('/kawaii/snippets', {asynchronous:true, evalScripts:true})
     }
+
+    this.add_tab()
                           
   },
   </diff>
      <filename>templates/javascripts/kawaii/kawaii.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c00911fcf8a474d0a2958cb6950b56720299caba</id>
    </parent>
  </parents>
  <author>
    <name>Paul Smith</name>
    <email>paul@paul-smiths-mac-mini.local</email>
  </author>
  <url>http://github.com/eviltrout/kawaii/commit/d7066e442a65c07eee7c2795d2f759deb0a935b9</url>
  <id>d7066e442a65c07eee7c2795d2f759deb0a935b9</id>
  <committed-date>2008-11-07T04:14:29-08:00</committed-date>
  <authored-date>2008-11-07T04:14:29-08:00</authored-date>
  <message>Missed some files...</message>
  <tree>aaed3c004f3db31723541d6374ddb8d1fbaacac7</tree>
  <committer>
    <name>Paul Smith</name>
    <email>paul@paul-smiths-mac-mini.local</email>
  </committer>
</commit>
