Module: AssetsHelper
- Defined in:
- app/helpers/assets_helper.rb
Instance Method Summary collapse
- #asset_grid_item(asset) ⇒ Object
- #asset_icon(asset, size = 30) ⇒ Object
- #asset_listing(asset) ⇒ Object
- #audio_player(asset) ⇒ Object
- #display(asset) ⇒ Object
- #image_tag(*args) ⇒ Object
- #link_to_remove(asset) ⇒ Object
- #list_view? ⇒ Boolean
- #square_thumb(image, size = 30) ⇒ Object
- #text_icon(asset, size = 30) ⇒ Object
- #video_player(asset) ⇒ Object
- #view_toggle ⇒ Object
Instance Method Details
#asset_grid_item(asset) ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/assets_helper.rb', line 8 def asset_grid_item(asset) asset_icon(asset, 120) + content_tag(:span, "ID: #{asset.id}", :class => 'id') + content_tag(:span, asset.to_s, :class => 'caption') end |
#asset_icon(asset, size = 30) ⇒ Object
14 15 16 |
# File 'app/helpers/assets_helper.rb', line 14 def asset_icon(asset, size=30) asset.image? ? square_thumb(asset, size) : text_icon(asset, size) end |
#asset_listing(asset) ⇒ Object
3 4 5 6 |
# File 'app/helpers/assets_helper.rb', line 3 def asset_listing(asset) asset_icon(asset) + content_tag(:span, asset.to_s, :class=>'title') end |
#audio_player(asset) ⇒ Object
53 54 55 |
# File 'app/helpers/assets_helper.rb', line 53 def audio_player(asset) %Q{<audio src="#{asset.upload.url}" type="#{asset.upload.mime_type}" controls="controls">} end |
#display(asset) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/assets_helper.rb', line 37 def display(asset) if @asset.image? content_tag :div, image_tag(@asset), :class => "image frame #{@asset.format}" elsif @asset.audio? audio_player(@asset) elsif @asset.video? video_player(@asset) elsif @asset.format == :pdf content_tag :iframe, '', :src => @asset.upload.url, :class => "pdf frame" end end |
#image_tag(*args) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/helpers/assets_helper.rb', line 28 def image_tag(*args) image = args.first if image && image.respond_to?(:upload) super image.upload.url, :width => image.upload.width, :height => image.upload.height else super(*args) end end |
#link_to_remove(asset) ⇒ Object
57 58 59 |
# File 'app/helpers/assets_helper.rb', line 57 def link_to_remove(asset) link_to 'Remove', remove_admin_asset_path(asset), :class => 'action remove', :title => 'Remove Asset' end |
#list_view? ⇒ Boolean
61 62 63 |
# File 'app/helpers/assets_helper.rb', line 61 def list_view? params[:view] == 'list' end |
#square_thumb(image, size = 30) ⇒ Object
23 24 25 26 |
# File 'app/helpers/assets_helper.rb', line 23 def square_thumb(image, size=30) src = image.upload.thumb("#{size}x#{size}#").url image_tag(src, :width=>size, :height => size, :class => "thumbnail #{image.format}") end |
#text_icon(asset, size = 30) ⇒ Object
18 19 20 21 |
# File 'app/helpers/assets_helper.rb', line 18 def text_icon(asset, size=30) css = "width:#{size}px;height:#{size}px;line-height:#{size}px" content_tag(:span, asset.format, :class => "icon #{asset.format}", :style => css) end |
#video_player(asset) ⇒ Object
49 50 51 |
# File 'app/helpers/assets_helper.rb', line 49 def video_player(asset) %Q{<video src="#{asset.upload.url}" type="#{asset.upload.mime_type}" controls="controls">} end |
#view_toggle ⇒ Object
65 66 67 68 |
# File 'app/helpers/assets_helper.rb', line 65 def view_toggle other = list_view? ? 'grid' : 'list' link_to "Switch to #{other} view", admin_assets_path(:view => other) end |