• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tulibraries / tul_cob / e90183c0-78db-4834-91d0-3f95e38a6d85

04 Mar 2024 05:30PM UTC coverage: 85.41% (+0.005%) from 85.405%
e90183c0-78db-4834-91d0-3f95e38a6d85

Pull #4270

circleci

cdoyle-temple
add witelisted collections, cleanup tests, styles, and code
Pull Request #4270: BL-1829 Update Digital Collections results on bento page

18 of 20 new or added lines in 1 file covered. (90.0%)

15 existing lines in 1 file now uncovered.

3003 of 3516 relevant lines covered (85.41%)

55.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.36
/app/controllers/catalog_controller.rb
1
# frozen_string_literal: true
2

3
class CatalogController < ApplicationController
1✔
4
  caches_page :show, expires_in: 24.hours
1✔
5
  caches_action :index, expires_in: 12.hours, cache_path: Proc.new { |c| c.request.url }
1✔
6

7
  include FacetParamsDedupe
1✔
8
  include BlacklightAdvancedSearch::Controller
1✔
9
  include BlacklightRangeLimit::ControllerOverride
1✔
10
  include Blacklight::Catalog
1✔
11

12
  include Blacklight::Marc::Catalog
1✔
13
  include ServerErrors
1✔
14
  include LCClassifications
1✔
15

16
  before_action :authenticate_purchase_order!, only: [ :purchase_order, :purchase_order_action ]
1✔
17
  before_action :set_thread_request
1✔
18
  before_action only: :index do
1✔
19
    blacklight_config.max_per_page = 50
81✔
20
    if params[:page] && params[:page].to_i > 250
81✔
21
      flash[:error] = t("blacklight.errors.deep_paging")
1✔
22
      redirect_to root_path
1✔
23
    end
24
  end
25

26
  helper_method :display_duration
1✔
27

28
  # TODO: remove once libwizard_tutorial? is no longer a flag
29
  def self.libwizard_tutorial?
1✔
UNCOV
30
    Proc.new { |context| ::FeatureFlags.libwizard_tutorial?(context.params) }
×
31
  end
32

33
  configure_blacklight do |config|
1✔
34
    # default advanced config values
35
    config.advanced_search ||= Blacklight::OpenStructWithHashAccess.new
1✔
36
    config.advanced_search[:url_key] ||= "advanced"
1✔
37
    config.advanced_search[:query_parser] ||= "edismax"
1✔
38
    config.advanced_search[:form_solr_parameters] ||= {}
1✔
39
    config.advanced_search[:form_solr_parameters]["facet.field"] ||= %w(format library_facet language_facet availability_facet)
1✔
40
    config.advanced_search[:form_solr_parameters]["facet.limit"] ||= -1
1✔
41
    config.advanced_search[:form_solr_parameters]["f.language_facet.facet.limit"] ||= -1
1✔
42
    config.advanced_search[:form_solr_parameters]["f.language_facet.facet.sort"] ||= "index"
1✔
43
    config.advanced_search[:fields_row_count] = 3
1✔
44

45
    config.track_search_session = true
1✔
46
    config.raw_endpoint.enabled = true
1✔
47

48
    ## Class for sending and receiving requests from a search index
49
    # config.repository_class = Blacklight::Solr::Repository
50
    #
51
    ## Class for converting Blacklight's url parameters to into request parameters for the search index
52
    # config.search_builder_class = ::SearchBuilder
53
    #
54
    ## Model that maps search index responses to the blacklight response model
55
    # config.response_model = Blacklight::Solr::Response
56

57
    ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
58
    # config.default_solr_params = {}
59

60
    # solr path which will be added to solr base url before the other solr params.
61
    config.document_solr_path = "document"
1✔
62
    config.solr_path = "search"
1✔
63

64
    # items to show per page, each number in the array represent another option to choose from.
65
    config.per_page = [10, 20, 50]
1✔
66

67
    # Set document specific solr request handler.
68
    ## Default parameters to send on single-document requests to Solr. These settings are the Blackligt defaults (see SearchHelper#solr_doc_params) or
69
    ## parameters included in the Blacklight-jetty document requestHandler.
70
    #
71
    #config.default_document_solr_params = {
72
    #  qt: 'document',
73
    #  ## These are hard-coded in the blacklight 'document' requestHandler
74
    #  # fl: '*',
75
    #  # rows: 1,
76
    #  # q: '{!term f=id v=$id}'
77
    #}
78

79
    # solr field configuration for search results/index views
