Class: Tenon::AssetDecorator
Instance Method Summary
collapse
#delete_link, #edit_path, #path, #published?
Instance Method Details
#crop_link ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/decorators/tenon/asset_decorator.rb', line 16
def crop_link
h.action_link(
'Crop',
[:crop, object],
'crop',
class: 'asset-crop',
data: {
'asset-id' => object.id,
'post-crop-handler' => 'Tenon.features.AssetListPostCropHandler'
}
) if object.attachment_content_type.include?('image') || object.attachment_content_type.include?('video')
end
|
#display_name ⇒ Object
11
12
13
14
|
# File 'app/decorators/tenon/asset_decorator.rb', line 11
def display_name
name = object.title.blank? ? object.attachment_file_name : object.title
h.truncate(name, length: 50)
end
|
#download_link ⇒ Object
37
38
39
|
# File 'app/decorators/tenon/asset_decorator.rb', line 37
def download_link
h.action_link('Download', object.attachment.url, 'download', target: '_')
end
|
#edit_link(opts = {}) ⇒ Object
29
30
31
32
33
34
35
|
# File 'app/decorators/tenon/asset_decorator.rb', line 29
def edit_link(opts = {})
defaults = {
'data-modal-remote' => true,
'data-modal-title' => 'Edit Asset'
}
super(opts.merge(defaults))
end
|
#human_size ⇒ Object
7
8
9
|
# File 'app/decorators/tenon/asset_decorator.rb', line 7
def human_size
h.number_to_human_size(object.attachment_file_size)
end
|
#icon ⇒ Object
3
4
5
|
# File 'app/decorators/tenon/asset_decorator.rb', line 3
def icon
h.asset_icon(object)
end
|
#style_urls ⇒ Object
41
42
43
44
45
46
|
# File 'app/decorators/tenon/asset_decorator.rb', line 41
def style_urls
styles = object.attachment.styles.map do |key, style|
[key, object.attachment.url(key)]
end
Hash[styles]
end
|