blacklight_oai_provider 5.1.0 → 6.0.0.pre1
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/.travis.yml +5 -3
- data/README.md +12 -19
- data/VERSION +1 -1
- data/app/controllers/concerns/blacklight_oai_provider/controller.rb +8 -3
- data/blacklight_oai_provider.gemspec +2 -7
- data/lib/blacklight_oai_provider.rb +0 -14
- data/lib/blacklight_oai_provider/engine.rb +0 -9
- data/lib/blacklight_oai_provider/routes.rb +5 -9
- data/lib/blacklight_oai_provider/solr_document_provider.rb +1 -1
- data/lib/generators/blacklight_oai_provider/install_generator.rb +12 -0
- data/lib/railties/blacklight_oai_provider.rake +1 -1
- data/spec/requests/list_records_spec.rb +1 -1
- data/spec/requests/list_sets_spec.rb +6 -6
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +13 -2
- metadata +16 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925f8e505c2c065988441a313a3cfd0788d08870
|
4
|
+
data.tar.gz: f0deb637627d94e7972d5061d66e4cdb80cbca62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45d6d9ef23dacabb77acc630c5f9d2d08ce61a2c336b1b74a48d6c80a76733837be8ff5507625b5e06d00641487611b1c5b200411af150b5854d7297b3a69971
|
7
|
+
data.tar.gz: ae5ea77c99bafe7a34bfcb7ee672e9b3016876071c325b98073ab4ac15de70fad59750c1dffe54687fba794eb94058322c16c62bb356501c36cab6d1b2214ba5
|
data/.travis.yml
CHANGED
@@ -3,14 +3,16 @@ notifications:
|
|
3
3
|
|
4
4
|
language: ruby
|
5
5
|
sudo: false
|
6
|
+
addons:
|
7
|
+
chrome: stable
|
6
8
|
rvm:
|
9
|
+
- 2.4
|
7
10
|
- 2.3.3
|
8
|
-
- 2.2
|
9
|
-
- 2.1
|
10
11
|
|
11
12
|
env:
|
12
13
|
- "RAILS_VERSION=4.2.9"
|
13
|
-
- "RAILS_VERSION=
|
14
|
+
- "RAILS_VERSION=5.0.6"
|
15
|
+
- "RAILS_VERSION=5.1.4"
|
14
16
|
|
15
17
|
before_install:
|
16
18
|
- gem install bundler
|
data/README.md
CHANGED
@@ -34,16 +34,25 @@ Then run
|
|
34
34
|
```ruby
|
35
35
|
rails generate blacklight_oai_provider:install
|
36
36
|
```
|
37
|
-
to install the appropriate extensions into your `CatalogController`
|
37
|
+
to install the appropriate extensions into your `CatalogController` class, `SolrDocument` class, and routes file. If you want to do customize the way this installs, instead you may:
|
38
38
|
|
39
|
-
- add this to
|
39
|
+
- add this to the SolrDocument model:
|
40
40
|
```ruby
|
41
41
|
include BlacklightOaiProvider::SolrDocument
|
42
42
|
```
|
43
|
-
- add this to
|
43
|
+
- add this to the Controller:
|
44
44
|
```ruby
|
45
45
|
include BlacklightOaiProvider::Controller
|
46
46
|
```
|
47
|
+
- add this to `config/routes.rb`
|
48
|
+
```ruby
|
49
|
+
concern :oai_provider, BlacklightOaiProvider::Routes.new
|
50
|
+
|
51
|
+
resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
|
52
|
+
concerns :oai_provider
|
53
|
+
...
|
54
|
+
end
|
55
|
+
```
|
47
56
|
|
48
57
|
## Configuration
|
49
58
|
|
@@ -134,23 +143,7 @@ config.oai = {
|
|
134
143
|
}
|
135
144
|
}
|
136
145
|
```
|
137
|
-
## Injection
|
138
|
-
This plugin assumes it is in a Blacklight Rails app, uses Blacklight methods, Rails methods, and standard ruby module includes to inject it's behaviors into the app.
|
139
|
-
|
140
|
-
You can turn off this injection if you like, although it will make the plugin less (or non-) functional unless you manually do similar injection. See `lib/blacklight_oai_provider.rb#inject!` to see exactly what's going on.
|
141
146
|
|
142
|
-
In any initializer, you can set:
|
143
|
-
```ruby
|
144
|
-
BlacklightOaiProvider.omit_inject = true
|
145
|
-
```
|
146
|
-
to turn off all injection. The plugin will be completely non-functional if you do this, of course. But perhaps you could try to re-use some of it's classes in a non-Blacklight, highly hacked Blacklight, or even non-Rails application this way.
|
147
|
-
|
148
|
-
You can also turn off injection of individual components, which could be more useful:
|
149
|
-
```ruby
|
150
|
-
BlacklightOaiProvider.omit_inject = {
|
151
|
-
routes: false,
|
152
|
-
}
|
153
|
-
```
|
154
147
|
## Tests
|
155
148
|
We use `engine_cart` and `solr_wrapper` to run tests on a dummy instance of an app using this plugin.
|
156
149
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.0.pre1
|
@@ -14,13 +14,12 @@ module BlacklightOaiProvider
|
|
14
14
|
# Used when we need a second Solr query to get range facets, after the
|
15
15
|
# first found min/max from result set.
|
16
16
|
def oai
|
17
|
-
options = params.delete_if { |k, _| %w[controller action].include?(k) }
|
18
17
|
body = oai_provider
|
19
|
-
.process_request(
|
18
|
+
.process_request(oai_params.to_h)
|
20
19
|
.gsub('<?xml version="1.0" encoding="UTF-8"?>') do |m|
|
21
20
|
"#{m}\n<?xml-stylesheet type=\"text/xsl\" href=\"#{ActionController::Base.helpers.asset_path('blacklight_oai_provider/oai2.xsl')}\"?>\n"
|
22
21
|
end
|
23
|
-
render
|
22
|
+
render xml: body, content_type: 'text/xml'
|
24
23
|
end
|
25
24
|
|
26
25
|
# Uses Blacklight.config, needs to be modified when
|
@@ -34,5 +33,11 @@ module BlacklightOaiProvider
|
|
34
33
|
def oai_provider
|
35
34
|
@oai_provider ||= BlacklightOaiProvider::SolrDocumentProvider.new(self, oai_config)
|
36
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def oai_params
|
40
|
+
params.permit(:verb, :identifier, :metadataPrefix, :set, :from, :until, :resumptionToken)
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
@@ -9,11 +9,6 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.homepage = "http://projectblacklight.org/"
|
10
10
|
s.summary = "Blacklight Oai Provider plugin"
|
11
11
|
|
12
|
-
s.post_install_message = %q{
|
13
|
-
BlacklightOaiProvider v5.x implements configuration changes. Please visit README for more information.
|
14
|
-
|
15
|
-
}
|
16
|
-
|
17
12
|
s.rubyforge_project = "blacklight"
|
18
13
|
|
19
14
|
s.files = `git ls-files`.split("\n")
|
@@ -21,8 +16,8 @@ BlacklightOaiProvider v5.x implements configuration changes. Please visit README
|
|
21
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
17
|
s.require_paths = ["lib"]
|
23
18
|
|
24
|
-
s.add_dependency "rails",
|
25
|
-
s.add_dependency "blacklight",
|
19
|
+
s.add_dependency "rails", '>= 4.2', '< 6'
|
20
|
+
s.add_dependency "blacklight", '~> 6.0'
|
26
21
|
s.add_dependency "oai", "~> 0.4"
|
27
22
|
s.add_development_dependency 'rspec-rails', "~> 3.0"
|
28
23
|
s.add_development_dependency 'capybara'
|
@@ -12,20 +12,6 @@ module BlacklightOaiProvider
|
|
12
12
|
require 'blacklight_oai_provider/version'
|
13
13
|
require 'blacklight_oai_provider/engine'
|
14
14
|
|
15
|
-
@omit_inject = {}
|
16
|
-
def self.omit_inject=(value)
|
17
|
-
value = Hash.new(true) if value == true
|
18
|
-
@omit_inject = value
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.omit_inject
|
22
|
-
@omit_inject
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.inject!
|
26
|
-
Blacklight::Routes.send(:include, BlacklightOaiProvider::Routes) unless BlacklightOaiProvider.omit_inject[:routes]
|
27
|
-
end
|
28
|
-
|
29
15
|
# Add element to array only if it's not already there
|
30
16
|
def self.safe_arr_add(array, element)
|
31
17
|
array << element unless array.include?(element)
|
@@ -4,15 +4,6 @@ require 'rails'
|
|
4
4
|
|
5
5
|
module BlacklightOaiProvider
|
6
6
|
class Engine < Rails::Engine
|
7
|
-
# Do these things in a to_prepare block, to try and make them work
|
8
|
-
# in development mode with class-reloading. The trick is we can't
|
9
|
-
# be sure if the controllers we're modifying are being reloaded in
|
10
|
-
# dev mode, if they are in the BL plugin and haven't been copied to
|
11
|
-
# local, they won't be. But we do our best.
|
12
|
-
config.to_prepare do
|
13
|
-
BlacklightOaiProvider.inject!
|
14
|
-
end
|
15
|
-
|
16
7
|
# Add XSL Stylesheet to list of assets to be precompiled.
|
17
8
|
initializer "blacklight_oai_provider.assets.precompile" do |app|
|
18
9
|
app.config.assets.precompile += %w[blacklight_oai_provider/oai2.xsl]
|
@@ -1,15 +1,11 @@
|
|
1
1
|
module BlacklightOaiProvider
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
included do |klass|
|
6
|
-
klass.default_route_sets.insert(klass.default_route_sets.index(:export), :oai_routing)
|
2
|
+
class Routes
|
3
|
+
def initialize(defaults = {})
|
4
|
+
@defaults = defaults
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
|
11
|
-
get "#{primary_resource}/oai", to: "#{primary_resource}#oai", as: 'oai_provider'
|
12
|
-
end
|
7
|
+
def call(mapper, _options = {})
|
8
|
+
mapper.match 'oai', action: 'oai', via: [:get, :post]
|
13
9
|
end
|
14
10
|
end
|
15
11
|
end
|
@@ -9,7 +9,7 @@ module BlacklightOaiProvider
|
|
9
9
|
self.class.model = SolrDocumentWrapper.new(controller, options[:document])
|
10
10
|
|
11
11
|
options[:repository_name] ||= controller.view_context.send(:application_name)
|
12
|
-
options[:repository_url] ||= controller.view_context.send(:
|
12
|
+
options[:repository_url] ||= controller.view_context.send(:oai_catalog_url)
|
13
13
|
|
14
14
|
options[:provider].each do |k, v|
|
15
15
|
self.class.send k, v
|
@@ -23,5 +23,17 @@ module BlacklightOaiProvider
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
def inject_blacklight_oai_routes
|
28
|
+
file_path = File.join('config', 'routes.rb')
|
29
|
+
|
30
|
+
inject_into_file file_path, after: 'Rails.application.routes.draw do' do
|
31
|
+
"\n concern :oai_provider, BlacklightOaiProvider::Routes.new\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
inject_into_file file_path, after: /resource :catalog,+(.*)do$/ do
|
35
|
+
"\n concerns :oai_provider\n"
|
36
|
+
end
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
@@ -6,7 +6,7 @@ namespace :blacklight_oai_provider do
|
|
6
6
|
require 'yaml'
|
7
7
|
|
8
8
|
docs = YAML.safe_load(File.open(File.join(BlacklightOaiProvider.root, 'solr', 'sample_solr_documents.yml')))
|
9
|
-
conn =
|
9
|
+
conn = Blacklight.default_index.connection
|
10
10
|
conn.add docs
|
11
11
|
conn.commit
|
12
12
|
end
|
@@ -112,7 +112,7 @@ describe 'OIA-PMH ListRecords Request' do
|
|
112
112
|
it 'only records from the set are returned' do
|
113
113
|
params = { verb: 'ListRecords', metadataPrefix: 'oai_dc', set: 'language:Japanese' }
|
114
114
|
|
115
|
-
get
|
115
|
+
get oai_catalog_path(params)
|
116
116
|
expect(xml.xpath('//xmlns:record').count).to be 2
|
117
117
|
end
|
118
118
|
end
|
@@ -27,7 +27,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
27
27
|
|
28
28
|
context 'without set configuration' do
|
29
29
|
it 'shows that no sets exist' do
|
30
|
-
get
|
30
|
+
get oai_catalog_path(verb: 'ListSets')
|
31
31
|
expect(xml.xpath('//xmlns:error').text).to eql 'This repository does not support sets.'
|
32
32
|
end
|
33
33
|
end
|
@@ -36,18 +36,18 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
36
36
|
let(:test_oai_config) { old_config }
|
37
37
|
|
38
38
|
it 'shows all sets' do
|
39
|
-
get
|
39
|
+
get oai_catalog_path(verb: 'ListSets')
|
40
40
|
expect(xml.xpath('//xmlns:set').count).to be 12
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'contains english set' do
|
44
|
-
get
|
44
|
+
get oai_catalog_path(verb: 'ListSets')
|
45
45
|
expect(xml.xpath('//xmlns:set//xmlns:setSpec').map(&:text)).to include 'language:English'
|
46
46
|
expect(xml.xpath('//xmlns:set//xmlns:setName').map(&:text)).to include 'Language: English'
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'shows the correct verb' do
|
50
|
-
get
|
50
|
+
get oai_catalog_path(verb: 'ListSets')
|
51
51
|
expect(xml.at_xpath('//xmlns:request').attribute('verb').value).to eql 'ListSets'
|
52
52
|
end
|
53
53
|
end
|
@@ -65,7 +65,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'shows set description' do
|
68
|
-
get
|
68
|
+
get oai_catalog_path(verb: 'ListSets')
|
69
69
|
expect(
|
70
70
|
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
71
71
|
).to eql 'Subject topic set using FAST subjects'
|
@@ -92,7 +92,7 @@ RSpec.describe 'OAI-PMH ListSets Request' do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "shows correct description" do
|
95
|
-
get
|
95
|
+
get oai_catalog_path(verb: 'ListSets')
|
96
96
|
expect(
|
97
97
|
xml.at_xpath('//xmlns:set/xmlns:setDescription/oai_dc:dc/dc:description', namespaces).text
|
98
98
|
).to eql 'This is a format set containing records with the value of Book.'
|
@@ -13,6 +13,17 @@ class TestAppGenerator < Rails::Generators::Base
|
|
13
13
|
generate 'blacklight:install', '--devise'
|
14
14
|
end
|
15
15
|
|
16
|
+
def change_migrations_if_rails_4_2
|
17
|
+
return unless Rails.version =~ /^4.2.*/
|
18
|
+
|
19
|
+
say_status('warning', 'OVERRIDING BLACKLIGHT MIGRATION FOR RAILS 4.2', :yellow)
|
20
|
+
migrations = Rails.root.join('db', 'migrate', '*.rb')
|
21
|
+
Dir.glob(migrations).each do |m|
|
22
|
+
text = File.read(m).gsub(/ActiveRecord::Migration\[[\d\.]+\]/, 'ActiveRecord::Migration')
|
23
|
+
File.open(m, 'w').write(text)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
16
27
|
# Add favicon.ico to asset path
|
17
28
|
# ADD THIS LINE Rails.application.config.assets.precompile += %w( favicon.ico )
|
18
29
|
# TO config/assets.rb
|
@@ -43,8 +54,8 @@ class TestAppGenerator < Rails::Generators::Base
|
|
43
54
|
def add_test_blacklight_oai_config
|
44
55
|
say_status("warning", "ADDING BL OIA-PMH CONFIG")
|
45
56
|
|
46
|
-
insert_into_file "app/controllers/catalog_controller.rb", after: "
|
47
|
-
" fl: '*',\n"
|
57
|
+
insert_into_file "app/controllers/catalog_controller.rb", after: "config.default_solr_params = {" do
|
58
|
+
"\n fl: '*',\n"
|
48
59
|
end
|
49
60
|
|
50
61
|
insert_into_file "app/controllers/catalog_controller.rb", after: " configure_blacklight do |config|\n" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_oai_provider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -15,30 +15,36 @@ dependencies:
|
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '4.
|
20
|
+
version: '4.2'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '6'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '4.2'
|
31
|
+
- - "<"
|
26
32
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
33
|
+
version: '6'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: blacklight
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
38
|
- - "~>"
|
33
39
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
40
|
+
version: '6.0'
|
35
41
|
type: :runtime
|
36
42
|
prerelease: false
|
37
43
|
version_requirements: !ruby/object:Gem::Requirement
|
38
44
|
requirements:
|
39
45
|
- - "~>"
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
47
|
+
version: '6.0'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: oai
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,10 +255,7 @@ files:
|
|
249
255
|
homepage: http://projectblacklight.org/
|
250
256
|
licenses: []
|
251
257
|
metadata: {}
|
252
|
-
post_install_message:
|
253
|
-
|
254
|
-
BlacklightOaiProvider v5.x implements configuration changes. Please visit README for more information.
|
255
|
-
|
258
|
+
post_install_message:
|
256
259
|
rdoc_options: []
|
257
260
|
require_paths:
|
258
261
|
- lib
|
@@ -263,9 +266,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
266
|
version: '0'
|
264
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
268
|
requirements:
|
266
|
-
- - "
|
269
|
+
- - ">"
|
267
270
|
- !ruby/object:Gem::Version
|
268
|
-
version:
|
271
|
+
version: 1.3.1
|
269
272
|
requirements: []
|
270
273
|
rubyforge_project: blacklight
|
271
274
|
rubygems_version: 2.5.2
|