80
    config.index.title_field = "title_with_subtitle_truncated_display"
1✔
81
    config.index.display_type_field = "format"
1✔
82
    config.index.document_presenter_class = IndexPresenter
1✔
83

84
    # solr field configuration for document/show views
85
    config.show.title_field = "title_with_subtitle_truncated_display"
1✔
86
    #config.show.display_type_field = 'format'
87
    config.show.document_presenter_class = ShowPresenter
1✔
88

89
    # solr fields that will be treated as facets by the blacklight application
90
    #   The ordering of the field names is the order of the display
91
    #
92
    # Setting a limit will trigger Blacklight's 'more' facet values link.
93
    # * If left unset, then all facet values returned by solr will be displayed.
94
    # * If set to an integer, then "f.somefield.facet.limit" will be added to
95
    # solr request, with actual solr request being +1 your configured limit --
96
    # you configure the number of items you actually want _displayed_ in a page.
97
    # * If set to 'true', then no additional parameters will be sent to solr,
98
    # but any 'sniffed' request limit parameters will be used for paging, with
99
    # paging at requested limit -1. Can sniff from facet.limit or
100
    # f.specific_field.facet.limit solr request params. This 'true' config
101
    # can be used if you set limits in :default_solr_params, or as defaults
102
    # on the solr side in the request handler itself. Request handler defaults
103
    # sniffing requires solr requests to be made with "echoParams=all", for
104
    # app code to actually have it echo'd back to see it.
105
    #
106
    # :show may be set to false if you don't want the facet to be drawn in the
107
    # facet bar
108
    #
109
    # set :index_range to true if you want the facet pagination view to have facet prefix-based navigation
110
    #  (useful when user clicks "more" on a large facet and wants to navigate alphabetically across a large set of results)
111
    # :index_range can be an array or range of prefixes that will be used to create the navigation (note: It is case sensitive when searching values)
112

113
    # Facet Fields
114

115
    # config.add_facet_field 'example_pivot_field', label: 'Pivot Field', :pivot => ['format', 'language_facet']
116
    # config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
117
    #    :years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.zone.now.year - 5 } TO *]" },
118
    #    :years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.zone.now.year - 10 } TO *]" },
119
    #    :years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.zone.now.year - 25 } TO *]" }
120
    # }
121

122
    # In order to decide at query time if we want to include ETAS records considered "Online"
123
    # we define two availability facets and decide which one to show based on the `config.campus_closed` lambda
124
    # which can evaluate the URL param as well as the env var set feature flag.
125
    # The `if:` and `unless:` params are the only part evaluated at query time.
126
    config.campus_closed = lambda { |context, _, __| ::FeatureFlags.campus_closed?(context.params) }
115✔
127
    config.add_facet_field "availability_facet_etas",
1✔
128
      label: "Availability", collapse: false, show: true, home: true, component: true,
129
      sort: :count,
130
      query: {
131
        "At the Library" => { label: "At the Library", fq: 'availability_facet:"At the Library"' },
132
        "Online" =>  { label: "Online", fq: 'availability_facet:(Online OR "ETAS")' },
133
        "Rapid Request Access" => { label: "Request Rapid Access",  fq: 'availability_facet:"Request Rapid Access"' }
134
      },
135
      if: config.campus_closed
136
    config.add_facet_field "availability_facet",
1✔
137
      label: "Availability", collapse: false, show: true, home: true, component: true,
138
      sort: :count,
139
      query: {
140
        "At the Library" => { label: "At the Library", fq: 'availability_facet:"At the Library"' },
141
        "Online" =>  { label: "Online", fq: 'availability_facet:"Online"' },
142
        "Rapid Request Access" => { label: "Request Rapid Access", fq: 'availability_facet:"Request Rapid Access"' }
143
      },
144
      unless: config.campus_closed
145

146
    config.add_facet_field "library_facet", label: "Library", presenter: PivotFacetFieldPresenter,
1✔
147
      pivot: ["library_facet", "location_facet"], limit: -1, collapsing: true,  show: true, home: true,
148
      component: true, pre_process: :pre_process_library_facet, icons: { show: "", hide: "" }
149
    config.add_facet_field "format", label: "Resource Type", limit: -1, show: true, home: true, component: true
1✔
150
    config.add_facet_field "pub_date_sort", label: "Publication Date", range: true, component: RangeFacetFieldListComponent
1✔
151
    config.add_facet_field "creator_facet", label: "Author/creator", limit: true, show: true, component: true
