Sha256: a1cde92b5cd85da6a3484d7d7052e9344a7f8d34cf6b248e3b28c18a70df71d0

Contents?: true

Size: 801 Bytes

Versions: 8

Compression:

Stored size: 801 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.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

8 entries across 8 versions & 1 rubygems

Version Path
scrivito_content_browser-0.65.2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.65.1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.65.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.65.0.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.65.0.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.60.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.60.0.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-0.60.0.rc1 config/initializers/scrivito_content_browser.rb