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

uclibs / ucrate / 285e4356-abf0-4868-97a1-916047b49424

28 Aug 2025 02:12PM UTC coverage: 49.621% (-6.4%) from 56.032%
285e4356-abf0-4868-97a1-916047b49424

Pull #1187

circleci

hortongn
Gem updates to fix Capistrano
Pull Request #1187: Gem updates to fix Capistrano

1966 of 3962 relevant lines covered (49.62%)

68.04 hits per line

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

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

3
class CatalogController < ApplicationController
1✔
4
  include Hydra::Catalog
1✔
5
  include Hydra::Controller::ControllerBehavior
1✔
6

7
  # This filter applies the hydra access controls
8
  before_action :enforce_show_permissions, only: :show
1✔
9

10
  def self.uploaded_field
1✔
11
    solr_name('system_create', :stored_sortable, type: :date)
3✔
12
  end
13

14
  def self.title_field
1✔
15
    solr_name('sort_title', :stored_sortable, type: :string)
2✔
16
  end
17

18
  def self.modified_field
1✔
19
    solr_name('system_modified', :stored_sortable, type: :date)
2✔
20
  end
21

22
  configure_blacklight do |config|
1✔
23
    config.view.gallery.partials = [:index_header, :index]
1✔
24
    config.view.masonry.partials = [:index]
1✔
25
    config.view.slideshow.partials = [:index]
1✔
26
    config.show.tile_source_field = :content_metadata_image_iiif_info_ssm
1✔
27
    config.show.partials.insert(1, :openseadragon)
1✔
28
    config.search_builder_class = Hyrax::CatalogSearchBuilder
1✔
29

30
    # Show gallery view
31
    config.view.gallery.partials = [:index_header, :index]
1✔
32
    config.view.slideshow.partials = [:index]
1✔
33

34
    # Because too many times on Samvera tech people raise a problem regarding a failed query to SOLR.
35
    # Often, it's because they inadvertantly exceeded the character limit of a GET request.
36
    config.http_method = :post
1✔
37

38
    ## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
39
    config.default_solr_params = {
1✔
40
      qt: "search",
41
      rows: 10,
42
      qf: "title_tesim description_tesim creator_tesim keyword_tesim"
43
    }
44

45
    # solr field configuration for document/show views
46
    config.index.title_field = solr_name("title", :stored_searchable)
1✔
47
    config.index.display_type_field = solr_name("has_model", :symbol)
1✔
48
    config.index.thumbnail_field = 'thumbnail_path_ss'
1✔
49

50
    # solr fields that will be treated as facets by the blacklight application
51
    #   The ordering of the field names is the order of the display
52
    config.add_facet_field solr_name("human_readable_type", :facetable), limit: 5
1✔
53
    config.add_facet_field solr_name("creator", :facetable), limit: 5
1✔
54
    config.add_facet_field solr_name("subject", :facetable), limit: 5
1✔
55
    config.add_facet_field solr_name("college", :facetable), limit: 5
1✔
56
    config.add_facet_field solr_name("department", :facetable), limit: 5
1✔
57
    config.add_facet_field solr_name("language", :facetable), limit: 5
1✔
58
    config.add_facet_field solr_name("publisher", :facetable), limit: 5
1✔
59
    config.add_facet_field solr_name("date_created", :facetable), limit: 5
1✔
60
    config.add_facet_field solr_name('member_of_collection_ids', :symbol), limit: 5, helper_method: :collection_title_by_id
1✔
61

62
    # The generic_type isn't displayed on the facet list
63
    # It's used to give a label to the filter that comes from the user profile
64
    config.add_facet_field solr_name("generic_type", :facetable), if: false
1✔
65

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

71
    # solr fields to be displayed in the index (search results) view
72
    #   The ordering of the field names is the order of the display
73
    config.add_index_field solr_name("title", :stored_searchable), itemprop: 'name', if: false
1✔
74
    config.add_index_field solr_name("human_readable_type", :stored_searchable), label: "Type"
1✔
75
    config.add_index_field solr_name("description", :stored_searchable), itemprop: 'description', helper_method: :iconify_auto_link
1✔
76
    config.add_index_field solr_name("alt_description", :stored_searchable), itemprop: 'description', helper_method: :iconify_auto_link
1✔
77
    config.add_index_field solr_name("creator", :stored_searchable), itemprop: 'creator', separator_options: { words_connector: "; " }, link_to_search: solr_name("creator", :facetable)
1✔
78
    config.add_index_field solr_name("depositor"), label: "Submitter", helper_method: :link_to_profile
1✔
79
    config.add_index_field solr_name("date_uploaded", :stored_sortable, type: :date), helper_method: :human_readable_date
1✔
80
    config.add_index_field solr_name("date_modified", :stored_sortable, type: :date), helper_method: :human_readable_date
1✔
81
    config.add_index_field solr_name("date_created", :stored_searchable), itemprop: 'dateCreated'
1✔
82
    config.add_index_field solr_name("license", :stored_searchable), helper_method: :license_links
1✔
83

84
    # solr fields to be displayed in the show (single result) view