1✔
152
    config.add_facet_field "subject_facet", label: "Subject", limit: true, show: false, component: true
1✔
153
    config.add_facet_field "donor_info_ms", label: "Donor bookplate", limit: true, show: false, component: true
1✔
154
    config.add_facet_field "genre_ms", label: "Genre", limit: true, show: false, component: true
1✔
155
    config.add_facet_field "language_facet", label: "Language", limit: true, show: true, component: true
1✔
156
    config.add_facet_field "lc_facet", label: "Library of Congress Classification", pivot: ["lc_outer_facet", "lc_inner_facet"], limit: true, show: true, presenter: ClassificationFieldPresenter, component: true, collapsing: true, icons: { show: "", hide: "" }
1✔
157
    config.add_facet_field "genre_facet", label: "Genre", limit: true, show: true, component: true
1✔
158
    config.add_facet_field "subject_topic_facet", label: "Topic" , limit: true, show: true, component: true
1✔
159
    config.add_facet_field "subject_era_facet", label: "Era", limit: true, show: true, component: true
1✔
160
    config.add_facet_field "subject_region_facet", label: "Region", limit: true, show: true, component: true
1✔
161
    config.add_facet_field "collection_ms", label: "Collection Name"
1✔
162
    config.add_facet_field "date_added_facet", label: "Newly Added", query: {
1✔
163
          week_1: { label: "Within Last Week", fq: "date_added_facet:[#{(Date.current - 2.weeks).strftime('%Y%m%d').to_i} TO #{(Date.current - 1.week).strftime('%Y%m%d').to_i}]" },
1✔
164
          months_1: { label: "Within Last Month", fq: "date_added_facet:[#{(Date.current - 1.month).strftime('%Y%m%d').to_i} TO #{(Date.current - 1.week).strftime('%Y%m%d').to_i}]" },
1✔
165
          months_3: { label: "Within Last Three Months", fq: "date_added_facet:[#{(Date.current - 3.months).strftime('%Y%m%d').to_i } TO #{(Date.current - 1.week).strftime('%Y%m%d').to_i}]" },
1✔
166
          months_12: { label: "Within Last Year", fq: "date_added_facet:[#{(Date.current - 1.year).strftime('%Y%m%d').to_i } TO #{(Date.current - 1.week).strftime('%Y%m%d').to_i}]" }
1✔
167
        }
168

169
    # Added due to BL pivot field bug. Remove once projectblacklight/blacklight#2463 is fixed.
170
    config.add_facet_field "location_facet", show: false
1✔
171
    config.add_facet_field "lc_inner_facet", show: false
1✔
172
    config.add_facet_field "lc_outer_facet", show: false
1✔
173
    config.add_facet_field "lc_classification", show: false
1✔
174

175
    # Have BL send all facet field names to Solr, which has been the default
176
    # previously. Simply remove these lines if you'd rather use Solr request
177
    # handler defaults, or have no facets.
178
    config.add_facet_fields_to_solr_request!
1✔
179

180
    # solr fields to be displayed in the index (search results) view
181
    #   The ordering of the field names is the order of the display
182
    config.add_index_field "format", raw: true, helper_method: :separate_formats, type: :format
1✔
183
    config.add_index_field "imprint_date_display", type: :date
1✔
184
    config.add_index_field "note_summary_display", helper_method: :join, type: :summary
1✔
185
    config.add_index_field "responsibility_truncated_display", label: ""
1✔
186
    config.add_index_field "creator_display", label: "Author/Creator", helper_method: :creator_links
1✔
187
    config.add_index_field "imprint_display", label: "Publication"
1✔
188
    config.add_index_field "imprint_prod_display", label: "Production"
1✔
189
    config.add_index_field "imprint_dist_display", label: "Distribution"
1✔
190
    config.add_index_field "imprint_man_display", label: "Manufacture"
1✔
191
    config.add_index_field "lc_call_number_display", if: :render_lc_call_number_on_index?
1✔
192
    config.add_index_field "url_finding_aid_display", label: "Finding Aid", helper_method: :check_for_full_http_link
1✔
193
    config.add_index_field "availability"
1✔
194
    config.add_index_field "purchase_order_availability", field: "purchase_order", if: false, helper_method: :render_purchase_order_availability, with_po_link: true
1✔
195
    config.add_index_field "bound_with_ids", if: false
1✔
196

197
    # solr fields to be displayed in the show (single result) view
198
    #   The ordering of the field names is the order of the display
199

