Sha256: 9318c34b970f0941fa1280de9092792ce20d26a9009369e0ef4c891f73477d66

Contents?: true

Size: 787 Bytes

Versions: 3

Compression:

Stored size: 787 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,
    file_size: ConverterHelper.human_binary_length(obj),
    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

3 entries across 3 versions & 1 rubygems

Version Path
scrivito_content_browser-0.66.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.66.0.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.66.0.rc1 config/initializers/scrivito_content_browser.rb