2010-05-11 21:38:52 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2010-06-02 14:31:01 +00:00
|
|
|
class ThemeAssetUploader < AssetUploader
|
2010-05-11 21:38:52 +00:00
|
|
|
|
|
|
|
process :set_content_type
|
|
|
|
process :set_size
|
|
|
|
process :set_width_and_height
|
|
|
|
|
2010-06-02 14:31:01 +00:00
|
|
|
def store_dir
|
|
|
|
"sites/#{model.site_id}/themes/#{model.id}"
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def extension_white_list
|
|
|
|
%w(jpg jpeg gif png css js)
|
|
|
|
end
|
|
|
|
|
|
|
|
def filename
|
|
|
|
if model.slug.present?
|
|
|
|
model.filename
|
|
|
|
else
|
|
|
|
extension = File.extname(original_filename)
|
|
|
|
basename = File.basename(original_filename, extension).slugify(:underscore => true)
|
|
|
|
"#{basename}#{extension}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-02 14:31:01 +00:00
|
|
|
end
|