Skip to content

Commit

Permalink
v5.1.3 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Carrick Rogers committed Aug 8, 2016
2 parents 76de5b8 + 68f25e8 commit c48e9b8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 44 deletions.
68 changes: 34 additions & 34 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# Copyright 2011-2015, The Trustees of Indiana University and Northwestern
# University. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
#
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# --- END LICENSE_HEADER BLOCK ---

# -*- encoding : utf-8 -*-
require 'blacklight/catalog'

class CatalogController < ApplicationController
class CatalogController < ApplicationController
include Blacklight::Catalog
# Extend Blacklight::Catalog with Hydra behaviors (primarily editing).
include Hydra::Controller::ControllerBehavior
include Hydra::MultiplePolicyAwareAccessControlsEnforcement

before_filter :save_sticky_settings

#Override taken from Hydra::Controller::ControllerBehavior and reapplied here to be in scope
def search_builder processor_chain = search_params_logic
super.tap { |builder| builder.current_ability = current_ability }
end
end

CatalogController.search_params_logic += [:add_access_controls_to_solr_params_if_not_admin, :only_wanted_models, :only_published_items, :limit_to_non_hidden_items, :apply_sticky_settings]

configure_blacklight do |config|
config.search_builder_class = SearchBuilder
config.http_method = :post
config.default_solr_params = {
config.default_solr_params = {
:qt => 'search',
:rows => 10
}
Expand All @@ -54,19 +54,19 @@ def search_builder processor_chain = search_params_logic
# * 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 _displayed_ in a page.
# you configure the number of items you actually want _displayed_ 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
# 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.
# 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
# :show may be set to false if you don't want the facet to be drawn in the
# facet bar
config.add_facet_field 'format_sim', label: 'Format', limit: 5, collapse: false
config.add_facet_field 'avalon_resource_type_sim', label: 'Format', limit: 5, collapse: false
# Eventually these need to be merged into a single facet
config.add_facet_field 'creator_ssim', label: 'Main contributor', limit: 5
config.add_facet_field 'date_sim', label: 'Date', limit: 5
Expand All @@ -89,16 +89,16 @@ def search_builder processor_chain = search_params_logic
config.add_facet_fields_to_solr_request!

# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
# The ordering of the field names is the order of the display
config.add_index_field 'date_ssi', label: 'Date', helper_method: :combined_display_date
config.add_index_field 'creator_ssim', label: 'Main contributors', helper_method: :contributor_index_display
config.add_index_field 'creator_ssim', label: 'Main contributors', helper_method: :contributor_index_display
config.add_index_field 'summary_ssi', label: 'Summary', helper_method: :description_index_display

# 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_tesi', label: 'Title'
config.add_show_field 'format_sim', label: 'Format'
config.add_show_field 'creator_sim', label: 'Creator'
# The ordering of the field names is the order of the display
config.add_show_field 'title_tesi', label: 'Title'
config.add_show_field 'format_sim', label: 'Format'
config.add_show_field 'creator_sim', label: 'Creator'
config.add_show_field 'language_sim', label: 'Language'
config.add_show_field 'date_ssi', label: 'Date'
config.add_show_field 'abstract_sim', label: 'Abstract'
Expand All @@ -122,45 +122,45 @@ def search_builder processor_chain = search_params_logic
# 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.
# or can be specified manually to be different.

# This one uses all the defaults set by the solr request handler. Which
# solr request handler? The one set in config[:default_solr_parameters][:qt],
# since we aren't specifying it otherwise.
# since we aren't specifying it otherwise.
config.add_search_field 'all_fields', label: 'All Fields'

# Now we see how to over-ride Solr request handler defaults, in this
# case for a BL "search field", which is really a dismax aggregate
# of Solr search fields.
# of Solr search fields.
config.add_search_field('title') do |field|
# solr_parameters hash are sent to Solr as ordinary url query params.
# solr_parameters hash are sent to Solr as ordinary url query params.
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }

# :solr_local_parameters will be sent using Solr LocalParams
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
# Solr parameter de-referencing like $title_qf.
# See: http://wiki.apache.org/solr/LocalParams
field.solr_local_parameters = {
field.solr_local_parameters = {
:qf => '$title_qf',
:pf => '$title_pf'
}
end

config.add_search_field('creator') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'creator' }
field.solr_local_parameters = {
field.solr_local_parameters = {
:qf => '$creator_qf',
:pf => '$creator_pf'
}
end

# Specifying a :qt only to show it's possible, and so our internal automated
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
# tests can test it. In this case it's the same as
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
config.add_search_field('subject') do |field|
field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
field.qt = 'search'
field.solr_local_parameters = {
field.solr_local_parameters = {
:qf => '$subject_qf',
:pf => '$subject_pf'
}
Expand All @@ -175,15 +175,15 @@ def search_builder processor_chain = search_params_logic
config.add_sort_field 'creator_ssort asc, title_ssort asc', label: 'Main contributor'
config.add_sort_field 'title_ssort asc, date_ssi desc', label: 'Title'

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

def can_embed?
params[:action] == 'index'
end

def save_sticky_settings
session[:sort] = params[:sort] if params[:sort].present?
session[:per_page] = params[:per_page] if params[:per_page].present?
Expand All @@ -194,4 +194,4 @@ def apply_sticky_settings(solr_parameters, user_parameters)
solr_parameters[:sort] = session[:sort] if session[:sort].present?
end

end
end
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def share_link_for(obj)
def image_for(document)
master_file_id = document["section_pid_tesim"].try :first

video_count = document["avalon_resource_type_tesim"].count{|m| m.start_with?('moving image') } rescue 0
audio_count = document["avalon_resource_type_tesim"].count{|m| m.start_with?('sound recording') } rescue 0
video_count = document["avalon_resource_type_sim"].count{|m| m.start_with?('moving image') } rescue 0
audio_count = document["avalon_resource_type_sim"].count{|m| m.start_with?('sound recording') } rescue 0

if master_file_id
if video_count > 0
Expand Down
3 changes: 2 additions & 1 deletion app/models/media_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def to_solr(solr_doc = Hash.new, opts = {})
solr_doc["creator_ssort"] = Array(self.creator).join(', ')
solr_doc["date_digitized_sim"] = parts.collect {|mf| mf.date_digitized }.compact.map {|t| Time.parse(t).strftime "%F" }
solr_doc["date_ingested_sim"] = Time.parse(self.create_date).strftime "%F"
solr_doc["avalon_resource_type_sim"] = self.avalon_resource_type.map(&:titleize)
#include identifiers for parts
solr_doc["other_identifier_sim"] += parts.collect {|mf| mf.DC.identifier }.flatten
#include labels for parts and their structural metadata
Expand Down Expand Up @@ -494,7 +495,7 @@ def access_control_bulk documents, params
# Limited access stuff
["group", "class", "user", "ipaddress"].each do |title|
if params["submit_add_#{title}"].present?
begin_time = params["add_#{title}_begin"].blank? ? nil : params["add_#{title}_begin"]
begin_time = params["add_#{title}_begin"].blank? ? nil : params["add_#{title}_begin"]
end_time = params["add_#{title}_end"].blank? ? nil : params["add_#{title}_end"]
create_lease = begin_time.present? || end_time.present?

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

module Avalon
VERSION = '5.1.2'
VERSION = '5.1.3'
class MissingUserId < Exception; end

class Application < Rails::Application
Expand Down
12 changes: 6 additions & 6 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,27 @@
describe "#image_for" do
# image_for expects hash keys as labels, not strings
it "should return nil" do
doc = {"avalon_resource_type_tesim" => [] }
doc = {"avalon_resource_type_sim" => [] }
expect(helper.image_for(doc)).to eq(nil)
end
it "should return audio icon" do
doc = {"avalon_resource_type_tesim" => ['sound recording 2', 'sound recording 1'] }
doc = {"avalon_resource_type_sim" => ['sound recording 2', 'sound recording 1'] }
expect(helper.image_for(doc)).to eq('/assets/audio_icon.png')
end
it "should return video icon" do
doc = {"avalon_resource_type_tesim" => ['moving image 1'] }
doc = {"avalon_resource_type_sim" => ['moving image 1'] }
expect(helper.image_for(doc)).to eq('/assets/video_icon.png')
end
it "should return hybrid icon" do
doc = {"avalon_resource_type_tesim" => ['moving image 1', 'sound recording 1'] }
doc = {"avalon_resource_type_sim" => ['moving image 1', 'sound recording 1'] }
expect(helper.image_for(doc)).to eq('/assets/hybrid_icon.png')
end
it "should return nil when only unprocessed video" do
doc = {"section_pid_tesim" => ['1'], "avalon_resource_type_tesim" => [] }
doc = {"section_pid_tesim" => ['1'], "avalon_resource_type_sim" => [] }
expect(helper.image_for(doc)).to eq(nil)
end
it "should return thumbnail" do
doc = {"section_pid_tesim" => ['1'], "avalon_resource_type_tesim" => ['moving image 1'] }
doc = {"section_pid_tesim" => ['1'], "avalon_resource_type_sim" => ['moving image 1'] }
expect(helper.image_for(doc)).to eq('/master_files/1/thumbnail')
end
end
Expand Down

0 comments on commit c48e9b8

Please sign in to comment.