Skip to content

Commit a20595c

Browse files
committed
DetailsController#embed should use catalog layouts (DLC-1169)
1 parent a770a1c commit a20595c

File tree

3 files changed

+32
-115
lines changed

3 files changed

+32
-115
lines changed

app/controllers/details_controller.rb

Lines changed: 11 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,23 @@
1-
class DetailsController < ApplicationController
1+
class DetailsController < SubsitesController
22
include Dcv::CatalogIncludes
33
include Dcv::Sites::SearchableController
4-
extend Dcv::Configurators::BaseBlacklightConfigurator
4+
include Dcv::Sites::ConfiguredLayouts
5+
include Dcv::Catalog::CatalogLayout
56

67
layout 'details'
78

89
_prefixes << 'catalog' # haaaaaaack to not reproduce templates
910

1011
configure_blacklight do |config|
11-
config.default_solr_params = {
12-
:qt => 'search',
13-
:rows => 20
14-
}
15-
config.search_state_fields.concat(DETAILS_PARAMS)
16-
config.per_page = [20,60,100]
17-
# solr field configuration for search results/index views
18-
default_index_configuration(config)
19-
default_show_configuration(config)
20-
21-
# solr fields that will be treated as facets by the blacklight application
22-
# The ordering of the field names is the order of the display
23-
#
24-
# Setting a limit will trigger Blacklight's 'more' facet values link.
25-
# * If left unset, then all facet values returned by solr will be displayed.
26-
# * If set to an integer, then "f.somefield.facet.limit" will be added to
27-
# solr request, with actual solr request being +1 your configured limit --
28-
# you configure the number of items you actually want _tsimed_ in a page.
29-
# * If set to 'true', then no additional parameters will be sent to solr,
30-
# but any 'sniffed' request limit parameters will be used for paging, with
31-
# paging at requested limit -1. Can sniff from facet.limit or
32-
# f.specific_field.facet.limit solr request params. This 'true' config
33-
# can be used if you set limits in :default_solr_params, or as defaults
34-
# on the solr side in the request handler itself. Request handler defaults
35-
# sniffing requires solr requests to be made with "echoParams=all", for
36-
# app code to actually have it echo'd back to see it.
37-
#
38-
# :show may be set to false if you don't want the facet to be drawn in the
39-
# facet bar
40-
41-
config.add_facet_fields_to_solr_request! # Required for facet queries
42-
43-
config.add_facet_field 'lib_project_sim', :label => 'Project'
44-
config.add_facet_field 'lib_collection_sim', :label => 'Collection'
45-
config.add_facet_field 'lib_repo_short_ssim', :label => 'Library Location'
46-
config.add_facet_field 'lib_name_sim', :label => 'Name'
47-
config.add_facet_field 'lib_format_sim', :label => 'Format'
48-
#todo: date
49-
#todo: language
50-
config.add_facet_field 'format_ssi', :label => 'System Format'
51-
52-
config.add_facet_field 'lc1_letter_sim', :label => 'Call Number'
53-
54-
# Have BL send all facet field names to Solr, which has been the default
55-
# previously. Simply remove these lines if you'd rather use Solr request
56-
# handler defaults, or have no facets.
57-
config.default_solr_params['facet.field'] = config.facet_fields.map { |key, config| config.field || config.key }
58-
#use this instead if you don't want to query facets marked :show=>false
59-
#config.default_solr_params['facet.field'] = config.facet_fields.select{ |k, v| v[:show] != false}.keys
60-
61-
62-
# solr fields to be displayed in the index (search results) view
63-
# The ordering of the field names is the order of the display
64-
config.add_index_field 'title_display_ssm', :label => 'Title'
65-
config.add_index_field 'lib_collection_ssm', :label => 'Collection'
66-
67-
# solr fields to be displayed in the show (single result) view
68-
# The ordering of the field names is the order of the display
69-
config.add_show_field 'title_display_ssm', :label => 'Title'
70-
config.add_show_field 'identifier_ssim', :label => 'Identifier'
71-
config.add_show_field 'lib_format_ssm', :label => 'Format'
72-
config.add_show_field 'lib_name_ssm', :label => 'Name'
73-
config.add_show_field 'lib_collection_ssm', :label=>"Collection"
74-
75-
# "fielded" search configuration. Used by pulldown among other places.
76-
# For supported keys in hash, see rdoc for Blacklight::SearchFields
77-
#
78-
# Search fields will inherit the :qt solr request handler from
79-
# config[:default_solr_parameters], OR can specify a different one
80-
# with a :qt key/value. Below examples inherit, except for subject
81-
# that specifies the same :qt as default for our own internal
82-
# testing purposes.
83-
#
84-
# The :key is what will be used to identify this BL search field internally,
85-
# as well as in URLs -- so changing it after deployment may break bookmarked
86-
# urls. A display label will be automatically calculated from the :key,
87-
# or can be specified manually to be different.
88-
89-
# All Text search configuration, used by main search pulldown.
90-
config.add_search_field 'all_text_teim' do |field|
91-
field.label = 'All Fields'
92-
field.default = true
93-
field.solr_parameters = {
94-
:qf => ['all_text_teim'],
95-
:pf => ['all_text_teim']
12+
config.search_state_fields.concat(Dcv::Configurators::BaseBlacklightConfigurator::Constants::DETAILS_PARAMS)
13+
Dcv::Configurators::DcvBlacklightConfigurator.configure(config)
14+
# Include this target's content in search results, and any additional publish targets specified in subsites.yml
15+
configure_blacklight_scope_constraints(config, true)
16+
config.add_facet_field 'content_availability', label: 'Limit by Availability', show: false,
17+
query: {
18+
onsite: { label: 'Reading Room', fq: "{!join from=cul_member_of_ssim to=fedora_pid_uri_ssi}!access_control_levels_ssim:Public*" },
19+
public: { label: 'Public', fq: "{!join from=cul_member_of_ssim to=fedora_pid_uri_ssi}access_control_levels_ssim:Public*" },
9620
}
97-
end
98-
99-
config.add_search_field 'search_title_info_search_title_teim' do |field|
100-
field.label = 'Title'
101-
field.solr_parameters = {
102-
:qf => ['search_title_info_search_title_teim'],
103-
:pf => ['search_title_info_search_title_teim']
104-
}
105-
end
106-
107-
config.add_search_field 'lib_name_teim' do |field|
108-
field.label = 'Name'
109-
field.solr_parameters = {
110-
:qf => ['lib_name_teim'],
111-
:pf => ['lib_name_teim']
112-
}
113-
end
114-
115-
# "sort results by" select (pulldown)
116-
# label in pulldown is followed by the name of the SOLR field to sort by and
117-
# whether the sort is ascending or descending (it must be asc or desc
118-
# except in the relevancy case).
119-
config.add_sort_field 'score desc, title_si asc, lib_date_dtsi desc', :label => 'relevance'
120-
config.add_sort_field 'title_si asc, lib_date_dtsi desc', :label => 'title'
121-
122-
# If there are more than this many search results, no spelling ("did you
123-
# mean") suggestion is offered.
124-
config.spell_max = 5
12521
end
12622

12723
def show
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'rails_helper'
2+
3+
describe DetailsController, type: :feature do
4+
# the relevant fixtures are loaded into the repository and seeded into the Site
5+
# database tables by CI tasks
6+
include_context "site fixtures for features"
7+
8+
describe "details" do
9+
before { visit "/catalog/donotuse:item/details" }
10+
it "shows the item title" do
11+
expect(page).to have_text('William Burroughs')
12+
end
13+
end
14+
describe "embed" do
15+
before { visit "/catalog/10.99999/1234-donotuse-item/embed" }
16+
it "shows the no assets message" do
17+
expect(page).to have_text('The zoomable version of this image is not yet available.')
18+
end
19+
end
20+
end

spec/fixtures/foxml/donotuse_item.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
3232
<memberOf xmlns="http://purl.oclc.org/NET/CUL/" rdf:resource="info:fedora/ldpd:101479"></memberOf>
3333
<image xmlns="https://schema.org/" rdf:resource="info:fedora/cul:1c59zw3rf4"></image>
3434
<publisher xmlns="http://purl.org/dc/terms/" rdf:resource="info:fedora/donotuse:catalog"></publisher>
35+
<doi xmlns="http://purl.org/ontology/bibo/" rdf:resource="doi:10.99999/1234-donotuse-item"></doi>
3536
</rdf:Description>
3637
</rdf:RDF>
3738
</foxml:xmlContent>

0 commit comments

Comments
 (0)