Skip to content

Commit

Permalink
Remove deprecated and actualize current code
Browse files Browse the repository at this point in the history
  • Loading branch information
chipiga committed May 19, 2010
1 parent b16a67e commit b6c8bd6
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 394 deletions.
37 changes: 15 additions & 22 deletions .gems
@@ -1,22 +1,15 @@
haml-edge --version '2.3.51'
json_pure --version '1.1.9'
rubyforge --version '2.0.3'
highline --version '>=1.4.0'
authlogic --version '>=2.0.11'
activemerchant --version '>=1.4.1'
tlsmail --version '0.0.1'
activerecord-tableless --version '>=0.1.0'
haml --version '2.2.0'
chriseppstein-compass --source gems.github.com --version '0.8.17'
calendar_date_select --version '1.15'
rsl-stringex --source gems.github.com
chronic
javan-whenever --source gems.github.com
searchlogic --version '>= 2.3.5'
mislav-will_paginate --version '~> 2.3.11' --source gems.github.com
rspec-rails --version '>= 1.2.0'
rspec --version '>= 1.2.0'
right_http_connection --version '1.2.4'
right_aws --version '1.10.0'
compass --version '>= 0.8.17' --source gems.rubyforge.org
spree --version '0.9.4'
rails -v 2.3.5
highline -v '1.5.1'
authlogic -v '>=2.1.2'
authlogic-oid -v '1.0.4'
activemerchant -v '1.5.1'
activerecord-tableless -v '0.1.0'
less -v '1.2.20'
stringex -v '1.0.3'
chronic -v '0.2.3'
whenever -v '0.3.7'
searchlogic -v '2.3.5'
will_paginate -v '2.3.11'
faker -v '0.3.1'
paperclip -v '>=2.3.1.1'
state_machine -v '0.8.0'
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_Store
*~
config/aws_s3.yml
33 changes: 13 additions & 20 deletions README.markdown
Expand Up @@ -20,7 +20,7 @@ Install this extension:

<pre>
cd myapp
script/extension install git://github.com/RSpace/spree-heroku.git
script/extension install git://github.com/chipiga/spree-heroku.git
</pre>

Copy the .gems manifest to the root of your application:
Expand All @@ -29,13 +29,21 @@ Copy the .gems manifest to the root of your application:
cp vendor/extensions/heroku/.gems ./
</pre>

Configure the extension with your S3 information:

<pre>
cp vendor/extensions/heroku/config/aws_s3.yml.example vendor/extensions/heroku/config/aws_s3.yml
</pre>

Enter your S3 configuration to vendor/extensions/heroku/config/aws_s3.yml

Create a Heroku application and deploy it:

<pre>
git init
git add .
git commit -m 'Initial create'
heroku create myapp
heroku create --stack bamboo-ree-1.8.7 myapp
git push heroku master
</pre>

Expand All @@ -54,28 +62,13 @@ heroku db:push

Please note that if you choose to load sample data, images will be missing for all products. Spree's bootstrap task copies the images locally, but it doesn't put them on S3, where this extension configures Spree to look for images.

Configure the extension with your S3 information and restart the application on Heroku:

<pre>
heroku console
>> Spree::Heroku::Config.set(:bucket => 'bucket name')
>> Spree::Heroku::Config.set(:access_key_id => 'access key')
>> Spree::Heroku::Config.set(:secret_access_key => 'secret access key')
>> exit
heroku restart
</pre>

That's it - you're done! :)

# Troubleshooting

This extension has been tested with Spree 0.9.1. If you have problems using the extension with a newer version of Spree, it could be due to Spree's gem dependencies having changed. The gems in the heroku .gems manifest must mach the gems and versions required by Spree. This page shows the current dependencies of the newest version of Spree: http://gemcutter.org/gems/spree


# Thanks to

Mooktakim Ahmed for creating the HerokuSassAndCache plugin, which is bundled with this extension.
This extension has been tested with Spree 0.10.2. If you have problems using the extension with a newer version of Spree, it could be due to Spree's gem dependencies having changed. The gems in the heroku .gems manifest must mach the gems and versions required by Spree. This page shows the current dependencies of the newest version of Spree: http://gemcutter.org/gems/spree

# Copyright and license

Copyright (c) 2009 Casper Fabricius, released under the MIT license
Copyright (c) 2009 Casper Fabricius, released under the MIT license
Actualized by Pavel Chipiga
38 changes: 31 additions & 7 deletions app/models/image.rb
@@ -1,12 +1,36 @@
# encoding: utf-8
class Image < Asset
has_attached_file :attachment,
:styles => { :mini => '48x48>', :small => '100x100>', :product => '240x240>', :large => '600x600>' },
:default_style => :product,
:path => "assets/products/:id/:style/:basename.:extension",
:storage => :s3,
:bucket => Spree::Heroku::Config['bucket'],
:url => "/assets/products/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/products/:id/:style/:basename.:extension",
:storage => "s3",
:s3_credentials => {
:access_key_id => Spree::Heroku::Config['access_key_id'],
:secret_access_key => Spree::Heroku::Config['secret_access_key']
}
end
:access_key_id => HEROKU_AWS_S3['access_key_id'],
:secret_access_key => HEROKU_AWS_S3['secret_access_key']
}, # "#{HerokuExtension}/config/aws_s3.yml"
:bucket => HEROKU_AWS_S3['bucket']

