<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>public/javascripts/jquery/jquery.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,11 +1,11 @@
 class SitesController &lt; ApplicationController
+  before_filter :find_site, :only =&gt; [:show, :deploy, :log]
   
   def index
     @sites = Site.all
   end
   
   def show
-    @site = Site.find_by_url!(params[:id])
     render :&quot;show_#{@site.state}&quot;
   end
   
@@ -23,4 +23,24 @@ class SitesController &lt; ApplicationController
     end
   end
   
+  def deploy
+    @site.deploy!
+    redirect_to site_path(@site) 
+  end
+  
+  def log
+    if File.exists?(@site.log_file)
+      render :text =&gt; `tail -n 1000 #{@site.log_file}`, :content_type =&gt; 'text/plain', :status =&gt; (@site.complete? ? :ok : :partial_content)
+    else
+      render :nothing =&gt; true
+    end
+  end
+    
+  
+  protected
+  
+    def find_site
+      @site = Site.find_by_url!(params[:id])
+    end
+    
 end</diff>
      <filename>app/controllers/sites_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,10 @@ class Site &lt; ActiveRecord::Base
     [self.url, App.server[:domain]].join('.')
   end
   
+  def log_file
+    File.join(Rails.root, 'log', &quot;#{self.url}.log&quot;)
+  end
+  
   protected
   
     def generate_token</diff>
      <filename>app/models/site.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,4 @@
 - content_for :title, @site.name
-- content_for :meta, &quot;current state: #{@site.state}&quot;
\ No newline at end of file
+- content_for :meta, &quot;current state: #{@site.state}&quot;
+
+%pre.log{:&quot;data-location&quot; =&gt; log_site_url(@site)}= h render(:file =&gt; @site.log_file) if File.exists?(@site.log_file)
\ No newline at end of file</diff>
      <filename>app/views/sites/show_deploying.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
 ActionController::Routing::Routes.draw do |map|
-  map.resources :sites, :member =&gt; {:deploy =&gt; :put}
+  map.resources :sites, :member =&gt; {:deploy =&gt; :put, :log =&gt; :get}
   map.root      :controller =&gt; :sites
 end</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -0,0 +1,29 @@
+$(function(){
+  $('.log').each(function(){
+    scrollToBottom(this);
+  })
+  tailLog();
+});
+
+function scrollToBottom(scrollable) {
+  $(scrollable).attr('scrollTop', $(scrollable).attr('scrollHeight'));
+}
+
+function tailLog() {
+  if($('.log').length) {
+    $('.log').load(
+      $('.log').attr('data-location'),
+      '',
+      function(responseText, textStatus, XMLHttpRequest){ 
+        scrollToBottom(this);
+        if(XMLHttpRequest.statusText == 'Success') {
+          alert('Install Complete');
+        } else {
+          // Status == 'Partial Content'
+          // lets get more
+          setTimeout(&quot;tailLog()&quot;, 3000);
+        }
+      }
+    );
+  }
+}
\ No newline at end of file</diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
    <modified>
      <diff>@@ -146,4 +146,10 @@ table .main { width: 100%; }
 }
 .html ul, .html ol  { margin-left: 2em; margin-bottom: 1em; }
 .html ul li   { margin-bottom: 0.5em; list-style: disc; }
-.html ol li   { margin-bottom: 0.5em; list-style: decimal; }
\ No newline at end of file
+.html ol li   { margin-bottom: 0.5em; list-style: decimal; }
+
+/* Log File */
+.log {
+  height: 400px; overflow: auto; padding: 10px;
+  border: 1px solid #C6C6C6; background-color: #F9F9F9;
+}
\ No newline at end of file</diff>
      <filename>public/stylesheets/application.css</filename>
    </modified>
    <modified>
      <diff>@@ -69,4 +69,16 @@ class SitesControllerTest &lt; ActionController::TestCase
     end
   end
   
+  context 'PUT /sites/:url/deploy' do
+    setup do
+      @site = Factory.build(:site, :url =&gt; 'site')
+      Site.expects(:find_by_url!).with(@site.url).returns(@site)
+      @site.expects(:deploy!).returns(true)
+      put :deploy, :id =&gt; @site.to_param
+    end
+    
+    should_assign_to(:site) { @site }
+    should_redirect_to('the site page again') { site_path(@site) }
+  end
+  
 end</diff>
      <filename>test/functional/sites_controller_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>015effd7b49169b614bbef440cd299cebb060c50</id>
    </parent>
  </parents>
  <author>
    <name>jdpace</name>
    <email>jared@codewordstudios.com</email>
  </author>
  <url>http://github.com/jdpace/wp-automator/commit/d005b11936baf711ce875906955e699f230bf975</url>
  <id>d005b11936baf711ce875906955e699f230bf975</id>
  <committed-date>2009-09-29T15:35:48-07:00</committed-date>
  <authored-date>2009-09-29T15:35:48-07:00</authored-date>
  <message>A site can have a log file that a user can view while deploying to see what's going on.</message>
  <tree>e66c5c9cf7bf62e671744cf582be42cc97961fe2</tree>
  <committer>
    <name>jdpace</name>
    <email>jared@codewordstudios.com</email>
  </committer>
</commit>
