qa 5.5.1 → 5.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/app/controllers/qa/terms_controller.rb +34 -23
- data/app/services/qa/linked_data/authority_url_service.rb +1 -1
- data/app/services/qa/pagination_service.rb +586 -0
- data/config/authorities/linked_data/oclc_fast.json +5 -5
- data/config/initializers/authorities.rb +3 -1
- data/config/initializers/linked_data_authorities.rb +3 -1
- data/config/initializers/mime_types.rb +4 -0
- data/config/routes.rb +4 -0
- data/lib/qa/authorities/local/file_based_authority.rb +3 -2
- data/lib/qa/version.rb +2 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +9 -9
- data/spec/controllers/terms_controller_spec.rb +102 -1
- data/spec/fixtures/authorities/authority_U.yml +13 -0
- data/spec/lib/authorities/linked_data/find_term_spec.rb +6 -6
- data/spec/lib/authorities/{file_based_authority_spec.rb → local/file_based_authority_spec.rb} +11 -0
- data/spec/lib/authorities/{mysql_table_based_authority_spec.rb → local/mysql_table_based_authority_spec.rb} +0 -0
- data/spec/lib/authorities/{table_based_authority_spec.rb → local/table_based_authority_spec.rb} +0 -0
- data/spec/lib/authorities/local_spec.rb +3 -1
- data/spec/services/linked_data/authority_url_service_spec.rb +9 -3
- data/spec/services/pagination_service_spec.rb +682 -0
- metadata +20 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4fcd121b5625fc9bddf0250e2bbf75fb1585a5ad2332b0e9b16c8a927085332
|
4
|
+
data.tar.gz: 323903a339a4ef24c3b50db110dfb4e01a93e33dbb3c95e155fbf3577e84b3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fc0da7aedbcc2519e0f79d2a6ae403eb26e8a730bb4e1babaf33c6864084b5c624ffe8b2b35cb34dc4057e76f88642a85ebe0b41bcda496d9e6b029a6fad6c
|
7
|
+
data.tar.gz: 564e2b850320b6411462236b2dc0ff88d02ce076c33e2abbe4c5d588b9fb8ae5af0382124cd65686bedf132bf42694d965cf68b233348040c2419d947e0398cd
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Questioning Authority
|
2
2
|
|
3
|
-
Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=
|
3
|
+
Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=main)](https://coveralls.io/github/samvera/questioning_authority?branch=main)
|
4
4
|
|
5
5
|
Docs: [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
|
6
6
|
|
@@ -145,6 +145,12 @@ rake ci
|
|
145
145
|
|
146
146
|
Commit your features into a new branch and submit a pull request.
|
147
147
|
|
148
|
+
## Contributing
|
149
|
+
|
150
|
+
If you're working on PR for this project, create a feature branch off of `main`.
|
151
|
+
|
152
|
+
This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera/maintenance/blob/main/templates/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
|
153
|
+
|
148
154
|
## Compatibility
|
149
155
|
|
150
156
|
- Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
|
@@ -169,7 +175,7 @@ Questioning Authority is a Core Component of the Samvera community. The document
|
|
169
175
|
github_changelog_generator --user samvera --project questioning_authority --token YOUR_GITHUB_TOKEN_HERE
|
170
176
|
```
|
171
177
|
|
172
|
-
5. Commit these changes to the
|
178
|
+
5. Commit these changes to the main branch
|
173
179
|
|
174
180
|
6. Run `rake release`
|
175
181
|
|
@@ -4,6 +4,9 @@
|
|
4
4
|
# same methods.
|
5
5
|
|
6
6
|
class Qa::TermsController < ::ApplicationController
|
7
|
+
class_attribute :pagination_service_class
|
8
|
+
self.pagination_service_class = Qa::PaginationService
|
9
|
+
|
7
10
|
before_action :check_vocab_param, :init_authority
|
8
11
|
before_action :check_query_param, only: :search
|
9
12
|
|
@@ -23,14 +26,39 @@ class Qa::TermsController < ::ApplicationController
|
|
23
26
|
def search
|
24
27
|
terms = @authority.method(:search).arity == 2 ? @authority.search(url_search, self) : @authority.search(url_search)
|
25
28
|
cors_allow_origin_header(response)
|
26
|
-
|
29
|
+
respond_to do |wants|
|
30
|
+
wants.json { render json: pagination_service(format: :json, results: terms).build_response }
|
31
|
+
wants.jsonapi { render json: pagination_service(format: :jsonapi, results: terms).build_response }
|
32
|
+
wants.any { render json: pagination_service(format: :json, results: terms).build_response, content_type: json_content_type }
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
36
|
# If the subauthority supports it, return all the information for a given term
|
37
|
+
# Expects id to be part of the request path (e.g. http://my.app/qa/show/auth/subauth/{:id})
|
30
38
|
def show
|
31
39
|
term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
|
32
40
|
cors_allow_origin_header(response)
|
33
|
-
|
41
|
+
respond_to do |wants|
|
42
|
+
wants.json { render json: term }
|
43
|
+
wants.n3 { render json: term }
|
44
|
+
wants.jsonld { render json: term }
|
45
|
+
wants.ntriples { render json: term }
|
46
|
+
wants.any { render json: term, content_type: json_content_type }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# If the subauthority supports it, return all the information for a given term
|
51
|
+
# Expects uri to be a request parameter (e.g. http://my.app/qa/show/auth/subauth?uri={:uri})
|
52
|
+
def fetch
|
53
|
+
term = @authority.method(:find).arity == 2 ? @authority.find(params[:uri], self) : @authority.find(params[:uri])
|
54
|
+
cors_allow_origin_header(response)
|
55
|
+
respond_to do |wants|
|
56
|
+
wants.json { render json: term }
|
57
|
+
wants.n3 { render json: term }
|
58
|
+
wants.jsonld { render json: term }
|
59
|
+
wants.ntriples { render json: term }
|
60
|
+
wants.any { render json: term, content_type: json_content_type }
|
61
|
+
end
|
34
62
|
end
|
35
63
|
|
36
64
|
def check_vocab_param
|
@@ -81,28 +109,11 @@ class Qa::TermsController < ::ApplicationController
|
|
81
109
|
params[:q].gsub("*", "%2A")
|
82
110
|
end
|
83
111
|
|
84
|
-
def
|
85
|
-
|
86
|
-
return 'json' if params[:format].blank?
|
87
|
-
params[:format]
|
88
|
-
end
|
89
|
-
|
90
|
-
def jsonld?
|
91
|
-
format.casecmp?('jsonld')
|
92
|
-
end
|
93
|
-
|
94
|
-
def n3?
|
95
|
-
format.casecmp?('n3')
|
96
|
-
end
|
97
|
-
|
98
|
-
def ntriples?
|
99
|
-
format.casecmp?('ntriples')
|
112
|
+
def json_content_type
|
113
|
+
Mime::Type.lookup_by_extension(:json).to_str
|
100
114
|
end
|
101
115
|
|
102
|
-
def
|
103
|
-
|
104
|
-
return 'text/n3' if n3?
|
105
|
-
return 'application/n-triples' if ntriples?
|
106
|
-
'application/json'
|
116
|
+
def pagination_service(results:, format:)
|
117
|
+
pagination_service_class.new(request: request, results: results, format: format)
|
107
118
|
end
|
108
119
|
end
|
@@ -29,7 +29,7 @@ module Qa
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def combined_substitutions(action_config, action, action_request, request_header)
|
32
|
-
substitutions = request_header.fetch(:replacements, {})
|
32
|
+
substitutions = request_header.fetch(:replacements, {}).clone
|
33
33
|
substitutions[action_request_variable(action_config, action)] = action_request
|
34
34
|
substitutions[action_subauth_variable(action_config)] = action_subauth_variable_value(action_config, request_header)
|
35
35
|
substitutions[action_language_variable(action_config)] = language_value(action_config, request_header)
|