2012-02-04 01:10:55 +00:00
|
|
|
module Locomotive
|
|
|
|
module ThemeAssetsHelper
|
2011-11-28 14:40:25 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def image_dimensions_and_size(asset)
|
|
|
|
content_tag(:small, "#{asset.width}px x #{asset.height}px | #{number_to_human_size(asset.size)}")
|
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def plain_text_type(asset)
|
|
|
|
asset.size && asset.size > 40000 ? 'nude' : (asset.content_type || 'stylesheet')
|
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def allow_plain_text_editing?(asset)
|
|
|
|
asset.new_record? || asset.stylesheet_or_javascript?
|
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
def display_plain_text?(asset)
|
|
|
|
if asset.new_record?
|
|
|
|
asset.performing_plain_text?
|
|
|
|
else
|
|
|
|
asset.stylesheet_or_javascript?
|
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
end
|
|
|
|
|
2012-03-01 10:07:22 +00:00
|
|
|
def theme_assets_to_json(list)
|
|
|
|
return nil.to_json if list.nil?
|
|
|
|
list.map { |asset| asset.as_json(:ability => current_ability) }.to_json
|
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
|
2012-02-04 01:10:55 +00:00
|
|
|
end
|
2011-11-28 14:40:25 +00:00
|
|
|
end
|