engine/app/uploaders/theme_asset_uploader.rb

27 lines
615 B
Ruby
Raw Normal View History

2010-05-11 21:38:52 +00:00
# encoding: utf-8
class ThemeAssetUploader < CarrierWave::Uploader::Base
include Locomotive::CarrierWave::Uploader::Asset
def store_dir
self.build_store_dir('sites', model.site_id, 'theme', model.folder)
2010-10-10 14:37:34 +00:00
end
2010-05-11 21:38:52 +00:00
def extension_white_list
%w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico htc)
2010-05-11 21:38:52 +00:00
end
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
end