Class: Spotlight::CatalogController

Inherits:
CatalogController show all
Includes:
Blacklight::Catalog, Catalog, Spotlight::Concerns::ApplicationController, Spotlight::Concerns::CatalogSearchContext
Defined in:
app/controllers/spotlight/catalog_controller.rb

Overview

Spotlight’s catalog controller. Note that this subclasses the host application’s CatalogController to get its configuration, partial overrides, etc rubocop:disable Metrics/ClassLength

Direct Known Subclasses

BulkActionsController

Instance Method Summary collapse

Methods included from Catalog

#add_facet_visibility_field, #render_curator_actions?

Methods included from SearchHelper

#search_service, #search_service_context

Methods included from Base

#autocomplete_json_response, #autocomplete_json_response_for_document, #blacklight_config, #controller_tracking_method

Methods included from Config

#exhibit_specific_blacklight_config

Methods included from Spotlight::Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #set_exhibit_locale_scope, #set_locale

Instance Method Details

#adminObject



67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/spotlight/catalog_controller.rb', line 67

def admin
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_path(@exhibit)
  (@response, @document_list) = search_service.search_results
  @filters = params[:f] || []

  respond_to do |format|
    format.html
  end
end

#autocompleteObject

“id_ng” and “full_title_ng” should be defined in the Solr core’s schema.xml. It’s expected that these fields will be set up to have EdgeNGram filter setup within their index analyzer. This will ensure that this method returns results when a partial match is passed in the “q” parameter.



55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/spotlight/catalog_controller.rb', line 55

def autocomplete
  (_, @document_list) = search_service.search_results do |builder|
    builder.with(builder.blacklight_params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field, public: true, rows: 100))
  end

  respond_to do |format|
    format.json do
      render json: { docs: autocomplete_json_response(@document_list) }
    end
  end
end

#editObject



88
89
90
# File 'app/controllers/spotlight/catalog_controller.rb', line 88

def edit
  @response, @document = search_service.fetch params[:id]
end

#make_privateObject



92
93
94
95
96
97
98
99
100
101
# File 'app/controllers/spotlight/catalog_controller.rb', line 92

def make_private
  @response, @document = search_service.fetch params[:id]
  @document.make_private!(current_exhibit)
  @document.save

  respond_to do |format|
    format.html { redirect_back(fallback_location: [spotlight, current_exhibit, @document]) }
    format.json { render json: true }
  end
end

#make_publicObject



103
104
105
106
107
108
109
110
111
112
# File 'app/controllers/spotlight/catalog_controller.rb', line 103

def make_public
  @response, @document = search_service.fetch params[:id]
  @document.make_public!(current_exhibit)
  @document.save

  respond_to do |format|
    format.html { redirect_back(fallback_location: [spotlight, current_exhibit, @document]) }
    format.json { render json: true }
  end
end

#manifestObject



114
115
116
117
118
119
120
121
122
# File 'app/controllers/spotlight/catalog_controller.rb', line 114

def manifest
  _, document = search_service.fetch params[:id]

  if document.uploaded_resource?
    render json: Spotlight::IiifManifestPresenter.new(document, self).iiif_manifest_json
  else
    head :not_found
  end
end

#showObject



43
44
45
46
47
48
49
# File 'app/controllers/spotlight/catalog_controller.rb', line 43

def show
  super

  authenticate_user! && authorize!(:curate, current_exhibit) if @document.private? current_exhibit

  add_document_breadcrumbs(@document)
end

#updateObject



78
79
80
81
82
83
84
85
86
# File 'app/controllers/spotlight/catalog_controller.rb', line 78

def update
  @response, @document = search_service.fetch params[:id]
  @document.update(current_exhibit, solr_document_params)
  @document.save

  try_solr_commit!

  redirect_to polymorphic_path([current_exhibit, @document])
end