Class: Spotlight::CatalogController

Inherits:
CatalogController show all
Includes:
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

Instance Method Summary collapse

Methods included from Base

#autocomplete_json_response, #autocomplete_json_response_for_document, #blacklight_config

Methods included from Config

#exhibit_specific_blacklight_config

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url

Instance Method Details

#adminObject



71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/spotlight/catalog_controller.rb', line 71

def admin
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
  (@response, @document_list) = search_results(params, search_params_logic)
  @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.



60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/spotlight/catalog_controller.rb', line 60

def autocomplete
  search_params = params.merge(search_field: Spotlight::Engine.config.autocomplete_search_field)
  (_, @document_list) = search_results(search_params.merge(public: true), search_params_logic)

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

#editObject



92
93
94
# File 'app/controllers/spotlight/catalog_controller.rb', line 92

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

#make_privateObject



96
97
98
99
100
101
102
103
104
105
# File 'app/controllers/spotlight/catalog_controller.rb', line 96

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

  respond_to do |format|
    format.html { redirect_to :back }
    format.json { render json: true }
  end
end

#make_publicObject



107
108
109
110
111
112
113
114
115
116
# File 'app/controllers/spotlight/catalog_controller.rb', line 107

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

  respond_to do |format|
    format.html { redirect_to :back }
    format.json { render json: true }
  end
end

#newObject



39
40
41
42
43
44
# File 'app/controllers/spotlight/catalog_controller.rb', line 39

def new
  add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.curation.sidebar.items'), admin_exhibit_catalog_index_path(@exhibit)
  add_breadcrumb t(:'spotlight.catalog.new.header'), new_exhibit_catalog_path(@exhibit)
  @resource = @exhibit.resources.build
end

#showObject



46
47
48
49
50
51
52
53
54
# File 'app/controllers/spotlight/catalog_controller.rb', line 46

def show
  super

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

  add_document_breadcrumbs(@document)
end

#updateObject



82
83
84
85
86
87
88
89
90
# File 'app/controllers/spotlight/catalog_controller.rb', line 82

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

  try_solr_commit!

  redirect_to exhibit_catalog_path(current_exhibit, @document)
end