blacklight 6.0.2 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -6
- data/.rubocop_todo.yml +448 -87
- data/.travis.yml +1 -1
- data/VERSION +1 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +8 -8
- data/app/controllers/concerns/blacklight/catalog.rb +5 -5
- data/app/controllers/concerns/blacklight/controller.rb +5 -5
- data/app/controllers/concerns/blacklight/saved_searches.rb +4 -2
- data/app/controllers/concerns/blacklight/search_context.rb +3 -0
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/catalog_helper_behavior.rb +20 -9
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +18 -8
- data/app/helpers/blacklight/render_partials_helper.rb +15 -3
- data/app/models/concerns/blacklight/configurable.rb +4 -8
- data/app/models/concerns/blacklight/document.rb +3 -3
- data/app/models/concerns/blacklight/document/dublin_core.rb +1 -1
- data/app/models/concerns/blacklight/document/extensions.rb +1 -1
- data/app/models/concerns/blacklight/user.rb +1 -1
- data/app/models/record_mailer.rb +6 -1
- data/app/models/search.rb +2 -2
- data/blacklight.gemspec +5 -2
- data/config/locales/blacklight.de.yml +1 -0
- data/config/locales/blacklight.en.yml +1 -0
- data/config/locales/blacklight.es.yml +1 -0
- data/config/locales/blacklight.fr.yml +1 -0
- data/config/locales/blacklight.it.yml +1 -0
- data/config/locales/blacklight.pt-BR.yml +1 -0
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/configuration/field.rb +1 -1
- data/lib/blacklight/configuration/search_field.rb +1 -1
- data/lib/blacklight/configuration/sort_field.rb +1 -1
- data/lib/blacklight/search_builder.rb +8 -4
- data/lib/blacklight/search_state.rb +3 -3
- data/lib/blacklight/solr/repository.rb +3 -3
- data/lib/blacklight/solr/request.rb +2 -2
- data/lib/blacklight/solr/response.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +7 -7
- data/lib/blacklight/utils.rb +5 -5
- data/lib/generators/blacklight/assets_generator.rb +1 -1
- data/lib/generators/blacklight/controller_generator.rb +13 -15
- data/lib/generators/blacklight/document_generator.rb +5 -4
- data/lib/generators/blacklight/install_generator.rb +24 -27
- data/lib/generators/blacklight/models_generator.rb +18 -16
- data/lib/generators/blacklight/search_builder_generator.rb +4 -4
- data/lib/generators/blacklight/solr4_generator.rb +14 -9
- data/lib/generators/blacklight/solr5_generator.rb +1 -1
- data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
- data/lib/generators/blacklight/templates/solr_document.rb +6 -8
- data/lib/generators/blacklight/test_support_generator.rb +5 -3
- data/lib/generators/blacklight/user_generator.rb +18 -12
- data/lib/railties/blacklight.rake +2 -2
- data/tasks/blacklight.rake +1 -3
- metadata +17 -10
- data/.rubocop_hound.yml +0 -1063
data/app/models/record_mailer.rb
CHANGED
@@ -3,7 +3,12 @@
|
|
3
3
|
class RecordMailer < ActionMailer::Base
|
4
4
|
def email_record(documents, details, url_gen_params)
|
5
5
|
|
6
|
-
|
6
|
+
title = begin
|
7
|
+
documents.first.to_semantic_values[:title]
|
8
|
+
rescue
|
9
|
+
I18n.t('blacklight.email.text.default_title')
|
10
|
+
end
|
11
|
+
subject = I18n.t('blacklight.email.text.subject', :count => documents.length, :title => title )
|
7
12
|
|
8
13
|
@documents = documents
|
9
14
|
@message = details[:message]
|
data/app/models/search.rb
CHANGED
@@ -18,8 +18,8 @@ class Search < ActiveRecord::Base
|
|
18
18
|
|
19
19
|
# delete old, unsaved searches
|
20
20
|
def self.delete_old_searches(days_old)
|
21
|
-
raise ArgumentError
|
22
|
-
raise ArgumentError
|
21
|
+
raise ArgumentError, 'days_old is expected to be a number' unless days_old.is_a?(Numeric)
|
22
|
+
raise ArgumentError, 'days_old is expected to be greater than 0' if days_old <= 0
|
23
23
|
self.destroy_all(['created_at < ? AND user_id IS NULL', Time.zone.today - days_old])
|
24
24
|
end
|
25
25
|
|
data/blacklight.gemspec
CHANGED
@@ -11,7 +11,10 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.email = ["blacklight-development@googlegroups.com"]
|
12
12
|
s.homepage = "http://projectblacklight.org/"
|
13
13
|
s.summary = "Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr) index."
|
14
|
-
s.description = %
|
14
|
+
s.description = %(Blacklight is an open source Solr user interface discovery platform.
|
15
|
+
You can use Blacklight to enable searching and browsing of your
|
16
|
+
collections. Blacklight uses the Apache Solr search engine to search
|
17
|
+
full text and/or metadata.)
|
15
18
|
s.license = "Apache 2.0"
|
16
19
|
|
17
20
|
s.files = `git ls-files -z`.split("\x0")
|
@@ -26,7 +29,7 @@ Gem::Specification.new do |s|
|
|
26
29
|
s.add_dependency "globalid"
|
27
30
|
s.add_dependency "nokogiri", "~>1.6" # XML Parser
|
28
31
|
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
|
29
|
-
s.add_dependency "rsolr", "~> 1.0.
|
32
|
+
s.add_dependency "rsolr", "~> 1.0", ">= 1.0.6" # Library for interacting with rSolr.
|
30
33
|
s.add_dependency "bootstrap-sass", "~> 3.2"
|
31
34
|
s.add_dependency "deprecation"
|
32
35
|
s.add_dependency "twitter-typeahead-rails", '~> 0.11'
|
data/lib/blacklight.rb
CHANGED
@@ -63,7 +63,7 @@ module Blacklight
|
|
63
63
|
require 'yaml'
|
64
64
|
|
65
65
|
return @blacklight_yml if @blacklight_yml
|
66
|
-
unless File.
|
66
|
+
unless File.exist?(blacklight_config_file)
|
67
67
|
raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
|
68
68
|
end
|
69
69
|
|
@@ -74,7 +74,7 @@ module Blacklight
|
|
74
74
|
end
|
75
75
|
|
76
76
|
begin
|
77
|
-
@blacklight_yml = YAML
|
77
|
+
@blacklight_yml = YAML.load(blacklight_erb)
|
78
78
|
rescue => e
|
79
79
|
raise("#{blacklight_config_file} was found, but could not be parsed.\n#{e.inspect}")
|
80
80
|
end
|
@@ -22,14 +22,14 @@ module Blacklight
|
|
22
22
|
# @param [String] document's unique key value
|
23
23
|
# @param [Hash] additional query parameters
|
24
24
|
def find(id, params = {})
|
25
|
-
|
25
|
+
raise NotImplementedError
|
26
26
|
end
|
27
27
|
|
28
28
|
##
|
29
29
|
# Execute a search query against a search index
|
30
30
|
# @param [Hash] query parameters
|
31
31
|
def search(params = {})
|
32
|
-
|
32
|
+
raise NotImplementedError
|
33
33
|
end
|
34
34
|
|
35
35
|
protected
|
@@ -210,14 +210,18 @@ module Blacklight
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
|
213
|
+
alias per rows
|
214
214
|
|
215
215
|
def sort
|
216
|
-
|
216
|
+
sort_field = if blacklight_params[:sort].blank?
|
217
217
|
# no sort param provided, use default
|
218
|
-
|
219
|
-
|
218
|
+
blacklight_config.default_sort_field
|
219
|
+
else
|
220
220
|
# check for sort field key
|
221
|
+
blacklight_config.sort_fields[blacklight_params[:sort]]
|
222
|
+
end
|
223
|
+
|
224
|
+
field = if sort_field.present?
|
221
225
|
sort_field.sort
|
222
226
|
else
|
223
227
|
# just pass the key through
|
@@ -74,7 +74,7 @@ module Blacklight
|
|
74
74
|
# Delete any request params from facet-specific action, needed
|
75
75
|
# to redir to index action properly.
|
76
76
|
request_keys = blacklight_config.facet_paginator_class.request_keys
|
77
|
-
new_params.extract!
|
77
|
+
new_params.extract!(*request_keys.values)
|
78
78
|
|
79
79
|
new_params
|
80
80
|
end
|
@@ -101,7 +101,7 @@ module Blacklight
|
|
101
101
|
p[:f] = (p[:f] || {}).dup
|
102
102
|
p[:f][url_field] = (p[:f][url_field] || []).dup
|
103
103
|
p[:f][url_field] = p[:f][url_field] - [value]
|
104
|
-
p[:f].delete(url_field) if p[:f][url_field].
|
104
|
+
p[:f].delete(url_field) if p[:f][url_field].empty?
|
105
105
|
p.delete(:f) if p[:f].empty?
|
106
106
|
p
|
107
107
|
end
|
@@ -158,7 +158,7 @@ module Blacklight
|
|
158
158
|
p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
|
159
159
|
p[:f][url_field] = (p[:f][url_field] || []).dup
|
160
160
|
|
161
|
-
if facet_config.single and
|
161
|
+
if facet_config.single and p[:f][url_field].present?
|
162
162
|
p[:f][url_field] = []
|
163
163
|
end
|
164
164
|
|
@@ -12,7 +12,7 @@ module Blacklight::Solr
|
|
12
12
|
.merge(blacklight_config.document_unique_id_param => id)
|
13
13
|
|
14
14
|
solr_response = send_and_receive blacklight_config.document_solr_path || blacklight_config.solr_path, doc_params
|
15
|
-
raise Blacklight::Exceptions::RecordNotFound
|
15
|
+
raise Blacklight::Exceptions::RecordNotFound if solr_response.documents.empty?
|
16
16
|
solr_response
|
17
17
|
end
|
18
18
|
|
@@ -45,9 +45,9 @@ module Blacklight::Solr
|
|
45
45
|
solr_response
|
46
46
|
end
|
47
47
|
rescue Errno::ECONNREFUSED => e
|
48
|
-
raise Blacklight::Exceptions::ECONNREFUSED
|
48
|
+
raise Blacklight::Exceptions::ECONNREFUSED, "Unable to connect to Solr instance using #{connection.inspect}: #{e.inspect}"
|
49
49
|
rescue RSolr::Error::Http => e
|
50
|
-
raise Blacklight::Exceptions::InvalidRequest
|
50
|
+
raise Blacklight::Exceptions::InvalidRequest, e.message
|
51
51
|
end
|
52
52
|
|
53
53
|
protected
|
@@ -3,8 +3,8 @@ class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
|
3
3
|
|
4
4
|
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
5
5
|
|
6
|
-
SINGULAR_KEYS = %w
|
7
|
-
ARRAY_KEYS = %w
|
6
|
+
SINGULAR_KEYS = %w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
|
7
|
+
ARRAY_KEYS = %w(facet.field facet.query facet.pivot fq hl.fl)
|
8
8
|
|
9
9
|
def initialize(constructor = {})
|
10
10
|
if constructor.is_a?(Hash)
|
@@ -52,8 +52,8 @@ module Blacklight::Solr
|
|
52
52
|
# solr LocalParams in config, using solr LocalParams syntax.
|
53
53
|
# http://wiki.apache.org/solr/LocalParams
|
54
54
|
##
|
55
|
-
if
|
56
|
-
local_params =
|
55
|
+
if search_field && search_field.solr_local_parameters.present?
|
56
|
+
local_params = search_field.solr_local_parameters.map do |key, val|
|
57
57
|
key.to_s + "=" + solr_param_quote(val, :quote => "'")
|
58
58
|
end.join(" ")
|
59
59
|
solr_parameters[:q] = "{!#{local_params}}#{blacklight_params[:q]}"
|
@@ -91,7 +91,7 @@ module Blacklight::Solr
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# :fq, map from :f.
|
94
|
-
if
|
94
|
+
if blacklight_params[:f]
|
95
95
|
f_request_params = blacklight_params[:f]
|
96
96
|
|
97
97
|
f_request_params.each_pair do |facet_field, value_list|
|
@@ -202,7 +202,7 @@ module Blacklight::Solr
|
|
202
202
|
end
|
203
203
|
|
204
204
|
page = blacklight_params.fetch(request_keys[:page], 1).to_i
|
205
|
-
offset = (page - 1) *
|
205
|
+
offset = (page - 1) * limit
|
206
206
|
|
207
207
|
sort = blacklight_params[request_keys[:sort]]
|
208
208
|
prefix = blacklight_params[request_keys[:prefix]]
|
@@ -281,7 +281,7 @@ module Blacklight::Solr
|
|
281
281
|
def facet_value_to_fq_string(facet_field, value)
|
282
282
|
facet_config = blacklight_config.facet_fields[facet_field]
|
283
283
|
|
284
|
-
solr_field = facet_config.field if facet_config and
|
284
|
+
solr_field = facet_config.field if facet_config and !facet_config.query
|
285
285
|
solr_field ||= facet_field
|
286
286
|
|
287
287
|
local_params = []
|
@@ -307,9 +307,9 @@ module Blacklight::Solr
|
|
307
307
|
def convert_to_term_value(value)
|
308
308
|
case
|
309
309
|
when (value.is_a?(DateTime) or value.is_a?(Time))
|
310
|
-
|
310
|
+
value.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
311
311
|
when value.is_a?(Date)
|
312
|
-
|
312
|
+
value.to_time(:local).strftime("%Y-%m-%dT%H:%M:%SZ")
|
313
313
|
else
|
314
314
|
value.to_s
|
315
315
|
end
|
data/lib/blacklight/utils.rb
CHANGED
@@ -85,11 +85,11 @@ module Blacklight
|
|
85
85
|
end
|
86
86
|
|
87
87
|
lazy_configs.each do |k,v|
|
88
|
-
if v.is_a? nested_class
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
hash[k] = if v.is_a? nested_class
|
89
|
+
v
|
90
|
+
else
|
91
|
+
nested_class.new v
|
92
|
+
end
|
93
93
|
end
|
94
94
|
|
95
95
|
super hash
|
@@ -4,7 +4,7 @@ module Blacklight
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
6
|
def assets
|
7
|
-
copy_file "blacklight.
|
7
|
+
copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss"
|
8
8
|
|
9
9
|
return if has_blacklight_assets?
|
10
10
|
|
@@ -6,20 +6,18 @@ module Blacklight
|
|
6
6
|
|
7
7
|
argument :controller_name , type: :string , default: "catalog"
|
8
8
|
|
9
|
-
desc
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Thank you for Installing Blacklight.
|
16
|
-
"""
|
9
|
+
desc <<-EOS
|
10
|
+
This generator makes the following changes to your application:
|
11
|
+
1. Injects behavior into your user application_controller.rb
|
12
|
+
2. Creates a Blacklight::Catalog-based controller
|
13
|
+
3. Adds routes for your controller
|
14
|
+
EOS
|
17
15
|
|
18
16
|
# Add Blacklight to the application controller
|
19
17
|
def inject_blacklight_controller_behavior
|
20
18
|
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
21
|
-
" # Adds a few additional behaviors into the application controller
|
22
|
-
" include Blacklight::Controller\n"
|
19
|
+
" # Adds a few additional behaviors into the application controller\n" \
|
20
|
+
" include Blacklight::Controller\n" \
|
23
21
|
" layout 'blacklight'\n\n"
|
24
22
|
end
|
25
23
|
end
|
@@ -30,12 +28,12 @@ module Blacklight
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def inject_blacklight_routes
|
33
|
-
route <<-EOF
|
34
|
-
|
31
|
+
route <<-EOF
|
32
|
+
concern :searchable, Blacklight::Routes::Searchable.new
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
|
35
|
+
concerns :searchable
|
36
|
+
end
|
39
37
|
EOF
|
40
38
|
end
|
41
39
|
end
|
@@ -9,10 +9,11 @@ module Blacklight
|
|
9
9
|
|
10
10
|
argument :model_name, :type => :string , :default => "solr_document"
|
11
11
|
|
12
|
-
desc
|
13
|
-
This generator makes the following changes to your application:
|
14
|
-
|
15
|
-
|
12
|
+
desc <<-EOS
|
13
|
+
This generator makes the following changes to your application:
|
14
|
+
1. Creates a blacklight document in your /app/models directory
|
15
|
+
EOS
|
16
|
+
|
16
17
|
def create_solr_document
|
17
18
|
template "solr_document.rb", "app/models/#{model_name}.rb"
|
18
19
|
end
|
@@ -13,32 +13,31 @@ module Blacklight
|
|
13
13
|
class_option :devise , type: :boolean, default: false, aliases: "-d", desc: "Use Devise as authentication logic."
|
14
14
|
class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty"
|
15
15
|
class_option :marc , type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo ."
|
16
|
+
class_option :'skip-assets', type: :boolean, default: false, desc: "Skip generating javascript and css assets into the application"
|
16
17
|
|
17
|
-
desc
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
7. Adds Blacklight routes to your ./config/routes.rb
|
18
|
+
desc <<-EOS
|
19
|
+
This generator makes the following changes to your application:
|
20
|
+
1. Generates blacklight:models
|
21
|
+
2. Generates utilities for working with solr
|
22
|
+
3. Creates a number of public assets, including images, stylesheets, and javascript
|
23
|
+
4. Injects behavior into your user application_controller.rb
|
24
|
+
5. Adds example configurations for dealing with MARC-like data
|
25
|
+
6. Adds Blacklight routes to your ./config/routes.rb
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
Thank you for Installing Blacklight.
|
28
|
+
EOS
|
29
29
|
|
30
30
|
def add_solr_wrapper
|
31
|
-
if options[:jettywrapper]
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
gem "globalid"
|
31
|
+
generator_options = '--jettywrapper' if options[:jettywrapper]
|
32
|
+
solr_generator = case
|
33
|
+
when options[:jettywrapper]
|
34
|
+
'blacklight:solr4'
|
35
|
+
when solr_version == 'latest'
|
36
|
+
'blacklight:solr5'
|
37
|
+
else
|
38
|
+
"blacklight:solr#{solr_version}"
|
39
|
+
end
|
40
|
+
generate solr_generator, generator_options
|
42
41
|
end
|
43
42
|
|
44
43
|
def bundle_install
|
@@ -51,7 +50,7 @@ module Blacklight
|
|
51
50
|
# Call external generator in AssetsGenerator, so we can
|
52
51
|
# leave that callable seperately too.
|
53
52
|
def copy_public_assets
|
54
|
-
generate "blacklight:assets"
|
53
|
+
generate "blacklight:assets" unless options[:'skip-assets']
|
55
54
|
end
|
56
55
|
|
57
56
|
def generate_blacklight_document
|
@@ -87,7 +86,7 @@ module Blacklight
|
|
87
86
|
def add_sass_configuration
|
88
87
|
|
89
88
|
insert_into_file "config/application.rb", :after => "config.assets.enabled = true" do <<EOF
|
90
|
-
|
89
|
+
|
91
90
|
# Default SASS Configuration, check out https://github.com/rails/sass-rails for details
|
92
91
|
config.assets.compress = !Rails.env.development?
|
93
92
|
EOF
|
@@ -112,9 +111,7 @@ EOF
|
|
112
111
|
end
|
113
112
|
|
114
113
|
def add_routes
|
115
|
-
route
|
116
|
-
mount Blacklight::Engine => '/'
|
117
|
-
EOF
|
114
|
+
route "mount Blacklight::Engine => '/'"
|
118
115
|
end
|
119
116
|
end
|
120
117
|
end
|