200
    config.add_show_field "title_with_subtitle_vern_display", label: "Title Statement", type: :primary
1✔
201
    config.add_show_field "responsibility_display", label: "", type: :responsibility
1✔
202
    config.add_show_field "responsibility_vern_display", label: "", type: :responsibility
1✔
203
    config.add_show_field "url_finding_aid_display", label: "Finding Aid", helper_method: :check_for_full_http_link, type: :primary
1✔
204
    config.add_show_field "title_uniform_display", label: "Uniform title", helper_method: :additional_title_link, type: :primary
1✔
205
    config.add_show_field "title_uniform_vern_display", label: "Uniform title", type: :primary
1✔
206
    config.add_show_field "title_addl_display", label: "Additional titles", helper_method: :additional_title_link, type: :primary
1✔
207
    config.add_show_field "title_addl_vern_display", label: "Additional titles", type: :primary
1✔
208
    config.add_show_field "creator_display", label: "Author/Creator", helper_method: :creator_links, multi: true, type: :primary
1✔
209
    config.add_show_field "creator_vern_display", label: "Author/Creator", helper_method: :creator_links, type: :primary
1✔
210
    config.add_show_field "contributor_display", label: "Contributor", helper_method: :creator_links, multi: true, type: :primary
1✔
211
    config.add_show_field "contributor_vern_display", label: "Contributor", helper_method: :creator_links, type: :primary
1✔
212
    config.add_show_field "format", label: "Resource Type", type: :primary, raw: true, helper_method: :separate_formats
1✔
213
    config.add_show_field "imprint_display", label: "Publication", type: :primary
1✔
214
    config.add_show_field "imprint_prod_display", label: "Production", type: :primary
1✔
215
    config.add_show_field "imprint_dist_display", label: "Distribution", type: :primary
1✔
216
    config.add_show_field "imprint_man_display", label: "Manufacture", type: :primary
1✔
217
    config.add_show_field "edition_display", label: "Edition", type: :primary
1✔
218
    config.add_show_field "date_copyright_display", label: "Copyright Notice", type: :primary
1✔
219
    config.add_show_field "phys_desc_display", label: "Physical Description", type: :primary
1✔
220
    config.add_show_field "collection_ms", label: "Collection", type: :primary, helper_method: :record_page_ms_links, multi: true
1✔
221
    config.add_show_field "title_series_display", label: "Series Title"
1✔
222
    config.add_show_field "title_series_vern_display", label: "Series Title"
1✔
223
    config.add_show_field "volume_series_display", label: "Volume"
1✔
224
    config.add_show_field "duration_display", label: "Duration", helper_method: :display_duration
1✔
225
    config.add_show_field "frequency_display", label: "Frequency"
1✔
226
    config.add_show_field "sound_display", label: "Sound characteristics"
1✔
227
    config.add_show_field "digital_file_display", label: "Digital file characteristics"
1✔
228
    config.add_show_field "video_file_display", label: "Video characteristics"
1✔
229
    config.add_show_field "music_format_display", label: "Format of notated music"
1✔
230
    config.add_show_field "form_work_display", label: "Form of work"
1✔
231
    config.add_show_field "performance_display", label: "Medium of performance"
1✔
232
    config.add_show_field "music_no_display", label: "Music no."
1✔
233
    config.add_show_field "music_key_display", label: "Musical key"
1✔
234
    config.add_show_field "audience_display", label: "Audience"
1✔
235
    config.add_show_field "creator_group_display", label: "Creator/Contributor characteristics"
1✔
236
    config.add_show_field "date_period_display", label: "Time Period"
1✔
237
    config.add_show_field "note_display", label: "Note"
1✔
238
    config.add_show_field "note_award", field: "note_award_display", label: "Awards Note"
1✔
239
    config.add_show_field "note_with_display", label: "With"
1✔
240
    config.add_show_field "note_diss_display", label: "Dissertation Note"
1✔
241
    config.add_show_field "note_biblio_display", label: "Bibliography"
1✔
242
    config.add_show_field "note_toc_display", label: "Contents"
1✔
243
    config.add_show_field "note_bio_display", label: "Biographical or Historical Note"
1✔
244
    config.add_show_field "note_summary_display", label: "Summary"
1✔
245
    config.add_show_field "note_restrictions_display", label: "Access and Restrictions"
1✔
246
    config.add_show_field "note_copyright_display", label: "Copyright Note"
1✔
247
    config.add_show_field "note_references_display", label: "Cited in"
