qa-ldf 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +116 -8
- data/VERSION +1 -1
- data/lib/qa/ldf/authorities/fast.rb +2 -2
- data/spec/qa/ldf/authorities/fast_spec.rb +2 -0
- 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: a041941c4cc97c0e5ae28e4b5e903efda839d4a6
|
4
|
+
data.tar.gz: 334742157564ae3694f9dba28268c4671c49316b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 150ef0cca7b17dc7917721228a44d90bebc82504394b1fc1d557bc214f4e874ea18fd348a48ad08be8a6328b2e805a6dd67170fdd4703a5a659af1db56bbf00b
|
7
|
+
data.tar.gz: 51b2d4aff7d73cc6c5921b6f0f4beb57dadc2b8d06df6a82f6c8d1e8e2bcd4a44face76d2c34ffc971333d23a6d340ba49a70c7be122a8f1106bc86187173906
|
data/README.md
CHANGED
@@ -24,12 +24,13 @@ How Does it Work?
|
|
24
24
|
-----------------
|
25
25
|
|
26
26
|
### [TK] Architecture Overview.
|
27
|
+
|
27
28
|
### Mounting and configuring the LDF caching server
|
28
29
|
|
29
30
|
The LDF caching server can run as a mounted application within Rails. To use the caching server, add the following to your `Gemfile`:
|
30
31
|
|
31
32
|
```ruby
|
32
|
-
gem 'qa-ldf', '~>0.
|
33
|
+
gem 'qa-ldf', '~>0.3.0'
|
33
34
|
|
34
35
|
# for now use the active branch of the linked data caching fragment server
|
35
36
|
gem 'ld_cache_fragment', github: 'ActiveTriples/linked-data-fragments', branch: 'feature/multi-dataset'
|
@@ -46,8 +47,46 @@ Rails.application.routes.draw do
|
|
46
47
|
# ...
|
47
48
|
end
|
48
49
|
```
|
50
|
+
And add an `ldf.yml` configuration.
|
51
|
+
|
52
|
+
```yaml
|
53
|
+
# config/ldf.yml
|
54
|
+
development:
|
55
|
+
uri_endpoint: 'http://localhost:3000/ldcache/{?subject}'
|
56
|
+
uri_root: 'http://localhost:3000/ldcache'
|
57
|
+
cache_backend:
|
58
|
+
provider: 'repository'
|
59
|
+
test: &TEST_
|
60
|
+
uri_endpoint: 'http://localhost:3000/ldcache/{?subject}'
|
61
|
+
uri_root: 'http://localhost:3000/ldcache'
|
62
|
+
cache_backend:
|
63
|
+
provider: 'repository'
|
64
|
+
production:
|
65
|
+
uri_endpoint: 'http://localhost:3000/ldcache/{?subject}'
|
66
|
+
uri_root: 'http://localhost:3000/ldcache'
|
67
|
+
cache_backend:
|
68
|
+
provider: 'marmotta'
|
69
|
+
```
|
70
|
+
|
71
|
+
You should now be able to access the ldcache endpoint at `http://example.com/ldcache`. That address will return a dataset description for the root dataset. Queries sent to that endpoint access the transparent cache. For example:
|
72
|
+
|
73
|
+
http://example.com/ldcache/?subject=http://id.loc.gov/authorities/subjects/sh2004002556
|
74
|
+
|
75
|
+
will pass the request through to the Library of Congress on the first request, subsequent requests are retrieved from the cached.
|
76
|
+
|
77
|
+
Finally, configure `Qa::LDF` to aim at the cache server:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
Qa::LDF.configure!(endpoint: LinkedDataFragments::Settings.uri_root)
|
81
|
+
```
|
49
82
|
|
50
|
-
|
83
|
+
In a Hydra app, the best place to put this is in an initializer, e.g. `config/initializers/hydra_config.rb`.
|
84
|
+
|
85
|
+
#### Datasets
|
86
|
+
|
87
|
+
The cache server uses [RDF Datasets](http://www.hydra-cg.com/spec/latest/linked-data-fragments/#datasets) to manage sperate cache spaces. The root dataset is at the server root (`http://example.com/ldcache`, above), and additional datasets are available at any `dataset/*` path following from the root. The `Qa::LDF` authorities are configured to use independent datasets, so each authority corresponds to a cache space of its own. Each dataset provides its own description at its base path, and is queryable with `?subject=` queries as demonstrated above.
|
88
|
+
|
89
|
+
#### LDF caching as an external service.
|
51
90
|
|
52
91
|
The LDF caching server can run independently from your Hydra application as a lightweight, generic [Rack](http://www.rubydoc.info/github/rack/rack/file/SPEC) application, or as a standalone Rails app. You may want to deploy the server in this way so it can run on separate hardware, or to segregate Linked Data "follow your nose" network traffic.
|
53
92
|
|
@@ -64,10 +103,6 @@ With this in your working directory, you can run `$ rackup` to launch a basic se
|
|
64
103
|
|
65
104
|
#### [TK] LDF caching as a Rails app
|
66
105
|
|
67
|
-
### Configuring authorities.
|
68
|
-
#### [TK] Models.
|
69
|
-
#### [TK] Forms.
|
70
|
-
|
71
106
|
Authority Sources
|
72
107
|
----------------------
|
73
108
|
|
@@ -79,8 +114,81 @@ The Library of Congress Name Authority File
|
|
79
114
|
|
80
115
|
Faceted Application of Subject Terminology
|
81
116
|
|
82
|
-
|
83
|
-
|
117
|
+
Configuring authorities
|
118
|
+
-----------------------
|
119
|
+
|
120
|
+
|
121
|
+
### [TK] Models.
|
122
|
+
|
123
|
+
### Forms
|
124
|
+
|
125
|
+
Autocomplete handling for Questioning Authority is provided by Sufia/Hyrax. To this handling, we add a custom dropdown for selecting from multiple authorities in a field.
|
126
|
+
|
127
|
+
#### Adding Controlled Vocabulary Dropdown Options
|
128
|
+
|
129
|
+
To create your own dropdown with authorities you extend the `QASelectService` class. By convention, we place this in `app/services`.
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
# app/services/name_authorities.rb
|
133
|
+
class NameAuthorities < QaSelectService
|
134
|
+
def initialize
|
135
|
+
super('names')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
```
|
139
|
+
|
140
|
+
Initialize the service with the name of a YAML file `names.yml` that contains a list of authorities:
|
141
|
+
|
142
|
+
```yaml
|
143
|
+
terms:
|
144
|
+
- id: /authorities/search/loc/names
|
145
|
+
term: LOC Names
|
146
|
+
active: true
|
147
|
+
- id: /authorities/search/assign_fast/all
|
148
|
+
term: FAST
|
149
|
+
active: true
|
150
|
+
```
|
151
|
+
|
152
|
+
Then in the partials for the input field at `app/views/records/edit_fields/_creator.html.erb`:
|
153
|
+
|
154
|
+
```erb
|
155
|
+
<% name_authorities = Hyrax::NameAuthorities.new %>
|
156
|
+
|
157
|
+
<%=
|
158
|
+
f.input key,
|
159
|
+
as: :multi_value,
|
160
|
+
input_html: {
|
161
|
+
class: 'form-control',
|
162
|
+
data: { 'autocomplete-url' => name_authorities.select_active_options.first.last,
|
163
|
+
'autocomplete' => key } } ,
|
164
|
+
required: f.object.required?(key) %>
|
165
|
+
|
166
|
+
<%= f.input key, collection: name_authorities.select_active_options, label: false %>
|
167
|
+
```
|
168
|
+
|
169
|
+
Implementing Custom Authorities
|
170
|
+
-------------------------------
|
171
|
+
|
172
|
+
Custom (local) authorities can be included by placing a YAML configuration in `config/authorities`. This configuration should specific a list of terms, and give an `id`, `term` name, and `active` flag for each of them. Terms can be set `inactive` to disable them.
|
173
|
+
|
174
|
+
```yaml
|
175
|
+
# config/authorities/moomin_valley.yml
|
176
|
+
terms:
|
177
|
+
- id: http://example.com/moomin
|
178
|
+
term: 'Moomin'
|
179
|
+
active: true
|
180
|
+
- id: http://example.com/moomin_papa
|
181
|
+
term: 'Moomin Papa'
|
182
|
+
active: true
|
183
|
+
- id: http://example.com/moomin_mama
|
184
|
+
term: 'Moomin Mama'
|
185
|
+
active: true
|
186
|
+
- id: http://example.com/snorkmaiden
|
187
|
+
term: 'Snorkmaiden'
|
188
|
+
active: true
|
189
|
+
```
|
190
|
+
|
191
|
+
These terms are now available from Questioning Authority at `/authorities/search/local/moomin_valley'.
|
84
192
|
|
85
193
|
License
|
86
194
|
-------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -11,7 +11,7 @@ module Qa
|
|
11
11
|
# @see http://www.oclc.org/research/themes/data-science/fast.html
|
12
12
|
class FAST < Authority
|
13
13
|
DEFAULT_DATASET_NAME = :fast
|
14
|
-
NAMESPACE = 'http://id.
|
14
|
+
NAMESPACE = 'http://id.worldcat.org/fast/'.freeze
|
15
15
|
|
16
16
|
register_namespace(namespace: NAMESPACE,
|
17
17
|
klass: self)
|
@@ -35,7 +35,7 @@ module Qa
|
|
35
35
|
##
|
36
36
|
# Uses the LC AssignFast 'all' subauthority as the search provider
|
37
37
|
def search_service
|
38
|
-
@search_service ||=
|
38
|
+
@search_service ||= SearchService.new do |service|
|
39
39
|
service.namespace = NAMESPACE
|
40
40
|
service.parent_service =
|
41
41
|
Qa::Authorities::AssignFast.subauthority_for('all')
|