Sha256: f69baed1e85a157f631eaa25acef9bd73d8299ad31056125f83ac16427097083

Contents?: true

Size: 1.28 KB

Versions: 9

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Base controller mixin
  module Base
    extend ActiveSupport::Concern

    include Blacklight::Base
    include Spotlight::Config

    included do
      helper_method :controller_tracking_method
    end

    def controller_tracking_method
      Spotlight::Engine.config.controller_tracking_method
    end

    # This overwrites Blacklight::Configurable#blacklight_config
    def blacklight_config
      exhibit_specific_blacklight_config
    end

    def autocomplete_json_response(document_list)
      document_list.map do |doc|
        autocomplete_json_response_for_document doc
      end
    end

    # rubocop:disable Metrics/AbcSize
    def autocomplete_json_response_for_document(doc)
      {
        id: doc.id,
        title: CGI.unescapeHTML(view_context.presenter(doc).heading.to_str),
        thumbnail: doc.first(blacklight_config.index.thumbnail_field),
        full_image_url: doc.first(Spotlight::Engine.config.full_image_field),
        description: doc.id,
        url: polymorphic_path([current_exhibit, doc]),
        private: doc.private?(current_exhibit),
        global_id: doc.to_global_id.to_s,
        iiif_manifest: doc[Spotlight::Engine.config.iiif_manifest_field]
      }
    end
    # rubocop:enable Metrics/AbcSize
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.rc5 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.rc4 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.rc3 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.rc2 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.rc1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.alpha.10 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.alpha.9 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.alpha.8 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0.alpha.7 app/controllers/concerns/spotlight/base.rb