85
    #   The ordering of the field names is the order of the display
86
    config.add_show_field solr_name("title", :stored_searchable)
1✔
87
    config.add_show_field solr_name("description", :stored_searchable)
1✔
88
    config.add_show_field solr_name("subject", :stored_searchable)
1✔
89
    config.add_show_field solr_name("creator", :stored_searchable)
1✔
90
    config.add_show_field solr_name("depositor"), label: "Submitter", helper_method: :link_to_profile
1✔
91
    config.add_show_field solr_name("college", :stored_searchable), label: "College"
1✔
92
    config.add_show_field solr_name("department", :stored_searchable), label: "Program or Department"
1✔
93
    config.add_show_field solr_name("contributor", :stored_searchable)
1✔
94
    config.add_show_field solr_name("publisher", :stored_searchable)
1✔
95
    config.add_show_field solr_name("based_near_label", :stored_searchable)
1✔
96
    config.add_show_field solr_name("geo_subject", :stored_searchable)
1✔
97
    config.add_show_field solr_name("language", :stored_searchable)
1✔
98
    config.add_show_field solr_name("date_uploaded", :stored_searchable, type: :date), itemprop: 'datePublished', helper_method: :human_readable_date
1✔
99
    config.add_show_field solr_name("date_modified", :stored_searchable, type: :date), itemprop: 'dateModified', helper_method: :human_readable_date
1✔
100
    config.add_show_field solr_name("date_created", :stored_searchable)
1✔
101
    config.add_show_field solr_name("rights_statement", :stored_searchable)
1✔
102
    config.add_show_field solr_name("license", :stored_searchable)
1✔
103
    config.add_show_field solr_name("resource_type", :stored_searchable), label: "Resource Type"
1✔
104
    config.add_show_field solr_name("format", :stored_searchable)
1✔
105
    config.add_show_field solr_name("identifier", :stored_searchable)
1✔
106
    config.add_show_field solr_name("alternate_title", :stored_searchable), label: "Alternate Title"
1✔
107
    config.add_show_field solr_name("journal_title", :stored_searchable), label: "Journal Title"
1✔
108
    config.add_show_field solr_name("issn", :stored_searchable), label: "ISSN"
1✔
109
    config.add_show_field solr_name("time_period", :stored_searchable), label: "Time Period"
1✔
110
    config.add_show_field solr_name("required_software", :stored_searchable), label: "Required Software"
1✔
111
    config.add_show_field solr_name("note", :stored_searchable), label: "Note"
1✔
112
    config.add_show_field solr_name("genre", :stored_searchable), label: "Genre"
1✔
113
    config.add_show_field solr_name("degree", :stored_searchable), label: "Degree"
1✔
114
    config.add_show_field solr_name("advisor", :stored_searchable), label: "Advisor"
1✔
115

116
    # "fielded" search configuration. Used by pulldown among other places.
117
    # For supported keys in hash, see rdoc for Blacklight::SearchFields
118
    #
119
    # Search fields will inherit the :qt solr request handler from
120
    # config[:default_solr_parameters], OR can specify a different one
121
    # with a :qt key/value. Below examples inherit, except for subject
122
    # that specifies the same :qt as default for our own internal
123
    # testing purposes.
124
    #
125
    # The :key is what will be used to identify this BL search field internally,
126
    # as well as in URLs -- so changing it after deployment may break bookmarked
127
    # urls.  A display label will be automatically calculated from the :key,
128
    # or can be specified manually to be different.
129
    #
130
    # This one uses all the defaults set by the solr request handler. Which
131
    # solr request handler? The one set in config[:default_solr_parameters][:qt],
132
    # since we aren't specifying it otherwise.
133
    config.add_search_field('all_fields', label: 'All Fields') do |field|
1✔
134
      all_names = config.show_fields.values.map(&:field).join(" ")
1✔
135
      title_name = solr_name("title", :stored_searchable)
1✔
136
      field.solr_parameters = {
1✔
137
        qf: "#{all_names} file_format_tesim all_text_timv",
138
        pf: title_name.to_s
139
      }
140
    end
141

142
    # Now we see how to over-ride Solr request handler defaults, in this
143
    # case for a BL "search field", which is really a dismax aggregate
144
    # of Solr search fields.
145
    # creator, title, description, publisher, date_created,
146
    # subject, language, resource_type, format, identifier, based_near,
147
    config.add_search_field('contributor') do |field|
1✔
148
      # solr_parameters hash are sent to Solr as ordinary url query params.
149

150
      # :solr_local_parameters will be sent using Solr LocalParams
151
      # syntax, as eg {! qf=$title_qf }. This is neccesary to use
152
      # Solr parameter de-referencing like $title_qf.
153
      # See: http://wiki.apache.org/solr/LocalParams
154
      solr_name = solr_name("contributor", :stored_searchable)
1✔
155
      field.solr_local_parameters = {
1✔
156
        qf: solr_name,
157
        pf: solr_name
158
      }
159
    end
160

161
    config.add_search_field('creator') do |field|
1✔
162
      solr_name = solr_name("creator", :stored_searchable)
