Sha256: 21430195f84a17aa4ad3f431318aead40e4549de02a907b0b8b41ecb6a83ee9b

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

module Pageflow
  # Format and generate seed data for files
  module FilesHelper
    include RenderJsonHelper

    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

    # Render seed data for all files of the revision.
    #
    # @param [JBuilder] json
    # @param [PublishedEntry] entry
    # @since 15.1
    def files_json_seed(json, entry)
      Pageflow.config.file_types.each do |file_type|
        json.set!(file_type.collection_name) do
          json.array!(entry.find_files(file_type.model)) do |file|
            json.partial!('pageflow/files/file', file: file, file_type: file_type)
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/helpers/pageflow/files_helper.rb
pageflow-17.0.3 app/helpers/pageflow/files_helper.rb
pageflow-17.0.2 app/helpers/pageflow/files_helper.rb
pageflow-17.0.1 app/helpers/pageflow/files_helper.rb
pageflow-17.0.0 app/helpers/pageflow/files_helper.rb
pageflow-16.2.0 app/helpers/pageflow/files_helper.rb
pageflow-16.1.0 app/helpers/pageflow/files_helper.rb
pageflow-16.0.0 app/helpers/pageflow/files_helper.rb
pageflow-15.8.0 app/helpers/pageflow/files_helper.rb
pageflow-15.7.1 app/helpers/pageflow/files_helper.rb
pageflow-15.7.0 app/helpers/pageflow/files_helper.rb
pageflow-15.6.1 app/helpers/pageflow/files_helper.rb
pageflow-15.6.0 app/helpers/pageflow/files_helper.rb
pageflow-15.5.0 app/helpers/pageflow/files_helper.rb
pageflow-15.4.0 app/helpers/pageflow/files_helper.rb
pageflow-15.3.0 app/helpers/pageflow/files_helper.rb
pageflow-15.2.2 app/helpers/pageflow/files_helper.rb
pageflow-15.2.1 app/helpers/pageflow/files_helper.rb
pageflow-15.2.0 app/helpers/pageflow/files_helper.rb
pageflow-15.1.2 app/helpers/pageflow/files_helper.rb