2010-05-11 21:38:52 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2011-06-08 14:33:33 +00:00
|
|
|
class ThemeAssetUploader < CarrierWave::Uploader::Base
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-06-08 14:33:33 +00:00
|
|
|
include Locomotive::CarrierWave::Uploader::Asset
|
|
|
|
|
2010-06-02 14:31:01 +00:00
|
|
|
def store_dir
|
2011-06-08 14:33:33 +00:00
|
|
|
self.build_store_dir('sites', model.site_id, 'theme', model.folder)
|
2010-10-10 14:37:34 +00:00
|
|
|
end
|
2010-10-07 00:45:41 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def extension_white_list
|
2011-01-03 10:50:09 +00:00
|
|
|
%w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico)
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-01-03 20:53:33 +00:00
|
|
|
def self.url_for(site, path)
|
|
|
|
build(site, path).url
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.build(site, path)
|
|
|
|
asset = ThemeAsset.new(:site => site, :folder => File.dirname(path))
|
|
|
|
uploader = ThemeAssetUploader.new(asset)
|
|
|
|
uploader.retrieve_from_store!(File.basename(path))
|
|
|
|
uploader
|
|
|
|
end
|
|
|
|
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|