blacklight 3.1.2 → 3.2.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -2
- data/README.md +7 -2
- data/VERSION +1 -1
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/blacklight/blacklight.js +23 -1
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +369 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +117 -0
- data/app/assets/stylesheets/blacklight/_folder.css.scss +38 -0
- data/app/assets/stylesheets/blacklight/_formatting.css.scss +164 -0
- data/app/assets/stylesheets/blacklight/_header.css.scss +36 -0
- data/app/assets/stylesheets/blacklight/_layout.css.scss +79 -0
- data/app/assets/stylesheets/blacklight/_print.css.scss +54 -0
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +44 -0
- data/app/assets/stylesheets/blacklight/_susy_framework.css.scss +228 -0
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +27 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +48 -0
- data/app/controllers/bookmarks_controller.rb +2 -1
- data/app/controllers/folder_controller.rb +4 -0
- data/app/controllers/saved_searches_controller.rb +4 -0
- data/app/controllers/search_history_controller.rb +4 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +64 -104
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/facets_helper_behavior.rb +52 -5
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +14 -59
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +56 -0
- data/app/helpers/search_history_constraints_helper.rb +3 -0
- data/app/models/record_mailer.rb +1 -2
- data/app/views/_flash_msg.html.erb +4 -5
- data/app/views/_user_util_links.html.erb +3 -1
- data/app/views/bookmarks/index.html.erb +2 -2
- data/app/views/catalog/_bookmark_control.html.erb +6 -6
- data/app/views/catalog/_facet_layout.html.erb +4 -0
- data/app/views/catalog/_facet_limit.html.erb +20 -33
- data/app/views/catalog/_facets.html.erb +1 -5
- data/app/views/catalog/_folder_control.html.erb +5 -5
- data/app/views/catalog/_index_default.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +4 -3
- data/app/views/catalog/_show_default.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +6 -6
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +2 -2
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +10 -0
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/folder/_tools.html.erb +4 -4
- data/app/views/layouts/blacklight.html.erb +25 -37
- data/app/views/record_mailer/email_record.text.erb +1 -1
- data/app/views/record_mailer/sms_record.text.erb +2 -2
- data/app/views/search_history/index.html.erb +1 -1
- data/blacklight.gemspec +11 -9
- data/lib/{generators/blacklight/templates/SolrMarc.jar → SolrMarc.jar} +0 -0
- data/lib/blacklight.rb +5 -3
- data/lib/blacklight/catalog.rb +3 -4
- data/lib/blacklight/configurable.rb +54 -39
- data/lib/blacklight/configuration.rb +126 -0
- data/lib/blacklight/configuration/fields.rb +142 -0
- data/lib/blacklight/configuration/search_field.rb +12 -0
- data/lib/blacklight/configuration/solr_field.rb +12 -0
- data/lib/blacklight/configuration/sort_field.rb +17 -0
- data/lib/blacklight/controller.rb +16 -14
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/global_configurable.rb +46 -0
- data/lib/blacklight/search_fields.rb +21 -54
- data/lib/blacklight/solr/document.rb +13 -3
- data/lib/blacklight/solr_helper.rb +88 -52
- data/lib/blacklight/utils.rb +18 -0
- data/lib/generators/blacklight/assets_generator.rb +14 -20
- data/lib/generators/blacklight/blacklight_generator.rb +14 -6
- data/lib/generators/blacklight/jetty_generator.rb +1 -1
- data/lib/generators/blacklight/templates/assets/standard.css.scss +51 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +148 -0
- data/lib/generators/blacklight/templates/config/blacklight_config.rb +2 -239
- data/lib/generators/blacklight/templates/config/sass.rb +5 -0
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +514 -164
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +1591 -323
- data/lib/generators/blacklight/templates/solr_document.rb +2 -0
- data/lib/railties/all_tests.rake +36 -3
- data/lib/railties/blacklight_cucumber.rake +6 -4
- data/lib/railties/blacklight_rspec.rake +5 -4
- data/test_support/bin/run-tests.sh +2 -13
- data/test_support/bin/test.sh +30 -23
- data/test_support/features/did_you_mean.feature +14 -13
- data/test_support/features/step_definitions/saved_searches_steps.rb +1 -1
- data/test_support/features/step_definitions/search_steps.rb +4 -4
- data/test_support/spec/controllers/application_controller_spec.rb +3 -13
- data/test_support/spec/controllers/catalog_controller_spec.rb +102 -24
- data/test_support/spec/controllers/folder_controller_spec.rb +7 -1
- data/test_support/spec/helpers/blacklight_helper_spec.rb +45 -34
- data/test_support/spec/helpers/facets_helper_spec.rb +68 -0
- data/test_support/spec/helpers/html_head_helper_spec.rb +37 -0
- data/test_support/spec/helpers/{render_constraints_helper_spec.rb → search_history_constraints_helper_spec.rb} +26 -7
- data/test_support/spec/lib/blacklight_configurable_spec.rb +92 -0
- data/test_support/spec/lib/blacklight_configuration_spec.rb +295 -0
- data/test_support/spec/lib/{configurable_spec.rb → global_configurable_spec.rb} +2 -2
- data/test_support/spec/lib/search_fields_spec.rb +26 -29
- data/test_support/spec/{helpers → lib}/solr_helper_spec.rb +268 -287
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
- data/test_support/spec/lib/utils_spec.rb +58 -0
- data/test_support/spec/models/solr_docment_spec.rb +4 -8
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +27 -170
- data/test_support/spec/views/catalog/_index_default.erb_spec.rb +38 -20
- data/test_support/spec/views/catalog/_show_default.erb_spec.rb +38 -19
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +19 -1
- metadata +148 -145
- data/app/assets/stylesheets/blacklight/blacklight.css +0 -493
- data/app/assets/stylesheets/yui.css +0 -31
- data/app/views/catalog/opensearch.xml.erb +0 -11
- data/doc/Atom-Responses.md +0 -90
- data/doc/CUSTOMIZING.md +0 -121
- data/doc/Extending-blacklight-with-the-document-extension-framework.md +0 -1
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -131
- data/doc/Features.md +0 -147
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Pagination.md +0 -38
- data/doc/Quickstart.md +0 -97
- data/doc/Upgrading-Guide.md +0 -98
- data/doc/User-Authentication.md +0 -54
- data/doc/Using-a-custom-solr-uniquekey-field.md +0 -36
- data/lib/blacklight/comma_link_renderer.rb +0 -28
- data/lib/railties/jetty_solr_server.rb +0 -108
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +0 -101
@@ -46,12 +46,10 @@
|
|
46
46
|
|
47
47
|
module Blacklight::SolrHelper
|
48
48
|
extend ActiveSupport::Concern
|
49
|
-
|
50
|
-
MaxPerPage = 100
|
49
|
+
include Blacklight::SearchFields
|
51
50
|
|
52
51
|
included do
|
53
52
|
if self.respond_to?(:helper_method)
|
54
|
-
helper_method(:facet_limit_hash)
|
55
53
|
helper_method(:facet_limit_for)
|
56
54
|
end
|
57
55
|
|
@@ -68,7 +66,7 @@ module Blacklight::SolrHelper
|
|
68
66
|
# CatalogController.include ModuleDefiningNewMethod
|
69
67
|
# CatalogController.solr_search_params_logic += [:new_method]
|
70
68
|
# CatalogController.solr_search_params_logic.delete(:we_dont_want)
|
71
|
-
self.solr_search_params_logic = [:default_solr_parameters , :add_query_to_solr, :add_facet_fq_to_solr, :add_facetting_to_solr, :
|
69
|
+
self.solr_search_params_logic = [:default_solr_parameters , :add_query_to_solr, :add_facet_fq_to_solr, :add_facetting_to_solr, :add_paging_to_solr, :add_sorting_to_solr ]
|
72
70
|
end
|
73
71
|
|
74
72
|
def force_to_utf8(value)
|
@@ -132,32 +130,63 @@ module Blacklight::SolrHelper
|
|
132
130
|
# Start with general defaults from BL config. Need to use custom
|
133
131
|
# merge to dup values, to avoid later mutating the original by mistake.
|
134
132
|
def default_solr_parameters(solr_parameters, user_params)
|
135
|
-
|
136
|
-
|
137
|
-
solr_parameters[key] = value.dup rescue value
|
138
|
-
end
|
133
|
+
blacklight_config.default_solr_params.each do |key, value|
|
134
|
+
solr_parameters[key] = value.dup rescue value
|
139
135
|
end
|
140
136
|
end
|
141
137
|
|
142
138
|
###
|
143
|
-
# copy paging
|
144
|
-
#
|
145
|
-
def
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
|
150
|
-
|
139
|
+
# copy paging params from BL app over to solr, changing
|
140
|
+
# app level per_page and page to Solr rows and start.
|
141
|
+
def add_paging_to_solr(solr_params, user_params)
|
142
|
+
# Deprecated behavior was to pass :per_page to RSolr, and we
|
143
|
+
# generated blacklight_config.default_solr_params with that
|
144
|
+
# value. Move it over to rows.
|
145
|
+
if solr_params.has_key?(:per_page)
|
146
|
+
$stderr.puts "DEPRECATION WARNING: Blacklight::SolrHelper#solr_search_params: magic :per_page key deprecated, use :rows instead. (Check default_solr_params in blacklight config?)"
|
147
|
+
per_page = solr_params.delete(:per_page)
|
148
|
+
solr_params[:rows] ||= per_page
|
151
149
|
end
|
152
150
|
|
153
|
-
|
154
|
-
|
155
|
-
solr_parameters[:sort] = default_sort_field.last unless default_sort_field.last.blank?
|
156
|
-
end
|
151
|
+
# Now any over-rides from current URL?
|
152
|
+
solr_params[:rows] = user_params[:per_page] unless user_params[:per_page].blank?
|
157
153
|
|
154
|
+
# Do we need to translate :page to Solr :start?
|
155
|
+
unless user_params[:page].blank?
|
156
|
+
# already set solr_params["rows"] might not be the one we just set,
|
157
|
+
# could have been from app defaults too. But we need one.
|
158
|
+
# raising is consistent with prior RSolr magic keys behavior.
|
159
|
+
# We could change this to default to 10, or to raise on startup
|
160
|
+
# from config instead of at runtime.
|
161
|
+
if solr_params[:rows].blank?
|
162
|
+
raise Exception.new("To use pagination when no :per_page is supplied in the URL, :rows must be configured in blacklight_config default_solr_params")
|
163
|
+
end
|
164
|
+
|
165
|
+
solr_params[:start] = solr_params[:rows].to_i * (user_params[:page].to_i - 1)
|
166
|
+
|
167
|
+
# Solr throws error for negative start. Existing specs say
|
168
|
+
# we say start at 1 in this case.
|
169
|
+
solr_params[:start] = 0 if solr_params[:start].to_i < 0
|
170
|
+
end
|
171
|
+
|
158
172
|
# limit to MaxPerPage (100). Tests want this to be a string not an integer,
|
159
173
|
# not sure why.
|
160
|
-
|
174
|
+
solr_params[:rows] = solr_params[:rows].to_i > blacklight_config.max_per_page ? blacklight_config.max_per_page : solr_params[:rows]
|
175
|
+
end
|
176
|
+
|
177
|
+
###
|
178
|
+
# copy sorting params from BL app over to solr
|
179
|
+
def add_sorting_to_solr(solr_parameters, user_params)
|
180
|
+
if user_params[:sort].blank? and sort_field = blacklight_config.default_sort_field
|
181
|
+
# no sort param provided, use default
|
182
|
+
solr_parameters[:sort] = sort_field.sort unless sort_field.sort.blank?
|
183
|
+
elsif sort_field = blacklight_config.sort_fields[user_params[:sort]]
|
184
|
+
# check for sort field key
|
185
|
+
solr_parameters[:sort] = sort_field.sort unless sort_field.sort.blank?
|
186
|
+
else
|
187
|
+
# just pass the key through
|
188
|
+
solr_parameters[:sort] = user_params[:sort]
|
189
|
+
end
|
161
190
|
end
|
162
191
|
|
163
192
|
##
|
@@ -175,10 +204,10 @@ module Blacklight::SolrHelper
|
|
175
204
|
# rspec'd.
|
176
205
|
solr_parameters[:qt] = user_parameters[:qt] if user_parameters[:qt]
|
177
206
|
|
178
|
-
search_field_def =
|
207
|
+
search_field_def = search_field_def_for_key(user_parameters[:search_field])
|
179
208
|
if (search_field_def)
|
180
|
-
solr_parameters[:qt] = search_field_def
|
181
|
-
solr_parameters.merge!( search_field_def
|
209
|
+
solr_parameters[:qt] = search_field_def.qt
|
210
|
+
solr_parameters.merge!( search_field_def.solr_parameters) if search_field_def.solr_parameters
|
182
211
|
end
|
183
212
|
|
184
213
|
##
|
@@ -186,7 +215,7 @@ module Blacklight::SolrHelper
|
|
186
215
|
# solr LocalParams in config, using solr LocalParams syntax.
|
187
216
|
# http://wiki.apache.org/solr/LocalParams
|
188
217
|
##
|
189
|
-
if (search_field_def && hash = search_field_def
|
218
|
+
if (search_field_def && hash = search_field_def.solr_local_parameters)
|
190
219
|
local_params = hash.collect do |key, val|
|
191
220
|
key.to_s + "=" + solr_param_quote(val, :quote => "'")
|
192
221
|
end.join(" ")
|
@@ -222,11 +251,26 @@ module Blacklight::SolrHelper
|
|
222
251
|
value_list ||= []
|
223
252
|
value_list = [value_list] unless value_list.respond_to? :each
|
224
253
|
value_list.each do |value|
|
225
|
-
solr_parameters[:fq] <<
|
254
|
+
solr_parameters[:fq] << facet_value_to_fq_string(facet_field, value)
|
226
255
|
end
|
227
256
|
end
|
228
257
|
end
|
229
258
|
end
|
259
|
+
|
260
|
+
##
|
261
|
+
# Convert a facet/value pair into a solr fq parameter
|
262
|
+
def facet_value_to_fq_string(facet_field, value)
|
263
|
+
case
|
264
|
+
when (value.is_a?(Integer) or (value.to_i.to_s == value if value.respond_to? :to_i))
|
265
|
+
"#{facet_field}:#{value}"
|
266
|
+
when (value.is_a?(Float) or (value.to_f.to_s == value if value.respond_to? :to_f))
|
267
|
+
"#{facet_field}:#{value}"
|
268
|
+
when value.is_a?(Range)
|
269
|
+
"#{facet_field}:[#{value.first} TO #{value.last}]"
|
270
|
+
else
|
271
|
+
"{!raw f=#{facet_field}}#{value}"
|
272
|
+
end
|
273
|
+
end
|
230
274
|
|
231
275
|
##
|
232
276
|
# Add appropriate Solr facetting directives in, including
|
@@ -247,8 +291,7 @@ module Blacklight::SolrHelper
|
|
247
291
|
# Support facet paging and 'more'
|
248
292
|
# links, by sending a facet.limit one more than what we
|
249
293
|
# want to page at, according to configured facet limits.
|
250
|
-
|
251
|
-
next if field_name.nil? # skip the 'default' key
|
294
|
+
blacklight_config.facet_fields.each do |field_name, facet|
|
252
295
|
next unless (limit = facet_limit_for(field_name))
|
253
296
|
|
254
297
|
solr_parameters[:"f.#{field_name}.facet.limit"] = (limit + 1)
|
@@ -268,7 +311,7 @@ module Blacklight::SolrHelper
|
|
268
311
|
# In later versions of Rails, the #benchmark method can do timing
|
269
312
|
# better for us.
|
270
313
|
bench_start = Time.now
|
271
|
-
|
314
|
+
|
272
315
|
solr_response = find(self.solr_search_params(user_params).merge(extra_controller_params))
|
273
316
|
document_list = solr_response.docs.collect {|doc| SolrDocument.new(doc, solr_response)}
|
274
317
|
Rails.logger.debug("Solr fetch: #{self.class}#get_search_results (#{'%.1f' % ((Time.now.to_f - bench_start.to_f)*1000)}ms)")
|
@@ -301,10 +344,17 @@ module Blacklight::SolrHelper
|
|
301
344
|
def get_solr_response_for_field_values(field, values, extra_solr_params = {})
|
302
345
|
values ||= []
|
303
346
|
values = [values] unless values.respond_to? :each
|
304
|
-
|
347
|
+
|
348
|
+
q = nil
|
349
|
+
if values.empty?
|
350
|
+
q = "NOT *:*"
|
351
|
+
else
|
352
|
+
q = "#{field}:(#{ values.to_a.map { |x| solr_param_quote(x)}.join(" OR ")})"
|
353
|
+
end
|
354
|
+
|
305
355
|
solr_params = {
|
306
356
|
:defType => "lucene", # need boolean for OR
|
307
|
-
:q =>
|
357
|
+
:q => q,
|
308
358
|
# not sure why fl * is neccesary, why isn't default solr_search_params
|
309
359
|
# sufficient, like it is for any other search results solr request?
|
310
360
|
# But tests fail without this. I think because some functionality requires
|
@@ -391,10 +441,8 @@ module Blacklight::SolrHelper
|
|
391
441
|
# the Blacklight app-level request params that define the search.
|
392
442
|
def get_single_doc_via_search(index, request_params)
|
393
443
|
solr_params = solr_search_params(request_params)
|
394
|
-
|
395
|
-
#
|
396
|
-
solr_params[:page] = index # start at 1 to get 1st 1-doc page with RSolr::Ext :page
|
397
|
-
solr_params[:per_page] = 1
|
444
|
+
|
445
|
+
solr_params[:start] = (index - 1) # start at 0 to get 1st doc, 1 to get 2nd.
|
398
446
|
solr_params[:rows] = 1
|
399
447
|
solr_params[:fl] = '*'
|
400
448
|
solr_response = find(solr_params)
|
@@ -402,13 +450,13 @@ module Blacklight::SolrHelper
|
|
402
450
|
end
|
403
451
|
|
404
452
|
# returns a solr params hash
|
405
|
-
# if field is nil, the value is fetched from
|
453
|
+
# if field is nil, the value is fetched from blacklight_config[:index][:show_link]
|
406
454
|
# the :fl (solr param) is set to the "field" value.
|
407
455
|
# per_page is set to 10
|
408
456
|
def solr_opensearch_params(field=nil)
|
409
457
|
solr_params = solr_search_params
|
410
458
|
solr_params[:per_page] = 10
|
411
|
-
solr_params[:fl] =
|
459
|
+
solr_params[:fl] = blacklight_config.index.show_link
|
412
460
|
solr_params
|
413
461
|
end
|
414
462
|
|
@@ -434,10 +482,10 @@ module Blacklight::SolrHelper
|
|
434
482
|
# available), and used in display (with @response available) to create
|
435
483
|
# a facet paginator with the right limit.
|
436
484
|
def facet_limit_for(facet_field)
|
437
|
-
|
438
|
-
return nil if
|
485
|
+
facet = blacklight_config.facet_fields[facet_field]
|
486
|
+
return nil if facet.blank?
|
439
487
|
|
440
|
-
limit =
|
488
|
+
limit = facet.limit
|
441
489
|
|
442
490
|
if ( limit == true && @response &&
|
443
491
|
@response["responseHeader"] &&
|
@@ -454,16 +502,4 @@ module Blacklight::SolrHelper
|
|
454
502
|
return limit
|
455
503
|
end
|
456
504
|
|
457
|
-
# Returns complete hash of key=facet_field, value=limit.
|
458
|
-
# Used by SolrHelper#solr_search_params to add limits to solr
|
459
|
-
# request for all configured facet limits.
|
460
|
-
def facet_limit_hash
|
461
|
-
Blacklight.config[:facet][:limits] || {}
|
462
|
-
end
|
463
|
-
|
464
|
-
def max_per_page
|
465
|
-
MaxPerPage
|
466
|
-
end
|
467
|
-
|
468
|
-
|
469
505
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module Blacklight
|
3
|
+
class OpenStructWithHashAccess < OpenStruct
|
4
|
+
delegate :keys, :merge, :to => :to_h
|
5
|
+
|
6
|
+
def []=(key, value)
|
7
|
+
send "#{key}=", value
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](key)
|
11
|
+
send key
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_h
|
15
|
+
@table
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -17,37 +17,31 @@ module Blacklight
|
|
17
17
|
source_root File.expand_path('../templates', __FILE__)
|
18
18
|
|
19
19
|
def assets
|
20
|
-
|
20
|
+
unless IO.read("app/assets/stylesheets/application.css").include?("Blacklight")
|
21
|
+
copy_file('assets/standard.css.scss', 'app/assets/stylesheets/blacklight_themes/standard.css.scss')
|
21
22
|
insert_into_file "app/assets/stylesheets/application.css", :after => "/*" do
|
22
|
-
%q{
|
23
|
-
*
|
24
|
-
* Required by Blacklight
|
25
|
-
*= require 'yui'
|
23
|
+
%q{
|
24
|
+
* Required by Blacklight:
|
26
25
|
*= require 'jquery/ui-lightness/jquery-ui-1.8.1.custom.css'
|
26
|
+
* This is the standard blacklight theme.
|
27
27
|
*= require 'blacklight/blacklight'
|
28
|
-
|
28
|
+
*
|
29
|
+
* If you'd like to modify the default theme, please instead require 'blacklight_themes/standard', which
|
30
|
+
* is in your local install at app/assets/stylesheets/blacklight_themes/ }
|
29
31
|
end
|
32
|
+
end
|
30
33
|
|
34
|
+
unless IO.read("app/assets/javascripts/application.js").include?('blacklight/blacklight')
|
31
35
|
insert_into_file "app/assets/javascripts/application.js", :after => "//= require jquery_ujs" do
|
32
|
-
%q{
|
36
|
+
%q{
|
37
|
+
//
|
33
38
|
// Required by Blacklight
|
34
39
|
//= require jquery-ui
|
35
|
-
//= require blacklight/blacklight
|
36
|
-
}
|
40
|
+
//= require blacklight/blacklight}
|
37
41
|
end
|
38
|
-
directory("../../../../app/assets/images/blacklight", "public/images/blacklight")
|
39
|
-
else
|
40
|
-
# directories are relative to the source_root
|
41
|
-
directory("../../../../app/assets/images/blacklight", "public/images/blacklight")
|
42
|
-
directory("../../../../app/assets/stylesheets", "public/stylesheets")
|
43
|
-
directory("../../../../app/assets/javascripts", "public/javascripts")
|
44
42
|
end
|
45
|
-
end
|
46
43
|
|
47
|
-
|
48
|
-
def use_asset_pipeline?
|
49
|
-
(Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR >= 1) and Rails.application.config.assets.enabled
|
44
|
+
directory("../../../../app/assets/images/blacklight", "app/assets/images/blacklight")
|
50
45
|
end
|
51
|
-
|
52
46
|
end
|
53
47
|
end
|
@@ -110,10 +110,6 @@ EOF
|
|
110
110
|
better_migration_template "add_user_types_to_bookmarks_searches.rb"
|
111
111
|
end
|
112
112
|
|
113
|
-
# Copy ocver the solr_marc.jar file
|
114
|
-
def copy_solr_marc
|
115
|
-
copy_file "SolrMarc.jar", "lib/SolrMarc.jar"
|
116
|
-
end
|
117
113
|
|
118
114
|
# Add Blacklight to the user model
|
119
115
|
def inject_blacklight_user_behavior
|
@@ -124,7 +120,7 @@ EOF
|
|
124
120
|
"\n include Blacklight::User\n"
|
125
121
|
end
|
126
122
|
else
|
127
|
-
|
123
|
+
say_status("warning", "Blacklight authenticated user functionality not installed, as a user model could not be found at /app/models/user.rb. If you used a different name, please re-run the migration and provide that name as an argument. Such as `rails -g blacklight client`", :yellow)
|
128
124
|
end
|
129
125
|
end
|
130
126
|
|
@@ -150,6 +146,19 @@ EOF
|
|
150
146
|
route('Blacklight.add_routes(self)')
|
151
147
|
end
|
152
148
|
|
149
|
+
def add_sass_configuration
|
150
|
+
insert_into_file "config/application.rb", :after => "config.assets.enabled = true" do <<EOF
|
151
|
+
|
152
|
+
# Default SASS Configuration, check out https://github.com/rails/sass-rails for details
|
153
|
+
config.assets.compress = !Rails.env.development?
|
154
|
+
config.sass.line_comments = Rails.env.development?
|
155
|
+
|
156
|
+
EOF
|
157
|
+
end
|
158
|
+
|
159
|
+
copy_file "config/sass.rb", "config/initializers/sass.rb"
|
160
|
+
end
|
161
|
+
|
153
162
|
private
|
154
163
|
|
155
164
|
def better_migration_template (file)
|
@@ -160,6 +169,5 @@ EOF
|
|
160
169
|
puts " \e[1m\e[34mMigrations\e[0m " + $!.message
|
161
170
|
end
|
162
171
|
end
|
163
|
-
|
164
172
|
end
|
165
173
|
|
@@ -11,7 +11,7 @@ module Blacklight
|
|
11
11
|
# change this to a different download if you want to peg to a different
|
12
12
|
# tagged version of our known-good jetty/solr.
|
13
13
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE # (Required by jruby)
|
14
|
-
class_option :download_url, :aliases => "-u", :type=>"string", :default =>"https://github.com/projectblacklight/blacklight-jetty/zipball/
|
14
|
+
class_option :download_url, :aliases => "-u", :type=>"string", :default =>"https://github.com/projectblacklight/blacklight-jetty/zipball/v3.5.0" , :desc=>"location of zip file including a jetty with solr setup for blacklight."
|
15
15
|
class_option :downloaded_package, :aliases => "-d", :type=>"string", :desc => "manual download of BL-jetty zip file"
|
16
16
|
|
17
17
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
/* Grid parameters */
|
3
|
+
/* changing total cols is not recommended unless you're going to redo blacklight/_layout.css.sass */
|
4
|
+
$total-cols: 24;
|
5
|
+
|
6
|
+
/* But the widths are changeable to px, em. */
|
7
|
+
$col-width: 2.5em;
|
8
|
+
$gutter-width: .5em;
|
9
|
+
$side-gutter-width: 2em;
|
10
|
+
|
11
|
+
|
12
|
+
$logo_url: 'blacklight/logo.png';
|
13
|
+
|
14
|
+
/* Various elements of search customization share these colors */
|
15
|
+
|
16
|
+
$search_ui_border_color: #AAAAAA;
|
17
|
+
$search_ui_bg_color: #F0F0F0;
|
18
|
+
|
19
|
+
/* separates documents, facets */
|
20
|
+
$dotted_border_color: #CCC;
|
21
|
+
|
22
|
+
/* background color of page */
|
23
|
+
$page_bg_color: #2E4F81;
|
24
|
+
|
25
|
+
|
26
|
+
/* label (field names) */
|
27
|
+
$field_name_color: #888;
|
28
|
+
|
29
|
+
|
30
|
+
/* constraint (you searched for:) details: */
|
31
|
+
|
32
|
+
$constraint_bg_color: #E2EDFE;
|
33
|
+
|
34
|
+
$constraint_border_color: #C4DAFE;
|
35
|
+
$constraint_border_active_color: #FFD27A;
|
36
|
+
|
37
|
+
/* dialog that pops up when you pick more on facets */
|
38
|
+
$facet_extended_button_bg_color: #F6F6F6;
|
39
|
+
$facet_extended_button_border_color: #CCC;
|
40
|
+
$facet_extended_disabled_button_bg_color: #E2EDFE;
|
41
|
+
$facet_extended_disabled_border_color: #C4DAFE;
|
42
|
+
$facet_extended_button_hover_bg_color: #DADADA;
|
43
|
+
$facet_extended_button_hover_border_color: #999;
|
44
|
+
$facet_extended_button_hover_color: #212121;
|
45
|
+
|
46
|
+
/* border between items on marc view */
|
47
|
+
$marc_item_separator: 1px solid #CCC;
|
48
|
+
|
49
|
+
/* uses these variables in the blacklight stylesheet */
|
50
|
+
@import 'blacklight/blacklight';
|
51
|
+
|
@@ -5,4 +5,152 @@ class CatalogController < ApplicationController
|
|
5
5
|
|
6
6
|
include Blacklight::Catalog
|
7
7
|
|
8
|
+
configure_blacklight do |config|
|
9
|
+
config.default_solr_params = {
|
10
|
+
:qt => 'search',
|
11
|
+
:rows => 10
|
12
|
+
}
|
13
|
+
|
14
|
+
# solr field configuration for search results/index views
|
15
|
+
config.index.show_link = 'title_display'
|
16
|
+
config.index.record_display_type = 'format'
|
17
|
+
|
18
|
+
# solr field configuration for document/show views
|
19
|
+
config.show.html_title = 'title_display'
|
20
|
+
config.show.heading = 'title_display'
|
21
|
+
config.show.display_type = 'format'
|
22
|
+
|
23
|
+
# solr fields that will be treated as facets by the blacklight application
|
24
|
+
# The ordering of the field names is the order of the display
|
25
|
+
#
|
26
|
+
# Setting a limit will trigger Blacklight's 'more' facet values link.
|
27
|
+
# * If left unset, then all facet values returned by solr will be displayed.
|
28
|
+
# * If set to an integer, then "f.somefield.facet.limit" will be added to
|
29
|
+
# solr request, with actual solr request being +1 your configured limit --
|
30
|
+
# you configure the number of items you actually want _displayed_ in a page.
|
31
|
+
# * If set to 'true', then no additional parameters will be sent to solr,
|
32
|
+
# but any 'sniffed' request limit parameters will be used for paging, with
|
33
|
+
# paging at requested limit -1. Can sniff from facet.limit or
|
34
|
+
# f.specific_field.facet.limit solr request params. This 'true' config
|
35
|
+
# can be used if you set limits in :default_solr_params, or as defaults
|
36
|
+
# on the solr side in the request handler itself. Request handler defaults
|
37
|
+
# sniffing requires solr requests to be made with "echoParams=all", for
|
38
|
+
# app code to actually have it echo'd back to see it.
|
39
|
+
config.add_facet_field 'format', :label => 'Format'
|
40
|
+
config.add_facet_field 'pub_date', :label => 'Publication Year'
|
41
|
+
config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
|
42
|
+
config.add_facet_field 'language_facet', :label => 'Language', :limit => true
|
43
|
+
config.add_facet_field 'lc_1letter_facet', :label => 'Call Number'
|
44
|
+
config.add_facet_field 'subject_geo_facet', :label => 'Region'
|
45
|
+
config.add_facet_field 'subject_era_facet', :label => 'Era'
|
46
|
+
|
47
|
+
# Have BL send all facet field names to Solr, which has been the default
|
48
|
+
# previously. Simply remove these lines if you'd rather use Solr request
|
49
|
+
# handler defaults, or have no facets.
|
50
|
+
config.default_solr_params[:'facet.field'] = config.facet_fields.keys
|
51
|
+
|
52
|
+
# solr fields to be displayed in the index (search results) view
|
53
|
+
# The ordering of the field names is the order of the display
|
54
|
+
config.add_index_field 'title_display', :label => 'Title:'
|
55
|
+
config.add_index_field 'title_vern_display', :label => 'Title:'
|
56
|
+
config.add_index_field 'author_display', :label => 'Author:'
|
57
|
+
config.add_index_field 'author_vern_display', :label => 'Author:'
|
58
|
+
config.add_index_field 'format', :label => 'Format:'
|
59
|
+
config.add_index_field 'language_facet', :label => 'Language:'
|
60
|
+
config.add_index_field 'published_display', :label => 'Published:'
|
61
|
+
config.add_index_field 'published_vern_display', :label => 'Published:'
|
62
|
+
config.add_index_field 'lc_callnum_display', :label => 'Call number:'
|
63
|
+
|
64
|
+
# solr fields to be displayed in the show (single result) view
|
65
|
+
# The ordering of the field names is the order of the display
|
66
|
+
config.add_show_field 'title_display', :label => 'Title:'
|
67
|
+
config.add_show_field 'title_vern_display', :label => 'Title:'
|
68
|
+
config.add_show_field 'subtitle_display', :label => 'Subtitle:'
|
69
|
+
config.add_show_field 'subtitle_vern_display', :label => 'Subtitle:'
|
70
|
+
config.add_show_field 'author_display', :label => 'Author:'
|
71
|
+
config.add_show_field 'author_vern_display', :label => 'Author:'
|
72
|
+
config.add_show_field 'format', :label => 'Format:'
|
73
|
+
config.add_show_field 'url_fulltext_display', :label => 'URL:'
|
74
|
+
config.add_show_field 'url_suppl_display', :label => 'More Information:'
|
75
|
+
config.add_show_field 'language_facet', :label => 'Language:'
|
76
|
+
config.add_show_field 'published_display', :label => 'Published:'
|
77
|
+
config.add_show_field 'published_vern_display', :label => 'Published:'
|
78
|
+
config.add_show_field 'lc_callnum_display', :label => 'Call number:'
|
79
|
+
config.add_show_field 'isbn_t', :label => 'ISBN:'
|
80
|
+
|
81
|
+
# "fielded" search configuration. Used by pulldown among other places.
|
82
|
+
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
83
|
+
#
|
84
|
+
# Search fields will inherit the :qt solr request handler from
|
85
|
+
# config[:default_solr_parameters], OR can specify a different one
|
86
|
+
# with a :qt key/value. Below examples inherit, except for subject
|
87
|
+
# that specifies the same :qt as default for our own internal
|
88
|
+
# testing purposes.
|
89
|
+
#
|
90
|
+
# The :key is what will be used to identify this BL search field internally,
|
91
|
+
# as well as in URLs -- so changing it after deployment may break bookmarked
|
92
|
+
# urls. A display label will be automatically calculated from the :key,
|
93
|
+
# or can be specified manually to be different.
|
94
|
+
|
95
|
+
# This one uses all the defaults set by the solr request handler. Which
|
96
|
+
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
97
|
+
# since we aren't specifying it otherwise.
|
98
|
+
|
99
|
+
config.add_search_field 'all_fields', :label => 'All Fields'
|
100
|
+
|
101
|
+
|
102
|
+
# Now we see how to over-ride Solr request handler defaults, in this
|
103
|
+
# case for a BL "search field", which is really a dismax aggregate
|
104
|
+
# of Solr search fields.
|
105
|
+
|
106
|
+
config.add_search_field('title') do |field|
|
107
|
+
# solr_parameters hash are sent to Solr as ordinary url query params.
|
108
|
+
field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
|
109
|
+
|
110
|
+
# :solr_local_parameters will be sent using Solr LocalParams
|
111
|
+
# syntax, as eg {! qf=$title_qf }. This is neccesary to use
|
112
|
+
# Solr parameter de-referencing like $title_qf.
|
113
|
+
# See: http://wiki.apache.org/solr/LocalParams
|
114
|
+
field.solr_local_parameters = {
|
115
|
+
:qf => '$title_qf',
|
116
|
+
:pf => '$title_pf'
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
config.add_search_field('author') do |field|
|
121
|
+
field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
|
122
|
+
field.solr_local_parameters = {
|
123
|
+
:qf => '$author_qf',
|
124
|
+
:pf => '$author_pf'
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
# Specifying a :qt only to show it's possible, and so our internal automated
|
129
|
+
# tests can test it. In this case it's the same as
|
130
|
+
# config[:default_solr_parameters][:qt], so isn't actually neccesary.
|
131
|
+
config.add_search_field('subject') do |field|
|
132
|
+
field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
|
133
|
+
field.qt = 'search'
|
134
|
+
field.solr_local_parameters = {
|
135
|
+
:qf => '$subject_qf',
|
136
|
+
:pf => '$subject_pf'
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
# "sort results by" select (pulldown)
|
141
|
+
# label in pulldown is followed by the name of the SOLR field to sort by and
|
142
|
+
# whether the sort is ascending or descending (it must be asc or desc
|
143
|
+
# except in the relevancy case).
|
144
|
+
config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
|
145
|
+
config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
|
146
|
+
config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
|
147
|
+
config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
|
148
|
+
|
149
|
+
# If there are more than this many search results, no spelling ("did you
|
150
|
+
# mean") suggestion is offered.
|
151
|
+
config.spell_max = 5
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
|
8
156
|
end
|