dbla 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +43 -16
- data/Rakefile +3 -13
- data/lib/dbla/abstract_response.rb +3 -7
- data/lib/dbla/version.rb +1 -1
- data/lib/tasks/dbla_key.rake +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec4c36f34bce118a8f7742e32040622e68c76d8
|
4
|
+
data.tar.gz: 44f112fa2dd872c43aaa9c93394c5f995a4ce733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fef1b5003cbb9895b39ec794e9eece9e5dfeb4bfd173c7d48e40fc9a80f9b1007b82fb657a18ae408595a2d2533140fd9ad62bb4b4c7dae72647e1e3b72155a5
|
7
|
+
data.tar.gz: 0b86c1b40dd2cae506feb38ec78dcae7e53d048e6bd6160895e75eb80bcae7ae65a4816bf6909f6032afa20633e4b4c1f86316f3aa7f09722659d770d083cdc3
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,36 +1,60 @@
|
|
1
1
|
= Dbla
|
2
2
|
|
3
|
+
Access [DPLA](http://dp.la)'s API via the [Blacklight](http://projectblacklight.org/) search interface.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
3
7
|
1. Generate a Blacklight app:
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
|
9
|
+
```console
|
10
|
+
$ rails new search_app -m https://raw.github.com/projectblacklight/blacklight/master/template.demo.rb
|
11
|
+
$ cd search_app
|
7
12
|
```
|
8
13
|
|
9
14
|
2. Add the dbla gem to the Gemfile:
|
10
|
-
|
15
|
+
|
16
|
+
```ruby
|
11
17
|
gem "dbla"
|
12
18
|
```
|
13
19
|
and bundle install.
|
14
20
|
|
15
21
|
3. Run the dbla generators:
|
16
|
-
```
|
17
|
-
rails g dbla:install
|
18
|
-
```
|
19
22
|
|
20
|
-
|
23
|
+
```console
|
24
|
+
$ rails g dbla:install
|
21
25
|
```
|
22
|
-
|
23
|
-
|
26
|
+
|
27
|
+
4. Create a config/dpla.yml file of the form
|
28
|
+
|
29
|
+
```yml
|
30
|
+
api_key: <your-api-key
|
31
|
+
api_email: <your-email-that-you-used-for-your-api-key>
|
24
32
|
url: http://api.dp.la/v2/
|
25
33
|
```
|
34
|
+
|
35
|
+
Find out how to [request your DPLA API key](http://dp.la/info/developers/codex/policies/#get-a-key)
|
36
|
+
|
26
37
|
This file can be stubbed out with a rake task:
|
38
|
+
|
39
|
+
```console
|
40
|
+
$ rake dbla:key:get email=my.email@my.server.org
|
41
|
+
# get your email from DPLA
|
42
|
+
$ rake dbla:key:config key=YOURKEY00000000
|
27
43
|
```
|
28
|
-
|
29
|
-
# get your email
|
30
|
-
rake dbla:key:config key=YOURKEY00000000
|
31
|
-
```
|
44
|
+
|
32
45
|
5. Configure the CatalogController
|
46
|
+
|
47
|
+
Replace the following code in your CatalogController:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# solr field configuration for search results/index views
|
51
|
+
config.index.title_field = 'title_display'
|
52
|
+
config.index.display_type_field = 'format'
|
33
53
|
```
|
54
|
+
|
55
|
+
With the Dbla options.
|
56
|
+
|
57
|
+
```ruby
|
34
58
|
config.repository_class = Dbla::Repository
|
35
59
|
config.document_model = Item
|
36
60
|
config.response_model = Dbla::Response
|
@@ -42,8 +66,11 @@ rake dbla:key:config key=YOURKEY00000000
|
|
42
66
|
```
|
43
67
|
|
44
68
|
6. Fire it up!
|
45
|
-
``` rails s```
|
46
69
|
|
47
|
-
|
70
|
+
```console
|
71
|
+
$ rails s
|
72
|
+
```
|
73
|
+
|
74
|
+
Open your browser and go to [localhost:3000](http://localhost:3000).
|
48
75
|
|
49
76
|
Search for kittens!
|
data/Rakefile
CHANGED
@@ -14,21 +14,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
20
|
Bundler::GemHelper.install_tasks
|
23
21
|
|
24
|
-
require '
|
25
|
-
|
26
|
-
Rake::TestTask.new(:test) do |t|
|
27
|
-
t.libs << 'lib'
|
28
|
-
t.libs << 'test'
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = false
|
31
|
-
end
|
32
|
-
|
22
|
+
require 'rspec/core/rake_task'
|
33
23
|
|
34
|
-
task default: :
|
24
|
+
task default: 'app:spec'
|
@@ -14,15 +14,11 @@ module Dbla
|
|
14
14
|
header['params'] || request_params
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
@start
|
19
|
-
end
|
20
|
-
|
21
|
-
def rows
|
22
|
-
@limit
|
23
|
-
end
|
17
|
+
alias_method :rows, :limit
|
24
18
|
|
25
19
|
def sort
|
20
|
+
# REVIEW: There are mixed style key accesses (strings and symbols);
|
21
|
+
# Could/Should this be "normalized"?
|
26
22
|
params[:sort]
|
27
23
|
end
|
28
24
|
|
data/lib/dbla/version.rb
CHANGED
data/lib/tasks/dbla_key.rake
CHANGED
@@ -4,9 +4,9 @@ module Dbla
|
|
4
4
|
module ApiKey
|
5
5
|
RESOURCE = 'http://api.dp.la/v2/api_key/'.freeze
|
6
6
|
USAGE = {
|
7
|
-
get: " rake
|
8
|
-
config: " rake
|
9
|
-
report: " rake
|
7
|
+
get: " rake dbla:key:get email=YOUR.EMAIL@SERVER.ORG",
|
8
|
+
config: " rake dbla:key:config key=YOURKEY000000000000000000000000",
|
9
|
+
report: " rake dbla:key:report",
|
10
10
|
}
|
11
11
|
def self.usage(key=:all)
|
12
12
|
puts "Usage:"
|
@@ -18,7 +18,7 @@ namespace :dbla do
|
|
18
18
|
namespace :key do
|
19
19
|
task get: :environment do
|
20
20
|
if ENV['email']
|
21
|
-
uri = URI(RESOURCE + email)
|
21
|
+
uri = URI(Dbla::ApiKey::RESOURCE + ENV['email'])
|
22
22
|
Net::HTTP.start(uri.host, uri.port) do |http|
|
23
23
|
request = Net::HTTP::Post.new uri
|
24
24
|
response = http.request request
|
@@ -43,8 +43,10 @@ namespace :dbla do
|
|
43
43
|
end
|
44
44
|
task config: :environment do
|
45
45
|
if ENV['key']
|
46
|
-
|
47
|
-
|
46
|
+
config = YAML.load(File.read(Dbla.config_path))
|
47
|
+
config['api_key'] = ENV['key']
|
48
|
+
open(Dbla.config_path,'w') do |blob|
|
49
|
+
blob.write YAML.dump(config)
|
48
50
|
end
|
49
51
|
else
|
50
52
|
Dbla::ApiKey.usage(:config)
|