2010-05-11 21:38:52 +00:00
|
|
|
module Admin::AssetsHelper
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def vignette_tag(asset)
|
2011-03-05 22:27:26 +00:00
|
|
|
if asset.image?
|
|
|
|
html, css = image_tag(asset.vignette_url), 'image'
|
|
|
|
else
|
|
|
|
css = "icon #{asset.content_type}"
|
|
|
|
html = asset.content_type.to_s == 'other' ? truncate(asset.extname, :length => 3) : asset.content_type
|
|
|
|
html = '?' if html.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
content_tag(:div, content_tag(:div, html, :class => 'inside'), :class => css)
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def image_dimensions_and_size(asset)
|
2010-07-13 00:46:17 +00:00
|
|
|
content_tag(:small, "#{asset.width}px x #{asset.height}px | #{number_to_human_size(asset.size)}")
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
def allow_plain_text_editing?(asset)
|
2011-01-29 16:24:37 +00:00
|
|
|
asset.new_record? || asset.stylesheet_or_javascript?
|
|
|
|
end
|
|
|
|
|
|
|
|
def display_plain_text?(asset)
|
|
|
|
if asset.new_record?
|
|
|
|
asset.performing_plain_text?
|
|
|
|
else
|
|
|
|
asset.stylesheet_or_javascript?
|
|
|
|
end
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
|
|
|
end
|