1✔
163
      field.solr_local_parameters = {
1✔
164
        qf: solr_name,
165
        pf: solr_name
166
      }
167
    end
168

169
    config.add_search_field('title') do |field|
1✔
170
      solr_name = solr_name("title", :stored_searchable)
1✔
171
      field.solr_local_parameters = {
1✔
172
        qf: solr_name,
173
        pf: solr_name
174
      }
175
    end
176

177
    config.add_search_field('description') do |field|
1✔
178
      field.label = "Abstract or Summary"
1✔
179
      solr_name = solr_name("description", :stored_searchable)
1✔
180
      field.solr_local_parameters = {
1✔
181
        qf: solr_name,
182
        pf: solr_name
183
      }
184
    end
185

186
    config.add_search_field('publisher') do |field|
1✔
187
      solr_name = solr_name("publisher", :stored_searchable)
1✔
188
      field.solr_local_parameters = {
1✔
189
        qf: solr_name,
190
        pf: solr_name
191
      }
192
    end
193

194
    config.add_search_field('date_created') do |field|
1✔
195
      solr_name = solr_name("date_created", :stored_searchable)
1✔
196
      field.solr_local_parameters = {
1✔
197
        qf: solr_name,
198
        pf: solr_name
199
      }
200
    end
201

202
    config.add_search_field('subject') do |field|
1✔
203
      solr_name = solr_name("subject", :stored_searchable)
1✔
204
      field.solr_local_parameters = {
1✔
205
        qf: solr_name,
206
        pf: solr_name
207
      }
208
    end
209

210
    config.add_search_field('language') do |field|
1✔
211
      solr_name = solr_name("language", :stored_searchable)
1✔
212
      field.solr_local_parameters = {
1✔
213
        qf: solr_name,
214
        pf: solr_name
215
      }
216
    end
217

218
    config.add_search_field('resource_type') do |field|
1✔
219
      solr_name = solr_name("resource_type", :stored_searchable)
1✔
220
      field.solr_local_parameters = {
1✔
221
        qf: solr_name,
222
        pf: solr_name
223
      }
224
    end
225

226
    config.add_search_field('format') do |field|
1✔
227
      solr_name = solr_name("format", :stored_searchable)
1✔
228
      field.solr_local_parameters = {
1✔
229
        qf: solr_name,
230
        pf: solr_name
231
      }
232
    end
233

234
    config.add_search_field('identifier') do |field|
1✔
235
      solr_name = solr_name("id", :stored_searchable)
1✔
236
      field.solr_local_parameters = {
1✔
237
        qf: solr_name,
238
        pf: solr_name
239
      }
240
    end
241

242
    config.add_search_field('based_near') do |field|
1✔
243
      field.label = "Location"
1✔
244
      solr_name = solr_name("based_near_label", :stored_searchable)
1✔
245
      field.solr_local_parameters = {
1✔
246
        qf: solr_name,
247
        pf: solr_name
248
      }
249
    end
250

251
    config.add_search_field('depositor') do |field|
1✔
252
      solr_name = solr_name("depositor", :symbol)
1✔
253
      field.solr_local_parameters = {
1✔
254
        qf: solr_name,
255
        pf: solr_name
256
      }
257
    end
258

259
    config.add_search_field('rights_statement') do |field|
1✔
260
      solr_name = solr_name("rights_statement", :stored_searchable)
1✔
261
      field.solr_local_parameters = {
1✔
262
        qf: solr_name,
263
        pf: solr_name
264
      }
265
    end
266

267
    config.add_search_field('license') do |field|
1✔
268
      solr_name = solr_name("license", :stored_searchable)
1✔
269
      field.solr_local_parameters = {
1✔
270
        qf: solr_name,
271
        pf: solr_name
272
      }
273
    end
274

275
    # "sort results by" select (pulldown)
276
    # label in pulldown is followed by the name of the SOLR field to sort by and
277
    # whether the sort is ascending or descending (it must be asc or desc
278
    # except in the relevancy case).
279
    # label is key, solr field is value
280
    config.add_sort_field "score desc, #{uploaded_field} desc", label: "relevance"
1✔
281
    config.add_sort_field "#{uploaded_field} desc", label: "date uploaded \u25BC"
1✔
282
    config.add_sort_field "#{uploaded_field} asc", label: "date uploaded \u25B2"
1✔
283
    config.add_sort_field "#{modified_field} desc", label: "date modified \u25BC"
1✔
284
    config.add_sort_field "#{modified_field} asc", label: "date modified \u25B2"
1✔
285
    config.add_sort_field "#{title_field} asc", label: "title A-Z"
1✔
286
    config.add_sort_field "#{title_field} desc", label: "title Z-A"
1✔
287

288
    # If there are more than this many search results, no spelling ("did you
289
    # mean") suggestion is offered.
290
    config.spell_max = 5
1✔
291
  end
292

293
  # disable the bookmark control from displaying in gallery view
294
  # Hyrax doesn't show any of the default controls on the list view, so
295
  # this method is not called in that context.
296
  def render_bookmarks_control?
1✔
297
    false
×
298
  end
299
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