blacklight 6.0.0.pre4 → 6.0.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +2 -2
- data/app/controllers/concerns/blacklight/catalog.rb +2 -0
- data/app/controllers/concerns/blacklight/search_context.rb +2 -2
- data/app/controllers/concerns/blacklight/search_helper.rb +1 -1
- data/app/controllers/saved_searches_controller.rb +2 -2
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/bookmark.rb +3 -1
- data/app/models/concerns/blacklight/document.rb +1 -1
- data/app/models/concerns/blacklight/document/active_model_shim.rb +4 -0
- data/app/models/concerns/blacklight/document/export.rb +3 -7
- data/app/models/concerns/blacklight/user.rb +1 -1
- data/app/views/layouts/blacklight.html.erb +1 -1
- data/lib/blacklight.rb +1 -0
- data/lib/blacklight/abstract_repository.rb +15 -0
- data/lib/blacklight/engine.rb +4 -0
- data/lib/blacklight/search_builder.rb +5 -1
- data/lib/blacklight/search_state.rb +1 -1
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response.rb +3 -3
- data/lib/blacklight/utils.rb +15 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +9 -0
- data/spec/controllers/blacklight/base_spec.rb +1 -1
- data/spec/helpers/catalog_helper_spec.rb +1 -1
- data/spec/helpers/facets_helper_spec.rb +1 -1
- data/spec/models/blacklight/solr/repository_spec.rb +4 -4
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7626335c66be4201927a8a1afbe8df051da1b4b0
|
4
|
+
data.tar.gz: 5bd3bfaac1b8b69940573d3172c7e0e8a97522af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814188a4b39df6c79dc2c993e0bc1ab879028b071b4341efcd4ebdb30594d1c3a8efb64b317d2f8e808d9dbc7ad029f5d313aff387711f2c21d6e8d7ac9107b0
|
7
|
+
data.tar.gz: 11a6ea22038b58e3240397a7e36dfe16c8c28730e18cbcedbe6fca188887fcce3ad8ff511757b5fe0d7c013420a458a424de3cb0c10fc4d01415c6c703248b3a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.0.0.
|
1
|
+
6.0.0.pre5
|
@@ -12,7 +12,7 @@ module Blacklight::Bookmarks
|
|
12
12
|
|
13
13
|
copy_blacklight_config_from(CatalogController)
|
14
14
|
|
15
|
-
|
15
|
+
before_action :verify_user
|
16
16
|
|
17
17
|
blacklight_config.add_results_collection_tool(:clear_bookmarks_widget)
|
18
18
|
|
@@ -97,7 +97,7 @@ module Blacklight::Bookmarks
|
|
97
97
|
# Beware, :id is the Solr document_id, not the actual Bookmark id.
|
98
98
|
# idempotent, as DELETE is supposed to be.
|
99
99
|
def destroy
|
100
|
-
bookmark = current_or_guest_user.bookmarks.find_by(document_id: params[:id], document_type: blacklight_config.document_model)
|
100
|
+
bookmark = current_or_guest_user.bookmarks.find_by(document_id: params[:id], document_type: blacklight_config.document_model.to_s)
|
101
101
|
|
102
102
|
if bookmark && bookmark.delete && bookmark.destroyed?
|
103
103
|
if request.xhr?
|
@@ -249,6 +249,8 @@ module Blacklight::Catalog
|
|
249
249
|
# CatalogController to do something else -- older BL displayed a Catalog#inde
|
250
250
|
# page with a flash message and a 404 status.
|
251
251
|
def invalid_document_id_error(exception)
|
252
|
+
raise exception unless Pathname.new("#{Rails.root}/public/404.html").exist?
|
253
|
+
|
252
254
|
error_info = {
|
253
255
|
"status" => "404",
|
254
256
|
"error" => "#{exception.class}: #{exception.message}"
|
@@ -11,7 +11,7 @@ module Blacklight::SearchContext
|
|
11
11
|
module ClassMethods
|
12
12
|
# Save the submitted search parameters in the search session
|
13
13
|
def record_search_parameters opts = { only: :index}
|
14
|
-
|
14
|
+
before_action :current_search_session, opts
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -93,7 +93,7 @@ module Blacklight::SearchContext
|
|
93
93
|
def setup_next_and_previous_documents
|
94
94
|
if search_session['counter'] and current_search_session
|
95
95
|
index = search_session['counter'].to_i - 1
|
96
|
-
response, documents = get_previous_and_next_documents_for_search index, current_search_session.query_params
|
96
|
+
response, documents = get_previous_and_next_documents_for_search index, ActiveSupport::HashWithIndifferentAccess.new(current_search_session.query_params)
|
97
97
|
|
98
98
|
search_session['total'] = response.total
|
99
99
|
@search_context_response = response
|
@@ -48,7 +48,7 @@ module Blacklight::SearchHelper
|
|
48
48
|
include Blacklight::RequestBuilders
|
49
49
|
|
50
50
|
# a solr query method
|
51
|
-
# @param [Hash
|
51
|
+
# @param [Hash] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
|
52
52
|
# @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new SearchBuilder to be used. Block should return SearchBuilder to be used.
|
53
53
|
# @return [Blacklight::Solr::Response] the solr response object
|
54
54
|
def search_results(user_params)
|
@@ -2,8 +2,8 @@ class SavedSearchesController < ApplicationController
|
|
2
2
|
include Blacklight::Configurable
|
3
3
|
|
4
4
|
copy_blacklight_config_from(CatalogController)
|
5
|
-
|
6
|
-
|
5
|
+
before_action :require_user_authentication_provider
|
6
|
+
before_action :verify_user
|
7
7
|
|
8
8
|
def index
|
9
9
|
@searches = current_user.searches
|
@@ -13,7 +13,7 @@ module Blacklight::UrlHelperBehavior
|
|
13
13
|
|
14
14
|
# link_to_document(doc, 'VIEW', :counter => 3)
|
15
15
|
# Use the catalog_path RESTful route to create a link to the show page for a specific item.
|
16
|
-
# catalog_path accepts a
|
16
|
+
# catalog_path accepts a hash. The solr query params are stored in the session,
|
17
17
|
# so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
|
18
18
|
def link_to_document(doc, field_or_opts = nil, opts={:counter => nil})
|
19
19
|
if field_or_opts.is_a? Hash
|
data/app/models/bookmark.rb
CHANGED
@@ -14,7 +14,9 @@ class Bookmark < ActiveRecord::Base
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def document_type
|
17
|
-
|
17
|
+
value = super if defined?(super)
|
18
|
+
value &&= value.constantize
|
19
|
+
value ||= default_document_type
|
18
20
|
end
|
19
21
|
|
20
22
|
def default_document_type
|
@@ -39,7 +39,7 @@ module Blacklight::Document
|
|
39
39
|
alias_method :solr_response, :response
|
40
40
|
|
41
41
|
def initialize(source_doc={}, response=nil)
|
42
|
-
@_source = source_doc
|
42
|
+
@_source = ActiveSupport::HashWithIndifferentAccess.new(source_doc)
|
43
43
|
@response = response
|
44
44
|
apply_extensions
|
45
45
|
end
|
@@ -56,13 +56,9 @@ module Blacklight::Document::Export
|
|
56
56
|
# registered. This is a bit sketchy though.
|
57
57
|
def will_export_as(short_name, content_type = nil)
|
58
58
|
#Lookup in Rails Mime::Type, register if needed, otherwise take
|
59
|
-
# content-type from registration if needed.
|
60
|
-
|
61
|
-
|
62
|
-
# type. But that's the only way to do the kind of check we need, sorry.
|
63
|
-
if defined?(Mime) && Mime.const_defined?(short_name.to_s.upcase)
|
64
|
-
mime_type = "Mime::#{short_name.to_s.upcase}".constantize
|
65
|
-
content_type ||= mime_type.to_s
|
59
|
+
# content-type from registration if needed.
|
60
|
+
if defined?(Mime) && Mime[short_name.to_sym]
|
61
|
+
content_type ||= Mime[short_name.to_sym]
|
66
62
|
else
|
67
63
|
# not registered, we need to register. Use register_alias to be least
|
68
64
|
# likely to interfere with host app.
|
@@ -12,7 +12,7 @@ module Blacklight::User
|
|
12
12
|
|
13
13
|
def bookmarks_for_documents documents = []
|
14
14
|
if documents.length > 0
|
15
|
-
bookmarks.where(document_type: documents.first.class.base_class, document_id: documents.map(&:id))
|
15
|
+
bookmarks.where(document_type: documents.first.class.base_class.to_s, document_id: documents.map(&:id))
|
16
16
|
else
|
17
17
|
[]
|
18
18
|
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
<title><%= render_page_title %></title>
|
20
20
|
<%= opensearch_description_tag application_name, opensearch_catalog_url(:format => 'xml') %>
|
21
|
-
<%= favicon_link_tag
|
21
|
+
<%= favicon_link_tag %>
|
22
22
|
<%= stylesheet_link_tag "application", media: "all" %>
|
23
23
|
<%= javascript_include_tag "application" %>
|
24
24
|
<%= csrf_meta_tags %>
|
data/lib/blacklight.rb
CHANGED
@@ -16,6 +16,21 @@ module Blacklight
|
|
16
16
|
@connection ||= build_connection
|
17
17
|
end
|
18
18
|
|
19
|
+
##
|
20
|
+
# Find a single document result by a known id
|
21
|
+
# @param [String] document's unique key value
|
22
|
+
# @param [Hash] additional query parameters
|
23
|
+
def find(id, params = {})
|
24
|
+
fail NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Execute a search query against a search index
|
29
|
+
# @param [Hash] query parameters
|
30
|
+
def search(params = {})
|
31
|
+
fail NotImplementedError
|
32
|
+
end
|
33
|
+
|
19
34
|
protected
|
20
35
|
def connection_config
|
21
36
|
blacklight_config.connection_config
|
data/lib/blacklight/engine.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
module Blacklight
|
2
|
+
##
|
3
|
+
# Blacklight's SearchBuilder converts blacklight request parameters into
|
4
|
+
# query parameters appropriate for search index. It does so by evaluating a
|
5
|
+
# chain of processing methods to populate a result hash (see {#to_hash}).
|
2
6
|
class SearchBuilder
|
3
7
|
extend Deprecation
|
4
8
|
class_attribute :default_processor_chain
|
@@ -106,7 +110,7 @@ module Blacklight
|
|
106
110
|
delegate :[], :key?, to: :to_hash
|
107
111
|
|
108
112
|
# a solr query method
|
109
|
-
# @param [Hash
|
113
|
+
# @param [Hash] extra_controller_params (nil) extra parameters to add to the search
|
110
114
|
# @return [Blacklight::Solr::Response] the solr response object
|
111
115
|
def to_hash
|
112
116
|
if params_need_update?
|
@@ -115,7 +115,7 @@ module Blacklight
|
|
115
115
|
# Reset any search parameters that store search context
|
116
116
|
# and need to be reset when e.g. constraints change
|
117
117
|
def reset_search_params
|
118
|
-
Parameters.sanitize(params).except(:page, :counter)
|
118
|
+
ActiveSupport::HashWithIndifferentAccess.new(Parameters.sanitize(params).except(:page, :counter))
|
119
119
|
end
|
120
120
|
|
121
121
|
# TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
2
2
|
|
3
|
-
class Blacklight::Solr::Request < HashWithIndifferentAccess
|
3
|
+
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
4
4
|
|
5
5
|
SINGULAR_KEYS = %w{facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType}
|
6
6
|
ARRAY_KEYS = %w{facet.field facet.query facet.pivot fq hl.fl}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Blacklight::Solr::Response < HashWithIndifferentAccess
|
1
|
+
class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
2
2
|
extend Deprecation
|
3
3
|
|
4
4
|
# Using required_dependency to work around Rails autoloading
|
@@ -22,8 +22,8 @@ class Blacklight::Solr::Response < HashWithIndifferentAccess
|
|
22
22
|
attr_accessor :document_model, :blacklight_config
|
23
23
|
|
24
24
|
def initialize(data, request_params, options = {})
|
25
|
-
super(force_to_utf8(data))
|
26
|
-
@request_params = request_params
|
25
|
+
super(force_to_utf8(ActiveSupport::HashWithIndifferentAccess.new(data)))
|
26
|
+
@request_params = ActiveSupport::HashWithIndifferentAccess.new(request_params)
|
27
27
|
self.document_model = options[:solr_document_model] || options[:document_model] || SolrDocument
|
28
28
|
self.blacklight_config = options[:blacklight_config]
|
29
29
|
end
|
data/lib/blacklight/utils.rb
CHANGED
@@ -153,7 +153,21 @@ module Blacklight
|
|
153
153
|
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
|
154
154
|
def merge! other_hash
|
155
155
|
@table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
156
|
-
end
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# Override #method_missing from OpenStruct to ensure the default_proc logic
|
160
|
+
# gets triggered.
|
161
|
+
def method_missing(mid, *args)
|
162
|
+
len = args.length
|
163
|
+
|
164
|
+
if len == 0
|
165
|
+
new_ostruct_member(mid)
|
166
|
+
@table[mid]
|
167
|
+
else
|
168
|
+
super
|
169
|
+
end
|
170
|
+
end
|
157
171
|
|
158
172
|
private
|
159
173
|
def set_default_proc!
|
@@ -3,6 +3,15 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
3
3
|
include Blacklight::Catalog
|
4
4
|
|
5
5
|
configure_blacklight do |config|
|
6
|
+
## Class for sending and receiving requests from a search index
|
7
|
+
# config.repository_class = Blacklight::Solr::Repository
|
8
|
+
#
|
9
|
+
## Class for converting Blacklight's url parameters to into request parameters for the search index
|
10
|
+
# config.search_builder_class = ::SearchBuilder
|
11
|
+
#
|
12
|
+
## Model that maps search index responses to the blacklight response model
|
13
|
+
# config.response_model = Blacklight::Solr::Response
|
14
|
+
|
6
15
|
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
7
16
|
config.default_solr_params = {
|
8
17
|
rows: 10
|
@@ -10,7 +10,7 @@ describe CatalogHelper do
|
|
10
10
|
total = args[:total]
|
11
11
|
start = (current_page - 1) * per_page
|
12
12
|
|
13
|
-
mock_docs = (1..total).to_a.map {
|
13
|
+
mock_docs = (1..total).to_a.map { ActiveSupport::HashWithIndifferentAccess.new }
|
14
14
|
|
15
15
|
mock_response = Kaminari.paginate_array(mock_docs).page(current_page).per(per_page)
|
16
16
|
|
@@ -111,7 +111,7 @@ describe FacetsHelper do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should not be collapsed if it is in the params" do
|
114
|
-
params[:f] =
|
114
|
+
params[:f] = ActiveSupport::HashWithIndifferentAccess.new(basic_field: [1], no_collapse: [2])
|
115
115
|
expect(helper.should_collapse_facet?(@config.facet_fields['basic_field'])).to be false
|
116
116
|
expect(helper.should_collapse_facet?(@config.facet_fields['no_collapse'])).to be false
|
117
117
|
end
|
@@ -51,11 +51,11 @@ describe Blacklight::Solr::Repository do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should preserve the class of the incoming params" do
|
54
|
-
doc_params = HashWithIndifferentAccess.new
|
54
|
+
doc_params = ActiveSupport::HashWithIndifferentAccess.new
|
55
55
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
56
56
|
response = subject.find("123", doc_params)
|
57
57
|
expect(response).to be_a_kind_of Blacklight::Solr::Response
|
58
|
-
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
|
58
|
+
expect(response.params).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -84,13 +84,13 @@ describe Blacklight::Solr::Repository do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should preserve the class of the incoming params" do
|
87
|
-
search_params = HashWithIndifferentAccess.new
|
87
|
+
search_params = ActiveSupport::HashWithIndifferentAccess.new
|
88
88
|
search_params[:q] = "query"
|
89
89
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
90
90
|
|
91
91
|
response = subject.search(search_params)
|
92
92
|
expect(response).to be_a_kind_of Blacklight::Solr::Response
|
93
|
-
expect(response.params).to be_a_kind_of HashWithIndifferentAccess
|
93
|
+
expect(response.params).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -26,7 +26,7 @@ describe Blacklight::Solr::Response::Facets do
|
|
26
26
|
let(:facet_field) { ['my_field', []] }
|
27
27
|
let(:response_header) { { params: request_params }}
|
28
28
|
let(:request_params) { Hash.new }
|
29
|
-
subject { Blacklight::Solr::Response.new({responseHeader: response_header, facet_counts: { facet_fields: [facet_field] }}
|
29
|
+
subject { Blacklight::Solr::Response.new({responseHeader: response_header, facet_counts: { facet_fields: [facet_field] }}, request_params) }
|
30
30
|
|
31
31
|
describe "#limit" do
|
32
32
|
it "should extract a field-specific limit value" do
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "catalog/_paginate_compact.html.erb" do
|
4
|
+
let(:user) { User.new.tap { |u| u.save(validate: false) } }
|
4
5
|
|
5
6
|
describe "with a real solr response", :integration => true do
|
6
7
|
def blacklight_config
|
@@ -33,7 +34,7 @@ describe "catalog/_paginate_compact.html.erb" do
|
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should render ActiveRecord collections" do
|
36
|
-
50.times { b = Bookmark.new; b.
|
37
|
+
50.times { b = Bookmark.new; b.user = user; b.save! }
|
37
38
|
render :partial => 'catalog/paginate_compact', :object => Bookmark.page(1).per(25)
|
38
39
|
expect(rendered).to have_selector ".page_entries"
|
39
40
|
expect(rendered).to have_selector "a[@rel=next]"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.
|
4
|
+
version: 6.0.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: exe
|
19
19
|
cert_chain: []
|
20
|
-
date: 2015-
|
20
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|