Skip to content

Commit

Permalink
DetailsController#embed should use catalog layouts (DLC-1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Oct 23, 2024
1 parent a770a1c commit a20595c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 115 deletions.
126 changes: 11 additions & 115 deletions app/controllers/details_controller.rb
Original file line number Diff line number Diff line change
@@ -1,127 +1,23 @@
class DetailsController < ApplicationController
class DetailsController < SubsitesController
include Dcv::CatalogIncludes
include Dcv::Sites::SearchableController
extend Dcv::Configurators::BaseBlacklightConfigurator
include Dcv::Sites::ConfiguredLayouts
include Dcv::Catalog::CatalogLayout

layout 'details'

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

configure_blacklight do |config|
config.default_solr_params = {
:qt => 'search',
:rows => 20
}
config.search_state_fields.concat(DETAILS_PARAMS)
config.per_page = [20,60,100]
# solr field configuration for search results/index views
default_index_configuration(config)
default_show_configuration(config)

# solr fields that will be treated as facets by the blacklight application
# The ordering of the field names is the order of the display
#
# Setting a limit will trigger Blacklight's 'more' facet values link.
# * If left unset, then all facet values returned by solr will be displayed.
# * If set to an integer, then "f.somefield.facet.limit" will be added to
# solr request, with actual solr request being +1 your configured limit --
# you configure the number of items you actually want _tsimed_ in a page.
# * If set to 'true', then no additional parameters will be sent to solr,
# but any 'sniffed' request limit parameters will be used for paging, with
# paging at requested limit -1. Can sniff from facet.limit or
# f.specific_field.facet.limit solr request params. This 'true' config
# can be used if you set limits in :default_solr_params, or as defaults
# on the solr side in the request handler itself. Request handler defaults
# sniffing requires solr requests to be made with "echoParams=all", for
# app code to actually have it echo'd back to see it.
#
# :show may be set to false if you don't want the facet to be drawn in the
# facet bar

config.add_facet_fields_to_solr_request! # Required for facet queries

config.add_facet_field 'lib_project_sim', :label => 'Project'
config.add_facet_field 'lib_collection_sim', :label => 'Collection'
config.add_facet_field 'lib_repo_short_ssim', :label => 'Library Location'
config.add_facet_field 'lib_name_sim', :label => 'Name'
config.add_facet_field 'lib_format_sim', :label => 'Format'
#todo: date
#todo: language
config.add_facet_field 'format_ssi', :label => 'System Format'

config.add_facet_field 'lc1_letter_sim', :label => 'Call Number'

# Have BL send all facet field names to Solr, which has been the default
# previously. Simply remove these lines if you'd rather use Solr request
# handler defaults, or have no facets.
config.default_solr_params['facet.field'] = config.facet_fields.map { |key, config| config.field || config.key }
#use this instead if you don't want to query facets marked :show=>false
#config.default_solr_params['facet.field'] = config.facet_fields.select{ |k, v| v[:show] != false}.keys


# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'title_display_ssm', :label => 'Title'
config.add_index_field 'lib_collection_ssm', :label => 'Collection'

# solr fields to be displayed in the show (single result) view
# The ordering of the field names is the order of the display
config.add_show_field 'title_display_ssm', :label => 'Title'
config.add_show_field 'identifier_ssim', :label => 'Identifier'
config.add_show_field 'lib_format_ssm', :label => 'Format'
config.add_show_field 'lib_name_ssm', :label => 'Name'
config.add_show_field 'lib_collection_ssm', :label=>"Collection"

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

# All Text search configuration, used by main search pulldown.
config.add_search_field 'all_text_teim' do |field|
field.label = 'All Fields'
field.default = true
field.solr_parameters = {
:qf => ['all_text_teim'],
:pf => ['all_text_teim']
config.search_state_fields.concat(Dcv::Configurators::BaseBlacklightConfigurator::Constants::DETAILS_PARAMS)
Dcv::Configurators::DcvBlacklightConfigurator.configure(config)
# Include this target's content in search results, and any additional publish targets specified in subsites.yml
configure_blacklight_scope_constraints(config, true)
config.add_facet_field 'content_availability', label: 'Limit by Availability', show: false,
query: {
onsite: { label: 'Reading Room', fq: "{!join from=cul_member_of_ssim to=fedora_pid_uri_ssi}!access_control_levels_ssim:Public*" },
public: { label: 'Public', fq: "{!join from=cul_member_of_ssim to=fedora_pid_uri_ssi}access_control_levels_ssim:Public*" },
}
end

config.add_search_field 'search_title_info_search_title_teim' do |field|
field.label = 'Title'
field.solr_parameters = {
:qf => ['search_title_info_search_title_teim'],
:pf => ['search_title_info_search_title_teim']
}
end

config.add_search_field 'lib_name_teim' do |field|
field.label = 'Name'
field.solr_parameters = {
:qf => ['lib_name_teim'],
:pf => ['lib_name_teim']
}
end

# "sort results by" select (pulldown)
# label in pulldown is followed by the name of the SOLR field to sort by and
# whether the sort is ascending or descending (it must be asc or desc
# except in the relevancy case).
config.add_sort_field 'score desc, title_si asc, lib_date_dtsi desc', :label => 'relevance'
config.add_sort_field 'title_si asc, lib_date_dtsi desc', :label => 'title'

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

def show
Expand Down
20 changes: 20 additions & 0 deletions spec/features/details_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'rails_helper'

describe DetailsController, type: :feature do
# the relevant fixtures are loaded into the repository and seeded into the Site
# database tables by CI tasks
include_context "site fixtures for features"

describe "details" do
before { visit "/catalog/donotuse:item/details" }
it "shows the item title" do
expect(page).to have_text('William Burroughs')
end
end
describe "embed" do
before { visit "/catalog/10.99999/1234-donotuse-item/embed" }
it "shows the no assets message" do
expect(page).to have_text('The zoomable version of this image is not yet available.')
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/foxml/donotuse_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
<memberOf xmlns="http://purl.oclc.org/NET/CUL/" rdf:resource="info:fedora/ldpd:101479"></memberOf>
<image xmlns="https://schema.org/" rdf:resource="info:fedora/cul:1c59zw3rf4"></image>
<publisher xmlns="http://purl.org/dc/terms/" rdf:resource="info:fedora/donotuse:catalog"></publisher>
<doi xmlns="http://purl.org/ontology/bibo/" rdf:resource="doi:10.99999/1234-donotuse-item"></doi>
</rdf:Description>
</rdf:RDF>
</foxml:xmlContent>
Expand Down

0 comments on commit a20595c

Please sign in to comment.