Sha256: 03dbcf76f4bda2ef44d59cfe60c3da2d2d8bd477272ffe4d537ce6175a74372e

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

# Register a JavaScript search API result format used by the content browser.
Scrivito::Configuration.register_obj_format('content_browser') do |obj, _, view_context|
  has_details_view = view_context.lookup_context.exists?(
    obj.details_view_path, [], false, [], formats: [:html])

  format = {
    id: obj.id,
    file_type: obj.obj_class_name,
    mime_type: obj.file_extension.upcase,
    file_size: ConverterHelper.human_binary_length(obj.binary_length),
    last_changed: obj[:_last_changed],
    title: obj.description_for_editor.presence || obj.binary.try(:filename),
    subtitle: obj.info_for_content_browser,
    mime_type: obj.binary_content_type,
    has_details_view: has_details_view
  }

  if obj.binary_content_type && obj.binary_content_type.start_with?('image/')
    format[:preview] = obj.binary_url
  end

  format
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scrivito_content_browser-0.50.1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.50.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.50.0.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.50.0.rc1 config/initializers/scrivito_content_browser.rb