qa 5.5.2 → 5.8.1
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/README.md +8 -2
- data/app/controllers/qa/terms_controller.rb +34 -23
- data/app/services/qa/pagination_service.rb +586 -0
- 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 +1 -1
- data/spec/controllers/terms_controller_spec.rb +102 -1
- data/spec/fixtures/authorities/authority_U.yml +13 -0
- 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/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: a7529be1fa8e0db065216d3fd303c3db02c739ede3ffed6ca0d56cda3b0d8bc5
|
4
|
+
data.tar.gz: ae2e1179e435d2cc82f6c8e068c413cfb6cf0e3fdee0a478fff4eccfff82b64c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05b1ea7d2611b2fd349d070171a9856059ae0c0a5ea8dfab12fcdddab55e76b6a0939c6e451e3c7852f6bdf782e3aff8f2dda0c2f8c043a2a61c9407c7a76fce
|
7
|
+
data.tar.gz: 0454fd9d3ce8663f9cc3e00e4a922cca3b33c6657213448f40de9b7601fb553b236dd822f1b8e5fb196ca91b1e7973134950003f52f4d33153c1e8e6c36b0517
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Questioning Authority
|
2
2
|
|
3
|
-
Code: [](http://badge.fury.io/rb/qa) [](https://circleci.com/gh/samvera/questioning_authority) [](http://badge.fury.io/rb/qa) [](https://circleci.com/gh/samvera/questioning_authority) [](https://coveralls.io/github/samvera/questioning_authority?branch=main)
|
4
4
|
|
5
5
|
Docs: [](./CONTRIBUTING.md) [](./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
|