<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/20090702030411_reset_current_theme.rb</filename>
    </added>
    <added>
      <filename>lib/tasks/s3.rake</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -33,11 +33,12 @@ script/server
 sudo gem install heroku --no-ri --no-rdoc
 heroku create
 # Set the variables for your production environment in config/config.yml
+rake s3:create
 rake heroku:config
 git push heroku master
 heroku rake db:schema:load
 heroku open
-# Note that uploads and email don't work (yet...)
+# Note that email won't work (yet...)
 # Read more about Heroku here: http://heroku.com/
 
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ module ApplicationHelper
     
   def theme_css
     return '&lt;style type=&quot;text/css&quot;&gt;@import &quot;/stylesheets/application.css&quot;;&lt;/style&gt;' if @settings.theme.blank? 
-    return '&lt;style type=&quot;text/css&quot;&gt;@import &quot;/themes/' + @settings.theme + '&quot;;&lt;/style&gt;'
+    return &quot;&lt;style type=\&quot;text/css\&quot;&gt;@import #{@settings.theme};&lt;/style&gt;&quot;
   end
 
   def page_title</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,15 @@ class Avatar &lt; ActiveRecord::Base
   belongs_to :user
   belongs_to :current_avatar_user, :foreign_key =&gt; 'current_user_id', :class_name =&gt; 'User'
   
-  has_attached_file :attachment, :url =&gt; &quot;/avatars/:filename&quot;, :storage =&gt; :filesystem
-  
+  if CONFIG['s3']
+    has_attached_file :attachment, :storage =&gt; :s3, :path =&gt; &quot;avatars/:filename&quot;,
+                      :bucket =&gt; CONFIG['s3_bucket_name'], # TODO is there a way to share this between models?
+                      :s3_credentials =&gt; { :access_key_id =&gt; CONFIG['s3_access_id'], :secret_access_key =&gt; CONFIG['s3_secret_key'] },
+                      :s3_headers =&gt; { 'Cache-Control' =&gt; 'max-age=315576000', 'Expires' =&gt; 10.years.from_now.httpdate }
+  else
+    has_attached_file :attachment, :storage =&gt; :filesystem, :url =&gt; &quot;/avatars/:filename&quot;
+  end
+    
   validates_attachment_size :attachment, :less_than =&gt; 500.kilobytes
   validates_attachment_content_type :attachment, :content_type =&gt; /image/
   </diff>
      <filename>app/models/avatar.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,8 +5,15 @@ class Header &lt; ActiveRecord::Base
   attr_accessible :description
   
   belongs_to :user
-  
-  has_attached_file :attachment, :url =&gt; &quot;/headers/:filename&quot;, :storage =&gt; :filesystem
+    
+  if CONFIG['s3']
+    has_attached_file :attachment, :storage =&gt; :s3, :path =&gt; &quot;headers/:filename&quot;,
+                      :bucket =&gt; CONFIG['s3_bucket_name'], # TODO is there a way to share this between models?
+                      :s3_credentials =&gt; { :access_key_id =&gt; CONFIG['s3_access_id'], :secret_access_key =&gt; CONFIG['s3_secret_key'] },
+                      :s3_headers =&gt; { 'Cache-Control' =&gt; 'max-age=315576000', 'Expires' =&gt; 10.years.from_now.httpdate }
+  else
+    has_attached_file :attachment, :storage =&gt; :filesystem, :url =&gt; &quot;/headers/:filename&quot;
+  end
   
   validates_attachment_size :attachment, :less_than =&gt; 500.kilobytes
   validates_attachment_content_type :attachment, :content_type =&gt; /image/</diff>
      <filename>app/models/header.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,8 @@ class Setting &lt; ActiveRecord::Base
   end
   
   def self.current_theme
-    Theme.find_by_attachment_file_name(Setting.first.theme) # TODO refactor to use has_one :current_theme etc
+    current_url = Setting.first.theme
+    Theme.all.detect {|t| t.attachment.url == current_url }
   end
   
   def to_s</diff>
      <filename>app/models/setting.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,16 +4,22 @@ class Theme &lt; ActiveRecord::Base
   
   belongs_to :user
   