1✔
248
    config.add_show_field "note_cite_display", label: "Cite as"
1✔
249
    config.add_show_field "note_finding_aid_display", label: "Cumulative Index/Finding Aids"
1✔
250
    config.add_show_field "note_custodial_display", label: "Custodial History"
1✔
251
    config.add_show_field "note_binding_display", label: "Binding Note"
1✔
252
    config.add_show_field "note_related_display", label: "Related Materials"
1✔
253
    config.add_show_field "note_accruals_display", label: "Additions to Collection"
1✔
254
    config.add_show_field "note_local_display", label: "Local Note"
1✔
255
    config.add_show_field "donor_info_ms", label: "Donor bookplate", helper_method: :record_page_ms_links, multi: true
1✔
256
    config.add_show_field "subject_display", label: "Subject", helper_method: :subject_links, multi: true
1✔
257
    config.add_show_field "genre_ms", label: "Genre", helper_method: :record_page_ms_links, multi: true
1✔
258
    config.add_show_field "collection_area_display", label: "SCRC Collecting Area"
1✔
259

260
    # Preceeding Entry fields
261
    config.add_show_field "continues_display", label: "Continues"
1✔
262
    config.add_show_field "continues_in_part_display", label: "Continues in part"
1✔
263
    config.add_show_field "formed_from_display", label: "Formed from"
1✔
264
    config.add_show_field "absorbed_display", label: "Absorbed"
1✔
265
    config.add_show_field "absorbed_in_part_display", label: "Absorbed in part"
1✔
266
    config.add_show_field "separated_from_display", label: "Separated from"
1✔
267

268
    # Succeeding Entry fields
269
    config.add_show_field "continued_by_display", label: "Continued by"
1✔
270
    config.add_show_field "continued_in_part_by_display", label: "Continued in part by"
1✔
271
    config.add_show_field "absorbed_by_display", label: "Absorbed by"
1✔
272
    config.add_show_field "absorbed_in_part_by_display", label: "Absorbed in part by"
1✔
273
    config.add_show_field "split_into_display", label: "Split into"
1✔
274
    config.add_show_field "merged_to_form_display", label: "Merged to form"
1✔
275
    config.add_show_field "changed_back_to_display", label: "Changed back to"
1✔
276

277
    config.add_show_field "isbn_display", label: "ISBN"
1✔
278
    config.add_show_field "alt_isbn_display", label: "Other ISBN"
1✔
279
    config.add_show_field "issn_display", label: "ISSN"
1✔
280
    config.add_show_field "alt_issn_display", label: "Other ISSN"
1✔
281
    config.add_show_field "pub_no_display", label: "Publication Number"
1✔
282
    config.add_show_field "gpo_display", label: "GPO Item Number"
1✔
283
    config.add_show_field "sudoc_display", label: "SuDOC"
1✔
284
    config.add_show_field "lc_call_number_display", label: "LC Classification"
1✔
285
    config.add_show_field "alma_mms_display", label: "Catalog Record ID"
1✔
286
    config.add_show_field "language_display", label: "Language"
1✔
287
    config.add_show_field "url_more_links_display", label: "Other Links", helper_method: :check_for_full_http_link
1✔
288
    config.add_show_field "electronic_resource_display", label: "Availability", helper_method: :check_for_full_http_link, if: false
1✔
289
    config.add_show_field "bound_with_ids", display: false
1✔
290

291
    config.add_show_field "po_link", field: "purchase_order", if: false, helper_method: :render_purchase_order_show_link
1✔
292
    config.add_show_field "purchase_order_availability", label: "Request Rapid Access", field: "purchase_order", if: false, helper_method: :render_purchase_order_availability, with_panel: true
1✔
293

294
    # "fielded" search configuration. Used by pulldown among other places.
295
    # For supported keys in hash, see rdoc for Blacklight::SearchFields
296
    #
297
    # Search fields will inherit the :qt solr request handler from
298
    # config[:default_solr_parameters], OR can specify a different one
299
    # with a :qt key/value. Below examples inherit, except for subject
300
    # that specifies the same :qt as default for our own internal
301
    # testing purposes.
302
    #
303
    # The :key is what will be used to identify this BL search field internally,
304
    # as well as in URLs -- so changing it after deployment may break bookmarked
305
    # urls.  A display label will be automatically calculated from the :key,
306
    # or can be specified manually to be different.
307

308
    # This one uses all the defaults set by the solr request handler. Which
309
    # solr request handler? The one set in config[:default_solr_parameters][:qt],
