Module: BlacklightUnapi::ControllerExtension

Extended by:
ActiveSupport::Concern
Defined in:
lib/blacklight_unapi/controller_extension.rb

Overview

Meant to be applied on top of a controller that implements Blacklight::SolrHelper.

Instance Method Summary collapse

Instance Method Details

#unapiObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/blacklight_unapi/controller_extension.rb', line 10

def unapi
  @export_formats = blacklight_config.unapi
  @format = params[:format]

  if params[:id]
    @response, @document = get_solr_response_for_doc_id params[:id]
    @export_formats = @document.export_formats
  end
	
  if params[:format]
    respond_to do |format|
      format.all do
        if @document.will_export_as @format
          send_data @document.export_as(@format), type: @document.export_formats[@format][:content_type], disposition: 'inline'
        end
      end
    end
  else
    render template: 'catalog/formats.xml'
  end 	
end