Sha256: c2ca3883b7aad768cb0b651ffae1e8dcf352cabab8d94ba7354d861847bd513b

Contents?: true

Size: 1.29 KB

Versions: 21

Compression:

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

21 entries across 21 versions & 1 rubygems

Version Path
blacklight-spotlight-3.5.0.4 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.5.0.3 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.5.0.2 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.5.0.1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.5.0 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.4.1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.4 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.3 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.2.2 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.2.1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.2 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.4.0 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.3.0 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.2.0 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.1.0 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.3 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.2 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.1 app/controllers/concerns/spotlight/base.rb
blacklight-spotlight-3.0.0 app/controllers/concerns/spotlight/base.rb