310
    # since we aren't specifying it otherwise.
311

312
    config.add_search_field "all_fields", label: "All Fields"
1✔
313

314
    # Now we see how to over-ride Solr request handler defaults, in this
315
    # case for a BL "search field", which is really a dismax aggregate
316
    # of Solr search fields.
317

318

319
    config.add_search_field("title") do |field|
1✔
320
      # solr_parameters hash are sent to Solr as ordinary url query params.
321
      field.solr_parameters = {
1✔
322
        # Curly brackets are required for solr_parameters.
323
        qf: "${title_qf}",
324
        pf: "${title_pf}"
325
      }
326

327
      field.solr_adv_parameters = {
1✔
328
        # Curly brackets break solr_adv_parameters.
329
        qf: "$title_qf",
330
        pf: "$title_pf"
331
      }
332
    end
333

334
    config.add_search_field("creator_t", label: "Author/creator/contributor") do |field|
1✔
335
      field.solr_parameters = {
1✔
336
        qf: "${author_qf}",
337
        pf: "${author_pf}"
338
      }
339

340
      field.solr_adv_parameters = {
1✔
341
        qf: "$author_qf",
342
        pf: "$author_pf"
343
      }
344
    end
345

346
    # Specifying a :qt only to show it's possible, and so our internal automated
347
    # tests can test it. In this case it's the same as
348
    # config[:default_solr_parameters][:qt], so isn't actually neccesary.
349
    config.add_search_field("subject") do |field|
1✔
350
      field.solr_parameters = {
1✔
351
        qf: "${subject_qf}",
352
        pf: "${subject_pf}"
353
      }
354

355
      field.solr_adv_parameters = {
1✔
356
        qf: "$subject_qf",
357
        pf: "$subject_pf"
358
      }
359
    end
360

361
    config.add_search_field("genre") do |field|
1✔
362
      field.include_in_simple_select = false
1✔
363
      field.solr_parameters = {
1✔
364
        qf: "genre_t",
365
      }
366
    end
367

368
    config.add_search_field("publisher_t", label: "Publisher") do |field|
1✔
369
      field.include_in_simple_select = false
1✔
370
      field.solr_parameters = {
1✔
371
        qf: "publisher_t",
372
      }
373
    end
374

375
    config.add_search_field("title_series_t", label: "Series Title") do |field|
1✔
376
      field.include_in_simple_select = false
1✔
377
      field.solr_parameters = {
1✔
378
        qf: "title_series_t",
379
      }
380
    end
381

382
    config.add_search_field("note_t", label: "Description") do |field|
1✔
383
      field.include_in_simple_select = false
1✔
384
      field.solr_parameters = {
1✔
385
        qf: %w[note_t note_with_t note_diss_t note_biblio_t note_toc_t note_restrictions_t note_references_t note_summary_t note_cite_t note_copyright_t note_bio_t note_finding_aid_t note_custodial_t note_binding_t note_related_t note_accruals_t note_local_t].join(" ")
386
      }
387
    end
388

389
    config.add_search_field("isbn_t", label: "ISBN") do |field|
1✔
390
      field.solr_parameters = {
1✔
391
        qf: "isbn_t",
392
      }
393
    end
394

395
    config.add_search_field("issn_t", label: "ISSN") do |field|
1✔
396
      field.solr_parameters = {
1✔
397
        qf: "issn_t",
398
      }
399
    end
400

401
    config.add_search_field("call_number_t", label: "Call Number") do |field|
1✔
402
      field.include_in_advanced_search = true
1✔
403
      field.include_in_simple_select = false
1✔
404
      field.solr_parameters = {
1✔
405
        qf: "call_number_t",
406
      }
407
    end
408

409
    config.add_search_field("alma_mms_t", label: "Catalog Record ID") do |field|
1✔
410
      field.include_in_simple_select = false
1✔
411
      field.solr_parameters = {
1✔
412
        qf: "alma_mms_t",
413
      }
414
    end
415

416
    # "sort results by" select (pulldown)
417
    # label in pulldown is followed by the name of the SOLR field to sort by and
418
    # whether the sort is ascending or descending (it must be asc or desc
419
    # except in the relevancy case).
420

421
    config.add_sort_field "score desc, pub_date_sort desc, title_sort asc", label: "relevance"
1✔
422
    config.add_sort_field "pub_date_sort desc, title_sort asc", label: "date (new to old)"
