Sha256: e15d672943c99f2b4b08870387e4058c72f05c7abfc49740541f7446b5e675af

Contents?: true

Size: 1.11 KB

Versions: 24

Compression:

Stored size: 1.11 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 #{asset.filename}</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

24 entries across 24 versions & 1 rubygems

Version Path
beef-has_assets-0.2.10 app/helpers/assets_helper.rb
beef-has_assets-0.2.6 app/helpers/assets_helper.rb
beef-has_assets-0.2.7 app/helpers/assets_helper.rb
beef-has_assets-0.2.8 app/helpers/assets_helper.rb
beef-has_assets-0.2.9 app/helpers/assets_helper.rb
beef-has_assets-0.3.1 app/helpers/assets_helper.rb
beef-has_assets-0.3.2 app/helpers/assets_helper.rb
beef-has_assets-0.3.3 app/helpers/assets_helper.rb
beef-has_assets-0.3.4 app/helpers/assets_helper.rb
beef-has_assets-0.3.5 app/helpers/assets_helper.rb
beef-has_assets-0.3.6 app/helpers/assets_helper.rb
beef-has_assets-0.3.7 app/helpers/assets_helper.rb
beef-has_assets-0.3.8 app/helpers/assets_helper.rb
beef-has_assets-0.3.9 app/helpers/assets_helper.rb
beef-has_assets-0.4.0 app/helpers/assets_helper.rb
beef-has_assets-0.4.1 app/helpers/assets_helper.rb
beef-has_assets-0.5.0 app/helpers/assets_helper.rb
beef-has_assets-0.6.7 app/helpers/assets_helper.rb
beef-has_assets-0.6.6 app/helpers/assets_helper.rb
beef-has_assets-0.6.5 app/helpers/assets_helper.rb