Sha256: e17aeb189d52a6e60653476151e05b093e5e555dded89a802014cf959f632a12

Contents?: true

Size: 861 Bytes

Versions: 50

Compression:

Stored size: 861 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,
    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/')
    binary = obj.binary.transform(width: 260, height: 140)
    format[:preview] = view_context.scrivito_path(binary)
  end

  format
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
scrivito_content_browser-1.5.5 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.5.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.3 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.4 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.4.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.3 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.3.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.2.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.1.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.1.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.0.rc2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.5.0.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.2 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.1.rc1 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.0 config/initializers/scrivito_content_browser.rb
scrivito_content_browser-1.4.0.rc2 config/initializers/scrivito_content_browser.rb