enhance carrierwave settings to support bushi.do
This commit is contained in:
parent
f16201f6cd
commit
09bd73c7ac
@ -5,7 +5,7 @@ class AssetUploader < CarrierWave::Uploader::Base
|
|||||||
include CarrierWave::RMagick
|
include CarrierWave::RMagick
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
"sites/#{model.collection.site_id}/assets/#{model.id}"
|
self.build_store_dir('sites', model.collection.site_id, 'assets', model.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def cache_dir
|
# def cache_dir
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class EditableFileUploader < ::CarrierWave::Uploader::Base
|
class EditableFileUploader < ::CarrierWave::Uploader::Base
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
"sites/#{model.page.site_id}/pages/#{model.page.id}/files"
|
self.build_store_dir('sites', model.page.site_id, 'pages', model.page.id, 'files')
|
||||||
end
|
end
|
||||||
|
|
||||||
# def cache_dir
|
# def cache_dir
|
||||||
|
@ -7,7 +7,7 @@ class ThemeAssetUploader < AssetUploader
|
|||||||
process :set_width_and_height
|
process :set_width_and_height
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
File.join('sites', (model.site_id_was || model.site_id).to_s, 'theme', model.folder_was || model.folder)
|
self.build_store_dir('sites', (model.site_id_was || model.site_id).to_s, 'theme', model.folder_was || model.folder)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stale_model?
|
def stale_model?
|
||||||
|
@ -2,7 +2,7 @@ class ThemeUploader < ::CarrierWave::Uploader::Base
|
|||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
if Locomotive.config.delayed_job
|
if Locomotive.config.delayed_job
|
||||||
"sites/#{model.id}/tmp/themes"
|
self.build_store_dir('sites', model.id, 'tmp', 'themes')
|
||||||
else
|
else
|
||||||
"#{Rails.root}/tmp/themes"
|
"#{Rails.root}/tmp/themes"
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
= f.custom_input :subdomain, :css => 'path' do
|
= f.custom_input :subdomain, :css => 'path' do
|
||||||
%em
|
%em
|
||||||
http://
|
http://
|
||||||
= f.text_field :subdomain, :disabled => (manage_subdomain? ? '' : 'disabled')
|
= f.text_field :subdomain, :readonly => !manage_subdomain?
|
||||||
\.
|
\.
|
||||||
%em
|
%em
|
||||||
= application_domain
|
= application_domain
|
||||||
|
@ -21,6 +21,7 @@ CarrierWave.configure do |config|
|
|||||||
if Locomotive.bushido?
|
if Locomotive.bushido?
|
||||||
config.storage = :file
|
config.storage = :file
|
||||||
config.root = File.join(Rails.root, 'public', 'store')
|
config.root = File.join(Rails.root, 'public', 'store')
|
||||||
|
config.store_dir = 'store'
|
||||||
else
|
else
|
||||||
config.storage = :s3
|
config.storage = :s3
|
||||||
config.s3_access_key_id = ENV['S3_KEY_ID']
|
config.s3_access_key_id = ENV['S3_KEY_ID']
|
||||||
|
@ -33,6 +33,26 @@ module CarrierWave
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Uploader
|
||||||
|
|
||||||
|
class Base
|
||||||
|
|
||||||
|
# alias :super_store_dir :store_dir
|
||||||
|
|
||||||
|
def build_store_dir(*args)
|
||||||
|
default_dir = self.class.store_dir
|
||||||
|
|
||||||
|
if default_dir.blank? || default_dir == 'uploads'
|
||||||
|
File.join(args)
|
||||||
|
else
|
||||||
|
File.join([default_dir] + args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module CarrierWave
|
module CarrierWave
|
||||||
|
Loading…
Reference in New Issue
Block a user