Sha256: 79e508a6341b495095ab66fcb10d9205c362623da0961dd35e4123fdd0c23eda

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

module AssetsHelper

  def gallery(assets, size = :square)
    if assets.respond_to? :images and assets.images.any?
      images = assets.images
    elsif assets.any?
      images = assets.reject{|a| !a.content_type.starts_with?('image')}
    else
      return
    end
    images_items = images.collect { |asset| content_tag( :li, link_to(image_tag(asset.public_filename(size), :alt => asset.description), asset.public_filename, :title => asset.description, :rel => 'gallery' ) ) }
    content_tag :ul, images_items.join, :class => 'gallery' unless images_items.empty?
  end

  def documents(assets)
    if assets.respond_to? :documents and assets.documents.any?
      documents = assets.documents
    elsif assets.any?
      documents = assets.reject{|a| a.content_type.starts_with?('image')}
    else
      return
    end
    documents_items = documents.collect { |asset| content_tag( :li, link_to("<em>Download <span class=\"filename\">#{asset.filename}</span></em> (#{number_to_human_size(asset.size)})", asset.public_filename, :title => asset.description ) ) }
    content_tag :ul, documents_items.join, :class => 'documents' unless documents_items.empty?
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
beef-has_assets-0.7.5 app/helpers/assets_helper.rb
beef-has_assets-0.7.4 app/helpers/assets_helper.rb
beef-has_assets-0.7.3 app/helpers/assets_helper.rb
beef-has_assets-0.7.2 app/helpers/assets_helper.rb
beef-has_assets-0.7.1 app/helpers/assets_helper.rb
beef-has_assets-0.7.0 app/helpers/assets_helper.rb
beef-has_assets-0.6.8 app/helpers/assets_helper.rb