Sha256: 1a08a0a3b6f636a5248f5e4f49ceacda9a8c4102877cc00f2e294c23e051b012

Contents?: true

Size: 981 Bytes

Versions: 14

Compression:

Stored size: 981 Bytes

Contents

module PushType
  module AssetsHelper

    def assets_array(assets)
      assets.map { |a| asset_hash(a) }
    end

    def asset_hash(asset)
      return nil if asset.nil?
      hash = [ :id, :file_name, :file_size, :mime_type, :created_at, :new_record?, :image?, :description_or_file_name ].inject({}) do |h, att|
        h.update att => asset.send(att)
      end
      hash.update url: main_app.media_path(file_uid: asset.file_uid), preview_thumb_url: asset_preview_thumb_url(asset) if asset.persisted?
      hash
    end

    def asset_preview_thumb_url(asset)
      if asset.image?
        main_app.media_path(file_uid: asset.file_uid, style: :push_type_thumb)
      else
        image_path(asset_icon(asset))
      end
    end

    def asset_icon(asset)
      "push_type/icons-assets.svg##{ asset.kind }"
    end

    def asset_back_link(asset)
      if asset.trashed?
        push_type.trash_assets_path
      else
        push_type.assets_path
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
push_type_admin-0.9.5 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.3 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.2 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.1 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.0 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.0.beta.4 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.0.beta.3 app/helpers/push_type/assets_helper.rb
push_type_admin-0.9.0.beta.2 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.2 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.1 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.0 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.0.beta.3 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.0.beta.2 app/helpers/push_type/assets_helper.rb
push_type_admin-0.8.0.beta.1 app/helpers/push_type/assets_helper.rb