Class: Locomotive::ThemeAssetUploader

Inherits:
CarrierWave::Uploader::Base show all
Includes:
CarrierWave::Uploader::Asset
Defined in:
app/uploaders/locomotive/theme_asset_uploader.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CarrierWave::Uploader::Asset

#image?, #set_content_type_of_model, #set_size, #set_width_and_height

Methods inherited from CarrierWave::Uploader::Base

#build_store_dir, #to_label, #to_liquid

Class Method Details

.build(site, path) ⇒ Object



20
21
22
23
24
25
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 20

def self.build(site, path)
  asset     = site.theme_assets.build(folder: File.dirname(path))
  uploader  = ThemeAssetUploader.new(asset)
  uploader.retrieve_from_store!(File.basename(path))
  uploader
end

.content_typesObject



27
28
29
30
31
32
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 27

def self.content_types
  # pdf is not considered as a custom content type for theme assets.
  list = super.clone
  list.delete(:pdf)
  list
end

.url_for(site, path) ⇒ Object



16
17
18
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 16

def self.url_for(site, path)
  build(site, path).url
end

Instance Method Details

#extension_white_listObject



12
13
14
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 12

def extension_white_list
  %w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico htc)
end

#store_dirObject



8
9
10
# File 'app/uploaders/locomotive/theme_asset_uploader.rb', line 8

def store_dir
  self.build_store_dir('sites', model.site_id, 'theme', model.folder)
end