-  has_attached_file :attachment, :url =&gt; &quot;/themes/:filename&quot;, :storage =&gt; :filesystem
+  if CONFIG['s3']
+    has_attached_file :attachment, :storage =&gt; :s3, :path =&gt; &quot;themes/:filename&quot;,
+                      :bucket =&gt; CONFIG['s3_bucket_name'], # TODO is there a way to share this between models?
+                      :s3_credentials =&gt; { :access_key_id =&gt; CONFIG['s3_access_id'], :secret_access_key =&gt; CONFIG['s3_secret_key'] },
+                      :s3_headers =&gt; { 'Cache-Control' =&gt; 'max-age=315576000', 'Expires' =&gt; 10.years.from_now.httpdate }
+  else
+    has_attached_file :attachment, :storage =&gt; :filesystem, :url =&gt; &quot;/themes/:filename&quot;
+  end
   
   validates_attachment_size :attachment, :less_than =&gt; 50.kilobytes
-  
   validates_attachment_content_type :attachment, :content_type =&gt; /css/
   
   after_destroy :deselect
   
   def select
-    Setting.first.update_attribute(:theme, self.attachment_file_name)
+    Setting.first.update_attribute(:theme, self.attachment.url)
   end
   
   def deselect</diff>
      <filename>app/models/theme.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,11 +5,12 @@ class Upload &lt; ActiveRecord::Base
   belongs_to :user
   
   if CONFIG['s3']
-    has_attached_file :attachment, :path =&gt; &quot;files/:filename&quot;, :storage =&gt; :s3, :bucket =&gt; CONFIG['s3_bucket_name'],
+    has_attached_file :attachment, :storage =&gt; :s3, :path =&gt; &quot;files/:filename&quot;,
+                      :bucket =&gt; CONFIG['s3_bucket_name'], # TODO is there a way to share this between models?
                       :s3_credentials =&gt; { :access_key_id =&gt; CONFIG['s3_access_id'], :secret_access_key =&gt; CONFIG['s3_secret_key'] },
                       :s3_headers =&gt; { 'Cache-Control' =&gt; 'max-age=315576000', 'Expires' =&gt; 10.years.from_now.httpdate }
   else
-    has_attached_file :attachment, :url =&gt; &quot;/files/:filename&quot;, :storage =&gt; :filesystem
+    has_attached_file :attachment, :storage =&gt; :filesystem, :url =&gt; &quot;/files/:filename&quot;
   end
   
   validates_attachment_size :attachment, :less_than =&gt; 100.megabytes</diff>
      <filename>app/models/upload.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@
       &lt;p&gt;
         &lt;%= link_to h(theme), theme.attachment.url %&gt; by 
         &lt;%= link_to h(theme.user), theme.user %&gt; 
-        &lt;% if @current_theme == theme %&gt;
+        &lt;% if theme == @current_theme %&gt;
           &lt;%= link_to '(deselect)', deselect_theme_path(theme), :method =&gt; :post %&gt;
         &lt;% else %&gt;
           &lt;%= link_to '(select)', select_theme_path(theme), :method =&gt; :post %&gt;</diff>
      <filename>app/views/themes/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,6 @@ production:
   session_secret: # at least 32 char random string and should be unique to your installation and kept secret
   domain: # http://example.com
   mailer: # noreply@example.com
-  s3_access_id: # s3 is generall optional, but required for heroku
-  s3_secret_key: # see https://s3.amazonaws.com/ to sign up for an account
-  s3_bucket_name: # ...
+  s3_access_id: # s3 is generally optional, but required for heroku
+  s3_secret_key: # see the Amazon S3 site to sign up: https://s3.amazonaws.com/
+  s3_bucket_name: # provide a unique bucket name and run &quot;rake s3:create&quot; to create it automatically</diff>
      <filename>config/config.example.yml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ee33101662a29b6b07ebad8c6f4f48f7923b8b2d</id>
    </parent>
  </parents>
  <author>
    <name>Trevor Turk</name>
    <email>trevorturk@yahoo.com</email>
  </author>
  <url>http://github.com/trevorturk/eldorado/commit/d7bdbd3ae39b240e304ecc1199ba2fb48666397e</url>
  <id>d7bdbd3ae39b240e304ecc1199ba2fb48666397e</id>
  <committed-date>2009-07-01T20:18:13-07:00</committed-date>
  <authored-date>2009-07-01T20:18:13-07:00</authored-date>
  <message>finish up optional s3 support, needed migration to change the way the current theme is stored in settings</message>
  <tree>ee5d49d01dc0e228753a5bd89802bae8d5839e40</tree>
  <committer>
    <name>Trevor Turk</name>
    <email>trevorturk@yahoo.com</email>
  </committer>
</commit>
