quick_search-contentdm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +66 -0
- data/Rakefile +37 -0
- data/app/searchers/quick_search/contentdm_searcher.rb +91 -0
- data/config/contentdm_config.yml +16 -0
- data/config/initializers/contentdm_searcher_config.rb +9 -0
- data/config/locales/en.yml +10 -0
- data/config/routes.rb +2 -0
- data/lib/quick_search-contentdm.rb +5 -0
- data/lib/quick_search-contentdm/engine.rb +5 -0
- data/lib/quick_search-contentdm/version.rb +3 -0
- data/lib/tasks/quick_search_contentdm_tasks.rake +4 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b2c4541c32202ee5b4a3fec7ace453100b1dcc0
|
4
|
+
data.tar.gz: 0bcfff752a0859359db6a326f060c076020f956c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2337c25a7f3b4aeb8b815699a844a5806d27c41e5d4b1306f33a2783ba09442860bc93223b1d2e9cf6df13632ba20fe1bbf634f12cfa4620a93e2d8a29873828
|
7
|
+
data.tar.gz: e2575d4a3faa49c5e8278975051cbc131b5c84d966dbc1e310315005c2a975a5e293a1a98875ef9739789eee9b0b1c882d6254dc38f5995df8ea52176eb26e38
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Chad Nelson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Quick Search Contentdm Plugin
|
2
|
+
A plugin for [Quick Search](http://www.lib.ncsu.edu/reports/quicksearch) that allows you to search a ContentDM. The ContentDM instance's API must be publicly available.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
Add the gem to your quick search application's `Gemfile` a then follow the instructions outlined in the Quick Search [Configuring Searchers](https://github.com/NCSU-Libraries/quick_search/blob/master/docs/configuration.md#configuring-searchers) docs.
|
6
|
+
|
7
|
+
### Configuration options
|
8
|
+
This plugin provides a few configuration points.
|
9
|
+
|
10
|
+
`api_url`: _Required_ Base URL to your contentDM backend server where your ContentDM Api is publicly available.
|
11
|
+
|
12
|
+
`records_url`: _Required_ Base URL to your public facing ContentDM site.
|
13
|
+
|
14
|
+
`custom_sort`: _Optional_ Field you want records sorted by. Defaults to 'relevance'
|
15
|
+
|
16
|
+
`collections`: _Optional_ A list of collectinos you would lke the search limited to. By default it searches all colelctions except unpublished colelctions.
|
17
|
+
|
18
|
+
_Example Config_
|
19
|
+
```yaml
|
20
|
+
defaults: &defaults
|
21
|
+
api_url: "http://backend.contentdm.org"
|
22
|
+
records_url: "http://frontend.contentdm.org"
|
23
|
+
sort: title
|
24
|
+
collections:
|
25
|
+
- collection1
|
26
|
+
- collection2
|
27
|
+
- collections3
|
28
|
+
|
29
|
+
development:
|
30
|
+
<<: *defaults
|
31
|
+
|
32
|
+
test:
|
33
|
+
<<: *defaults
|
34
|
+
|
35
|
+
staging:
|
36
|
+
<<: *defaults
|
37
|
+
|
38
|
+
production:
|
39
|
+
<<: *defaults
|
40
|
+
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Installation
|
46
|
+
Add this line to your application's Gemfile:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
gem 'quick_search-contentdm'
|
50
|
+
```
|
51
|
+
|
52
|
+
And then execute:
|
53
|
+
```bash
|
54
|
+
$ bundle install
|
55
|
+
```
|
56
|
+
|
57
|
+
Or install it yourself as:
|
58
|
+
```bash
|
59
|
+
$ gem install quick_search-contentdm
|
60
|
+
```
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
Contribution directions go here.
|
64
|
+
|
65
|
+
## License
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'QuickSearchContentdm'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module QuickSearch
|
2
|
+
class ContentdmSearcher < QuickSearch::Searcher
|
3
|
+
|
4
|
+
def search
|
5
|
+
url = base_url + parameters.to_query
|
6
|
+
Rails.logger.info "ContenDM query url: #{url}"
|
7
|
+
raw_response = @http.get(url)
|
8
|
+
@response = JSON.parse(raw_response.body)
|
9
|
+
end
|
10
|
+
|
11
|
+
def results
|
12
|
+
if results_list
|
13
|
+
results_list
|
14
|
+
else
|
15
|
+
@results_list = []
|
16
|
+
@response['records'].each do |record|
|
17
|
+
result = OpenStruct.new
|
18
|
+
|
19
|
+
result.title = title(record)
|
20
|
+
result.link = link(record)
|
21
|
+
result.description = description(record)
|
22
|
+
result.thumbnail = thumbnail(record)
|
23
|
+
|
24
|
+
|
25
|
+
@results_list << result
|
26
|
+
end
|
27
|
+
@results_list
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def base_url
|
35
|
+
config['api_url'] + "/dmwebservices/index.php?"
|
36
|
+
end
|
37
|
+
|
38
|
+
def parameters
|
39
|
+
{
|
40
|
+
'q' => "dmQuery/#{collections_to_search}/CISOSEARCHALL^#{http_request_queries['not_escaped']}^all^and/" +
|
41
|
+
"title!descri/#{sort}/#{@per_page}/#{@offset}/1/0/0/0/0/0/json",
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def title(record)
|
46
|
+
record['title']
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def link(record)
|
51
|
+
"#{config['records_url']}/cdm/#{object_type(record)}/collection#{record['collection']}/id/#{record['pointer']}"
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def description(record)
|
56
|
+
record['description']
|
57
|
+
end
|
58
|
+
|
59
|
+
def object_type(record)
|
60
|
+
if record['filetype'] == 'cpd'
|
61
|
+
'compoundobject'
|
62
|
+
else
|
63
|
+
'singleitem'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def thumbnail(record)
|
68
|
+
"#{config['records_url']}/utils/getthumbnail/collection#{record['collection']}/id/#{record['pointer']}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def sort
|
72
|
+
if config.has_key? 'custom_sort'
|
73
|
+
"#{config['custom_sort']}"
|
74
|
+
else
|
75
|
+
"nosort"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def collections_to_search
|
80
|
+
if config.has_key? 'collections'
|
81
|
+
config['collections'].join('!')
|
82
|
+
else
|
83
|
+
'all'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def config
|
88
|
+
QuickSearch::Engine::CONTENTDM_CONFIG
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#Try to load a local version of the config file if it exists - expected to be in quicksearch_root/config/searchers/contentdm_config.yml
|
2
|
+
|
3
|
+
if File.exists?(File.join(Rails.root, "/config/searchers/contentdm_config.yml"))
|
4
|
+
config_file = File.join Rails.root, "/config/searchers/contentdm_config.yml"
|
5
|
+
else
|
6
|
+
# otherwise load the default config file
|
7
|
+
config_file = File.expand_path("../../contentdm_config.yml", __FILE__)
|
8
|
+
end
|
9
|
+
QuickSearch::Engine::CONTENTDM_CONFIG = YAML.load_file(config_file)[Rails.env]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
en:
|
2
|
+
contentdm_search:
|
3
|
+
display_name: "Temple Digital Collections"
|
4
|
+
short_display_name: "Digital Collections"
|
5
|
+
see_all_message: "Find more Temple Digital Collections"
|
6
|
+
search_form_placeholder: "Search for collections"
|
7
|
+
module_callout: "Search for collections"
|
8
|
+
error_service_message: "searching Temple Digital Collections"
|
9
|
+
no_results_service_message: "a different search for digital collections"
|
10
|
+
|
data/config/routes.rb
ADDED
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quick_search-contentdm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chad Nelson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: quick_search-core
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Plugin for NCSU Quicksearch to search contentDM
|
56
|
+
email:
|
57
|
+
- chad.nelson@temple.edu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/searchers/quick_search/contentdm_searcher.rb
|
66
|
+
- config/contentdm_config.yml
|
67
|
+
- config/initializers/contentdm_searcher_config.rb
|
68
|
+
- config/locales/en.yml
|
69
|
+
- config/routes.rb
|
70
|
+
- lib/quick_search-contentdm.rb
|
71
|
+
- lib/quick_search-contentdm/engine.rb
|
72
|
+
- lib/quick_search-contentdm/version.rb
|
73
|
+
- lib/tasks/quick_search_contentdm_tasks.rake
|
74
|
+
homepage: https://github.com/tulibraries/quick_search-contentdm
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.8
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Plugin for NCSU Quicksearch to search contentDM
|
98
|
+
test_files: []
|