# save the w,h of the original image (from which others can be calculated)
# we need to look at the write-queue for images which have not been saved yet
after_post_process :find_dimensions
def find_dimensions
temporary = attachment.queued_for_write[:original]
filename = temporary.path unless temporary.nil?
filename = attachment.path if filename.blank?
geometry = Paperclip::Geometry.from_file(filename)
self.attachment_width = geometry.width
self.attachment_height = geometry.height
end

# if there are errors from the plugin, then add a more meaningful message
def validate
unless attachment.errors.empty?
# uncomment this to get rid of the less-than-useful interrim messages
# errors.clear
errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
false
end
end
end
11 changes: 11 additions & 0 deletions config/aws_s3.yml.example
@@ -0,0 +1,11 @@
common: &common
access_key_id: your_access_key
secret_access_key: secret_access_key

development:
bucket: spree_development
<<: *common

production:
bucket: spree_production
<<: *common
6 changes: 6 additions & 0 deletions config/initializers/heroku.rb
@@ -0,0 +1,6 @@
# encoding: utf-8
begin
HEROKU_AWS_S3 = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'aws_s3.yml'))[Rails.env]
rescue
HEROKU_AWS_S3 = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'aws_s3.yml.example'))[Rails.env]
end
5 changes: 0 additions & 5 deletions config/routes.rb

This file was deleted.

35 changes: 3 additions & 32 deletions heroku_extension.rb
@@ -1,45 +1,16 @@
# encoding: utf-8
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'

class HerokuExtension < Spree::Extension
version "0.1"
version "0.2"
description "Allows Spree to run on Heroku"
url "http://casperfabricius.com"

# Please use heroku/config/routes.rb instead for extension routes.

# def self.require_gems(config)
# config.gem "gemname-goes-here", :version => '1.2.3'
# end
url "http://github.com/chipiga/spree-heroku"

def activate

# Patch up for strange error in a call to javascript include tag
require File.expand_path(File.dirname(__FILE__) + '/lib/javascript_include_tag_patch.rb')

# Disable caching in the production environment
ActionController::Base.perform_caching = false if RAILS_ENV == 'production'
Spree::BaseController.perform_caching = false if RAILS_ENV == 'production'

# Add your extension tab to the admin.
# Requires that you have defined an admin controller:
# app/controllers/admin/yourextension_controller
# and that you mapped your admin in config/routes

#Admin::BaseController.class_eval do
# before_filter :add_yourextension_tab
#
# def add_yourextension_tab
# # add_extension_admin_tab takes an array containing the same arguments expected
# # by the tab helper method:
# # [ :extension_name, { :label => "Your Extension", :route => "/some/non/standard/route" } ]
# add_extension_admin_tab [ :yourextension ]
# end
#end

# make your helper avaliable in all views
# Spree::BaseController.class_eval do
# helper YourHelper
# end
end
end
5 changes: 0 additions & 5 deletions lib/heroku_configuration.rb

This file was deleted.

10 changes: 0 additions & 10 deletions lib/javascript_include_tag_patch.rb

This file was deleted.

22 changes: 0 additions & 22 deletions lib/spree/heroku/config.rb

This file was deleted.

28 changes: 0 additions & 28 deletions lib/tasks/heroku_extension_tasks.rake

This file was deleted.

11 changes: 11 additions & 0 deletions vendor/plugins/file_utils_patch/init.rb
@@ -0,0 +1,11 @@
# encoding: utf-8
Spree::FileUtilz.class_eval do
class << self
# Patch mirror_files method to be silent when using r/o Heroku FS
alias_method :mirror_files_old, :mirror_files
def mirror_files(source, destination, create_backups = false)
return mirror_files_old(source, destination, create_backups) unless Rails.env == 'production'
mirror_files_old(source, destination, create_backups) rescue true
end
end
end
20 changes: 0 additions & 20 deletions vendor/plugins/heroku_sass_and_cache/MIT-LICENSE

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/plugins/heroku_sass_and_cache/README

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/plugins/heroku_sass_and_cache/Rakefile

This file was deleted.

4 changes: 0 additions & 4 deletions vendor/plugins/heroku_sass_and_cache/init.rb

This file was deleted.

1 change: 0 additions & 1 deletion vendor/plugins/heroku_sass_and_cache/install.rb

This file was deleted.

0 comments on commit b6c8bd6

Please sign in to comment.