smoother integration with bushi.do

This commit is contained in:
did 2011-04-07 01:34:36 +02:00
parent 917208812b
commit e03d7b5dcc
11 changed files with 62 additions and 32 deletions

View File

@ -23,7 +23,8 @@ gem 'locomotive_carrierwave', '0.5.0.1.beta3', :require => 'carrierwave'
gem 'custom_fields', '1.0.0.beta.9'
gem 'fog', '0.3.7'
gem 'mimetype-fu'
gem 'actionmailer_with_request', :git => 'git://github.com/eric1234/actionmailer_with_request.git'
gem 'actionmailer-with-request', :git => 'git://github.com/weppos/actionmailer_with_request.git'
#:git => 'git://github.com/eric1234/actionmailer_with_request.git'
gem 'heroku', '1.19.1' # '1.18.2'
gem 'bushido'
gem 'httparty', '>= 0.6.1'

View File

@ -1,16 +1,16 @@
GIT
remote: git://github.com/eric1234/actionmailer_with_request.git
revision: 6dd5658d44cc3624596a4fc57e6cde08b7e3bf43
specs:
actionmailer_with_request (0.0.3)
rails (>= 3)
GIT
remote: git://github.com/floehopper/mocha.git
revision: 2b4e868d1907859cd03f407078bd8b630f7d0dd6
specs:
mocha (0.9.12.20110213002255)
GIT
remote: git://github.com/weppos/actionmailer_with_request.git
revision: c1f18f4541554367fe5910fc1bc8caecd7d09682
specs:
actionmailer-with-request (0.3.0)
rails (>= 3)
GIT
remote: https://github.com/wunderbread/xpath.git
revision: d04da707886287e7dfe82705fda5b3d4f65e94c3
@ -274,7 +274,7 @@ DEPENDENCIES
RedCloth (= 4.2.7)
SystemTimer
ZenTest
actionmailer_with_request!
actionmailer-with-request!
autotest
bson_ext (~> 1.3.0)
bushido

View File

@ -8,9 +8,9 @@ class AssetUploader < CarrierWave::Uploader::Base
"sites/#{model.collection.site_id}/assets/#{model.id}"
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
# def cache_dir
# "#{Rails.root}/tmp/uploads"
# end
version :thumb, :if => :image? do
process :resize_to_fill => [50, 50]

View File

@ -4,8 +4,8 @@ class EditableFileUploader < ::CarrierWave::Uploader::Base
"sites/#{model.page.site_id}/pages/#{model.page.id}/files"
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
# def cache_dir
# "#{Rails.root}/tmp/uploads"
# end
end

View File

@ -8,9 +8,9 @@ class ThemeUploader < ::CarrierWave::Uploader::Base
end
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
# def cache_dir
# "#{Rails.root}/tmp/uploads"
# end
def extension_white_list
%w(zip)

View File

@ -1,3 +1,5 @@
require 'locomotive'
# TODO: Make this store to RAILS_ROOT/permanent
# On bushido, the app directory is destroyed on every update, so everything is lost.
@ -7,6 +9,8 @@
CarrierWave.configure do |config|
config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
case Rails.env.to_sym
when :development
@ -14,11 +18,16 @@ CarrierWave.configure do |config|
config.root = File.join(Rails.root, 'public')
when :production
config.storage = :s3
config.s3_access_key_id = ENV['S3_KEY_ID']
config.s3_secret_access_key = ENV['S3_SECRET_KEY']
config.s3_bucket = ENV['S3_BUCKET']
# config.s3_cname = 'ENV['S3_CNAME']
if Locomotive.bushido?
config.storage = :file
config.root = File.join(Rails.root, 'public', 'store')
else
config.storage = :s3
config.s3_access_key_id = ENV['S3_KEY_ID']
config.s3_secret_access_key = ENV['S3_SECRET_KEY']
config.s3_bucket = ENV['S3_BUCKET']
# config.s3_cname = 'ENV['S3_CNAME']
end
end
end
end unless Locomotive.engine?

View File

@ -17,11 +17,10 @@ test:
# set these environment variables on your prod server
production:
<<: *defaults
database: locomotive_prod
# <<: *defaults
# database: locomotive_prod
# other settings for production
# host: <%= ENV['MONGOID_HOST'] %>
# port: <%= ENV['MONGOID_PORT'] %>
# username: <%= ENV['MONGOID_USERNAME'] %>

View File

@ -13,13 +13,13 @@ module Locomotive
end
def copy_initializers
copy_file 'config/initializers/carrierwave.rb', 'config/initializers/carrierwave.rb'
@source_paths = nil # reset it for the find_in_source_paths method
Locomotive::InstallGenerator.source_root(File.expand_path('../templates', __FILE__))
template 'locomotive.rb', 'config/initializers/locomotive.rb'
template 'carrierwave.rb', 'config/initializers/carrierwave.rb'
end
def remove_index_html

View File

@ -0,0 +1,19 @@
CarrierWave.configure do |config|
config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
case Rails.env.to_sym
when :development
config.storage = :file
config.root = File.join(Rails.root, 'public')
when :production
config.storage = :s3
config.s3_access_key_id = ENV['S3_KEY_ID']
config.s3_secret_access_key = ENV['S3_SECRET_KEY']
config.s3_bucket = ENV['S3_BUCKET']
# config.s3_cname = 'ENV['S3_CNAME']
end
end

View File

@ -8,7 +8,7 @@ module Locomotive
included do
validate :subdomain_availability
before_save :check_subdomain_change
before_update :check_subdomain_change
after_save :add_bushido_domains
after_update :record_new_subdomain
@ -22,6 +22,8 @@ module Locomotive
protected
def subdomain_availability
return true if self.new_record?
unless ::Bushido::App.subdomain_available?(self.subdomain)
self.errors.add(:subdomain, :exclusion)
end

View File

@ -46,7 +46,7 @@ describe 'Bushido support' do
context '#enabled' do
it 'tells bushido is enabled from ENV' do
ENV['HOSTING_PLATFORM'] = 'bushido'
ENV['APP_TLD'] = 'bushi.do'
Locomotive.config.hosting = :auto
Locomotive.bushido?.should be_true
end
@ -165,7 +165,7 @@ describe 'Bushido support' do
end
after(:all) do
ENV['HOSTING_PLATFORM'] = ENV['APP_TLD'] = nil
ENV['APP_TLD'] = nil
Locomotive.configure_for_test(true)
end