1✔
423
    config.add_sort_field "pub_date_sort asc, title_sort asc", label: "date (old to new)"
1✔
424
    config.add_sort_field "author_sort asc, title_sort asc", label: "author/creator (A to Z)"
1✔
425
    config.add_sort_field "author_sort desc, title_sort asc", label: "author/creator (Z to A)"
1✔
426
    config.add_sort_field "title_sort asc, pub_date_sort desc", label: "title (A to Z)"
1✔
427
    config.add_sort_field "title_sort desc, pub_date_sort desc", label: "title (Z to A)"
1✔
428
    config.add_sort_field "lc_call_number_sort asc, pub_date_sort desc", label: "lc classification (A to Z)"
1✔
429
    config.add_sort_field "lc_call_number_sort desc, pub_date_sort desc", label: "lc classification (Z to A)"
1✔
430
    config.add_sort_field "date_added_facet desc, title_sort asc", label: "newly added"
1✔
431

432
    # If there are more than this many search results, no spelling ("did you
433
    # mean") suggestion is offered.
434
    config.spell_max = 5
1✔
435

436
    # Configuration for autocomplete suggestor
437
    config.autocomplete_enabled = false
1✔
438
    config.autocomplete_path = "suggest"
1✔
439

440
    config.add_nav_action :library_account, partial: "/users/account_link", if: :user_signed_in?
1✔
441

442
    # marc config
443
    # Do not show library_view link
444
    config.show.document_actions.delete(:librarian_view)
1✔
445
    #config.add_show_tools_partial(:ris, label: "RIS File", if: :render_ris_action?, modal: false, path: :ris_path)
446
    # Do not show endnotes for beta release
447
    config.show.document_actions.delete(:endnote)
1✔
448
    config.add_show_tools_partial(:citation)
1✔
449
    # Need to add citation for side effect only.
450
    config.show.document_actions.delete(:citation)
1✔
451
    config.show.document_actions.delete(:refworks)
1✔
452

453
    # Document results tools
454
    config.add_results_document_tool(:bookmark, partial: "bookmark_control", if: :render_bookmarks_control?)
1✔
455

456
    # Results collection tools
457
    config.add_results_collection_tool(:sort_widget)
1✔
458
    config.add_results_collection_tool(:per_page_widget)
1✔
459
    config.add_results_collection_tool(:view_type_group)
1✔
460

461
    # Show tools
462
    config.add_show_tools_partial(:bookmark, partial: "bookmark_control", if: :render_bookmarks_control?)
1✔
463
    config.add_show_tools_partial(:email, callback: :email_action, validator: :validate_email_params)
1✔
464
    config.add_show_tools_partial(:ris, label: "RIS file (for Zotero, Mendeley, Endnote)", modal: false, path: :ris_path)
1✔
465

466
    # Nav tools
467
    config.add_nav_action(:bookmark, partial: "blacklight/nav/bookmark", if: :render_bookmarks_control?)
1✔
468

469
    config.show.document_actions.delete(:email) if Rails.configuration.features[:email_document_action_disabled]
1✔
470

471
  end
472

473
  def availability
1✔
474
    ids = params["id_list"].split(",")
1✔
475
    response = Alma::Bib.get_availability(ids)
1✔
476
    render json: { availability: response.availability }.to_json
1✔
477
  end
478

479
  # Can be overridden by subclass
480
  def show_sidebar?
1✔
481
    has_search_parameters?
92✔
482
  end
483

484
  helper_method :show_sidebar?
1✔
485

486
  def text_this_message_body(params)
1✔
UNCOV
487
    "#{params[:title]}\n" +
×
488
    "#{params[:location]}"
489
  end
490

491
  def creator_links(args)
1✔
492
    creator = args[:document][args[:field]] || []
×
493
    base_path = helpers.base_path
×
UNCOV
494
    creator.map do |creator_data|
×
495
      begin
496
        creator_data = JSON.parse(creator_data)
×
497
        relation = creator_data["relation"]
×
498
        name = creator_data["name"]
×
UNCOV
499
        role = creator_data["role"]
×
500
      rescue JSON::ParserError
UNCOV
501
        name, role = creator_data.split("|")
×
502
      end
503

504
      creator_query = view_context.send(:url_encode, name)
×
UNCOV
505
      name_link = view_context.link_to(name, base_path + "?f[creator_facet][]=#{creator_query}") if name.present?
×
506

UNCOV
507
      ActiveSupport::SafeBuffer.new([ relation,
×
508
        name_link,
509
        role ].select(&:present?).join(" "))
