Sha256: 7b443c1483d1d4977e5e0ffc4c2e2b51b761244528bf234ec5ed757aab9bd1aa

Contents?: true

Size: 990 Bytes

Versions: 20

Compression:

Stored size: 990 Bytes

Contents

module BrowseEverythingHelper

  def array_to_hidden_fields(array,key)
    fields = array.to_query(key).split(Rack::Utils::DEFAULT_SEP).collect do |pair|
      key,value=pair.split('=', 2).map { |str| Rack::Utils.unescape(str) }
      hidden_field_tag(key,value)
    end
    fields.join("\n").html_safe
  end

  # Extracted from Rack::Mime 1.5.2 for use with earlier versions
  # of Rack/Rails
  def mime_match?(value, matcher)
    v1, v2 = value.split('/', 2)
    m1, m2 = matcher.split('/', 2)

    if m1 == '*'
      if m2.nil? || m2 == '*'
        return true
      elsif m2 == v2
        return true
      else
        return false
      end
    end

    return false if v1 != m1

    return true if m2.nil? || m2 == '*'

    m2 == v2
  end

  def is_acceptable?(file)
    acceptable = params[:accept] || '*/*'
    acceptable_types = acceptable.split(/,\s*/)
    acceptable_types << 'application/x-directory'
    acceptable_types.any? { |type| mime_match?(file.type, type) }
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
browse-everything-0.10.5 app/helpers/browse_everything_helper.rb
browse-everything-0.10.4 app/helpers/browse_everything_helper.rb
browse-everything-0.10.3 app/helpers/browse_everything_helper.rb
browse-everything-0.10.2 app/helpers/browse_everything_helper.rb
browse-everything-0.10.1 app/helpers/browse_everything_helper.rb
browse-everything-0.10.0 app/helpers/browse_everything_helper.rb
browse-everything-0.9.1 app/helpers/browse_everything_helper.rb
browse-everything-0.9.0 app/helpers/browse_everything_helper.rb
browse-everything-0.8.4 app/helpers/browse_everything_helper.rb
browse-everything-0.8.3 app/helpers/browse_everything_helper.rb
browse-everything-0.8.2 app/helpers/browse_everything_helper.rb
browse-everything-0.8.1 app/helpers/browse_everything_helper.rb
browse-everything-0.8.0 app/helpers/browse_everything_helper.rb
browse-everything-0.7.1 app/helpers/browse_everything_helper.rb
browse-everything-0.7.0 app/helpers/browse_everything_helper.rb
browse-everything-0.6.3 app/helpers/browse_everything_helper.rb
browse-everything-0.6.2 app/helpers/browse_everything_helper.rb
browse-everything-0.6.1 app/helpers/browse_everything_helper.rb
browse-everything-0.6.0 app/helpers/browse_everything_helper.rb
browse-everything-0.5.2 app/helpers/browse_everything_helper.rb