Sha256: 694395a443e479625450eec938f7a765ea718f5fb3fdc035002412c4f0911c99

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 KB

Contents

module Pageflow
  module FilesHelper
    include RenderJsonHelper
    include VideoFilesHelper

    def file_format(file)
      file.format.presence || '-'
    end

    def file_dimensions(file)
      if file.width && file.height
        "#{file.width} x #{file.height}px"
      else
        "-"
      end
    end

    def file_duration(file)
      if file.duration_in_ms
        total_seconds = file.duration_in_ms / 1000
        seconds = total_seconds % 60
        minutes = (total_seconds / 60) % 60
        hours = total_seconds / (60 * 60)

        format("%02d:%02d:%02d", hours, minutes, seconds)
      else
        "-"
      end
    end

    def files_json_seeds(entry)
      inner = Pageflow.config.file_types.map do |file_type|
        json = render_json_partial(partial: 'pageflow/editor/files/file',
                                   collection: entry.find_files(file_type.model),
                                   locals: {file_type: file_type},
                                   as: :file)

        %'"#{file_type.collection_name}": #{json}'
      end.join(',')

      "{#{inner}}".html_safe
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
pageflow-13.6.0 app/helpers/pageflow/files_helper.rb
pageflow-13.5.0 app/helpers/pageflow/files_helper.rb
pageflow-13.4.0 app/helpers/pageflow/files_helper.rb
pageflow-13.3.0 app/helpers/pageflow/files_helper.rb
pageflow-13.2.0 app/helpers/pageflow/files_helper.rb
pageflow-12.6.0 app/helpers/pageflow/files_helper.rb
pageflow-13.1.0 app/helpers/pageflow/files_helper.rb
pageflow-12.5.0 app/helpers/pageflow/files_helper.rb
pageflow-12.4.1 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.rc1 app/helpers/pageflow/files_helper.rb
pageflow-12.4.0 app/helpers/pageflow/files_helper.rb
pageflow-12.3.0 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta7 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta6 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta5 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta4 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta3 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta2 app/helpers/pageflow/files_helper.rb
pageflow-13.0.0.beta1 app/helpers/pageflow/files_helper.rb