510
    end
511
  end
512

513
  def display_duration(args)
1✔
514
    args[:value]&.map { |v| v.scan(/([0-9]{2})/).join(":") }
2✔
515
  end
516

517
  # Overrides CatalogController.invalid_document_id_error
518
  # Overridden so that we can use our own 404 error handling setup.
519
  def invalid_document_id_error(exception)
1✔
520
    error_info = {
521
      "status" => "404",
2✔
522
      "error"  => "#{exception.class}: #{exception.message}"
523
    }
524

525
    respond_to do |format|
2✔
526
      format.xml  { render xml: error_info, status: :not_found }
2✔
527
      format.json { render json: error_info, status: :not_found }
2✔
528

529
      # default to HTML response, even for other non-HTML formats we don't
530
      # neccesarily know about, seems to be consistent with what Rails4 does
531
      # by default with uncaught ActiveRecord::RecordNotFound in production
532
      format.any do
2✔
533
        # use standard, possibly locally overridden, 404.html file. Even for
534
        # possibly non-html formats, this is consistent with what Rails does
535
        # on raising an ActiveRecord::RecordNotFound. Rails.root IS needed
536
        # for it to work under testing, without worrying about CWD.
537
        render "errors/not_found", status: :not_found
2✔
538
      end
539
    end
540
  end
541

542
  def raise_bad_range_limit(exception)
1✔
543
    flash[:notice] = exception.message
×
UNCOV
544
    redirect_to request.referrer || root_url
×
545
  end
546

547
  def purchase_order
1✔
548
    (@response, @document) = search_service.fetch(params["id"])
1✔
549
    render layout: false
1✔
550
  end
551

552
  def purchase_order_action
1✔
UNCOV
553
    (_, document) = search_service.fetch(params["id"])
×
554

555
    email = current_user&.email || params[:to]
×
UNCOV
556
    name = current_user&.name
×
557

UNCOV
558
    from = { email: email, name: name }
×
559

560
    mail = PurchaseOrderMailer.purchase_order(document, { from: from, message: params[:message] }, url_options)
×
561
    log = { type: "purchase_order", user: current_user.id, mms_id: document.id }
×
562
    if mail.respond_to? :deliver_now
×
UNCOV
563
      do_with_json_logger(log) { mail.deliver_now }
×
564
    else
UNCOV
565
      do_with_json_logger(log) { mail.deliver }
×
566
    end
567

UNCOV
568
    redirect_back(fallback_location: root_path, success: "Your request has been submitted.")
×
569
  end
570

571
  def authenticate_purchase_order!
1✔
572
    authenticate_user!
6✔
573
    message = "You do not have access to purchase order items."
4✔
574
    to_the_future = { fallback_location: root_path, alert: message }
4✔
575

576
    redirect_back(**to_the_future) unless current_user.can_purchase_order?
4✔
577
  end
578

579
  # Override the show method so we can suppress some items that solr doesn't want to filter out
580
  # get a single document from the index
581
  # to add responses for formats other than html or json see _Blacklight::Document::Export_
582
  def show
1✔
583
    deprecated_response, @document = search_service.fetch(params[:id])
152✔
584
    @response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_response, "The @response instance variable is deprecated; use @document.response instead.")
152✔
585

586
    # Our override that can be removed if we can figure out how to do a negatove filter query in the document/get handler
587
    # without breaking results that shouldn't be filtered.
588
    raise Blacklight::Exceptions::RecordNotFound if @document.is_suppressed?
152✔
589

590
    respond_to do |format|
151✔
591
      format.html { @search_context = setup_next_and_previous_documents }
302✔
592
      format.json
151✔
593
      additional_export_formats(@document, format)
151✔
594
    end
595
  end
596

597
  # Override index because we don't show any results at /catalog when
598
  # there are no parameters, and so we don't need to bother solr
599
  def index
1✔
600
    if has_search_parameters? || advanced_controller?
59✔
601
      super
47✔
602
    else
603
      respond_to do |format|
12✔
604
        format.html { store_preferred_view }
24✔
605
      end
606
    end
607
  end
608

609
  private
1✔
610
    def catalog?
1✔
UNCOV
611
      self.class == CatalogController
×
612
    end
613

614
    def advanced_controller?
1✔
615
      self.class == AdvancedController
12✔
616
    end
617

618
    # Allow access to request outside of controller context.
619
    def set_thread_request
1✔
620
      LogUtils.request = request
269✔
621
    end
622
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc