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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7205f6d228b7548f6dc39ce9781dd4b591d2f4c5e56d5b2bcc4189b3c9005f7e
4
- data.tar.gz: 5cdce31ba635c298e5da88cfc01cc86237426a45a1b8ccf3095c316c1eb7b8f4
3
+ metadata.gz: b4fcd121b5625fc9bddf0250e2bbf75fb1585a5ad2332b0e9b16c8a927085332
4
+ data.tar.gz: 323903a339a4ef24c3b50db110dfb4e01a93e33dbb3c95e155fbf3577e84b3db
5
5
  SHA512:
6
- metadata.gz: 39259b1eb80bcaab90653152302e38b853d24ecf1ff9bb46ca16afe637a35fe53b7d4abcf85ee2cc7ee7550b57bb6e7505f558adb10792056ea5573d7607b025
7
- data.tar.gz: 3a748c62a1aa1b05d0f0b768af0a03ea2d2c6918c892c40cfc7ab1fdb619866053fb272d16b20a3241b9024c5d1dde8521fde108c36e33b59d55037d5d618e96
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=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
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 master branch
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
- render json: terms
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
- render json: term, content_type: content_type_for_format
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 format
85
- return 'json' unless params.key?(:format)
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 content_type_for_format
103
- return 'application/ld+json' if jsonld?
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)