linked_rails 0.0.4.pre.gb254a2893 → 0.0.4.pre.gc3dfc6914
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/linked_rails/bulk_controller.rb +2 -8
- data/app/models/linked_rails/actions/item.rb +1 -1
- data/app/models/linked_rails/collection/view.rb +3 -4
- data/app/models/linked_rails/form/field/file_input.rb +1 -5
- data/app/models/linked_rails/form/field_factory.rb +7 -1
- data/app/models/linked_rails/manifest.rb +8 -8
- data/app/models/linked_rails/menus/item.rb +1 -1
- data/app/models/linked_rails/menus/list.rb +3 -14
- data/app/policies/linked_rails/collection_policy.rb +0 -1
- data/app/serializers/linked_rails/collection/view_serializer.rb +0 -1
- data/app/workers/linked_rails/invalidation_stream_worker.rb +1 -1
- data/lib/linked_rails/helpers/resource_helper.rb +1 -4
- data/lib/linked_rails/iri_mapper.rb +1 -1
- data/lib/linked_rails/model/cacheable.rb +4 -2
- data/lib/linked_rails/model/iri.rb +0 -1
- data/lib/linked_rails/params_parser.rb +4 -14
- data/lib/linked_rails/storage.rb +1 -2
- data/lib/linked_rails.rb +2 -5
- metadata +2 -3
- data/lib/linked_rails/url.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c46a1b1dd79f52ab737125d44fbf850d58ce90cfedfda01fc41f09f23479afd
|
4
|
+
data.tar.gz: 21772f28097f492ea3593f79e0c1ecaddaacdb91e04e62ac3c08497aacb1afbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d17d949a1683172351c183f24be5174d36a96dba396a417a58448c5d72a22a5e833d7db8ca0056ec08cc25ddbc2ef5ac5da02a4bd7598b279336fb46fe95c47f
|
7
|
+
data.tar.gz: ddb938f6a9d7c3b3bc148c5bc6153318f0508eb6c57f101ee47434c900709538caf3dde57ae00b0813b95a09ef109d534b6c2fc4d2447e1ee5bc4c5d7e0ab5fe
|
@@ -98,8 +98,6 @@ module LinkedRails
|
|
98
98
|
params = param.permit(:include, :iri)
|
99
99
|
params[:iri] = URI(params[:iri])
|
100
100
|
params
|
101
|
-
rescue URI::InvalidURIError
|
102
|
-
params.except(:iri)
|
103
101
|
end
|
104
102
|
|
105
103
|
def resource_response_body(iri, rack_body, status)
|
@@ -163,17 +161,13 @@ module LinkedRails
|
|
163
161
|
|
164
162
|
resource_response(
|
165
163
|
iri,
|
166
|
-
body:
|
164
|
+
body: include && status == 200 ? resource_body(resource) : nil,
|
167
165
|
cache: resource_cache_control(resource.try(:cacheable?), status, resource_policy),
|
168
166
|
language: I18n.locale,
|
169
167
|
status: status
|
170
168
|
)
|
171
169
|
end
|
172
170
|
|
173
|
-
def response_from_resource_body(include, _iri, resource, status)
|
174
|
-
include && status == 200 ? resource_body(resource) : nil
|
175
|
-
end
|
176
|
-
|
177
171
|
def term_from_vocab(iri)
|
178
172
|
vocab = Vocab.for(iri)
|
179
173
|
tag = iri.to_s.split(vocab.to_s).last
|
@@ -251,7 +245,7 @@ module LinkedRails
|
|
251
245
|
|
252
246
|
def sanitized_relative_path(iri) # rubocop:disable Metrics/AbcSize
|
253
247
|
iri.path = "#{iri.path}/" unless iri.path&.ends_with?('/')
|
254
|
-
uri = URI(LinkedRails.iri.path.
|
248
|
+
uri = URI(LinkedRails.iri.path.present? ? iri.to_s.split("#{LinkedRails.iri.path}/").last : iri)
|
255
249
|
|
256
250
|
[uri.path, uri.query].compact.join('?')
|
257
251
|
end
|
@@ -187,7 +187,7 @@ module LinkedRails
|
|
187
187
|
|
188
188
|
def target_url_fallback # rubocop:disable Metrics/AbcSize
|
189
189
|
base = (resource.try(:singular_resource?) ? resource.singular_iri : resource.iri).dup
|
190
|
-
base.path = "#{base.path
|
190
|
+
base.path = "#{base.path}/#{target_path}" if target_path.present?
|
191
191
|
base.query = Rack::Utils.parse_nested_query(base.query).merge(target_query).to_param if target_query.present?
|
192
192
|
base
|
193
193
|
end
|
@@ -8,9 +8,8 @@ module LinkedRails
|
|
8
8
|
include LinkedRails::Model
|
9
9
|
|
10
10
|
attr_accessor :collection, :filter
|
11
|
-
delegate :apply_scope, :association_base, :association_class, :
|
12
|
-
:
|
13
|
-
to: :collection
|
11
|
+
delegate :apply_scope, :association_base, :association_class, :default_page_size, :display, :include_members,
|
12
|
+
:parent, :policy, :total_page_count, :unfiltered_collection, :user_context, to: :collection
|
14
13
|
delegate :count, to: :members
|
15
14
|
|
16
15
|
alias id iri
|
@@ -43,7 +42,7 @@ module LinkedRails
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def preview_includes
|
46
|
-
include_members ? {
|
45
|
+
include_members ? {member_sequence: :members} : %i[member_sequence]
|
47
46
|
end
|
48
47
|
|
49
48
|
def title
|
@@ -52,7 +52,13 @@ module LinkedRails
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def attr_column(name)
|
55
|
-
|
55
|
+
column_model =
|
56
|
+
if model_class.is_delegated_attribute?(name)
|
57
|
+
model_class.class_for_delegated_attribute(name)
|
58
|
+
else
|
59
|
+
model_class
|
60
|
+
end
|
61
|
+
column_model.column_for_attribute(name)
|
56
62
|
end
|
57
63
|
|
58
64
|
def attr_to_datatype # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
@@ -9,7 +9,7 @@ module LinkedRails
|
|
9
9
|
Storage.hset(
|
10
10
|
:persistent,
|
11
11
|
:manifest,
|
12
|
-
|
12
|
+
LinkedRails.iri.to_s => web_manifest.to_json
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
@@ -41,7 +41,7 @@ module LinkedRails
|
|
41
41
|
def blob_preview_iri
|
42
42
|
return unless ActiveStorage::Blob.service.present?
|
43
43
|
|
44
|
-
|
44
|
+
LinkedRails.iri(path: 'rails/active_storage/blobs/redirect/{signed_id}/preview')
|
45
45
|
end
|
46
46
|
|
47
47
|
def blob_upload_iri
|
@@ -138,7 +138,7 @@ module LinkedRails
|
|
138
138
|
|
139
139
|
def web_manifest_sw_section
|
140
140
|
{
|
141
|
-
src: "#{scope
|
141
|
+
src: "#{scope}/sw.js",
|
142
142
|
scope: scope
|
143
143
|
}
|
144
144
|
end
|
@@ -161,19 +161,19 @@ module LinkedRails
|
|
161
161
|
|
162
162
|
class << self
|
163
163
|
def destroy(iri)
|
164
|
-
Storage.hdel(:persistent, :manifest,
|
164
|
+
Storage.hdel(:persistent, :manifest, iri)
|
165
165
|
end
|
166
166
|
|
167
167
|
def move(from, to)
|
168
168
|
Storage.hset(
|
169
169
|
:persistent,
|
170
|
-
:
|
171
|
-
|
170
|
+
:redirect,
|
171
|
+
"#{from}*" => to
|
172
172
|
)
|
173
173
|
|
174
|
-
data = Storage.hget(:persistent, :manifest,
|
174
|
+
data = Storage.hget(:persistent, :manifest, from)
|
175
175
|
|
176
|
-
Storage.hset(:persistent, :manifest,
|
176
|
+
Storage.hset(:persistent, :manifest, to, data) if data
|
177
177
|
|
178
178
|
destroy(from)
|
179
179
|
end
|
@@ -49,8 +49,9 @@ module LinkedRails
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def menu_item(tag, options) # rubocop:disable Metrics/AbcSize
|
52
|
-
|
53
|
-
|
52
|
+
if options[:policy].present?
|
53
|
+
return unless resource_policy(options[:policy_resource]).send(options[:policy], *options[:policy_arguments])
|
54
|
+
end
|
54
55
|
options[:label_params] ||= {}
|
55
56
|
options[:label_params][:default] ||= ["menus.default.#{tag}".to_sym, tag.to_s.capitalize]
|
56
57
|
options[:label] ||= default_label(tag, options)
|
@@ -59,10 +60,6 @@ module LinkedRails
|
|
59
60
|
LinkedRails.menus_item_class.new(resource: resource, tag: tag, parent: self, **options)
|
60
61
|
end
|
61
62
|
|
62
|
-
def policy_verdict(policy, options)
|
63
|
-
policy.send(options[:policy], *options[:policy_arguments])
|
64
|
-
end
|
65
|
-
|
66
63
|
def resource_policy(policy_resource)
|
67
64
|
policy_resource ||= resource
|
68
65
|
policy_resource = instance_exec(&policy_resource) if policy_resource.respond_to?(:call)
|
@@ -72,14 +69,6 @@ module LinkedRails
|
|
72
69
|
@resource_policy[policy_resource] ||= Pundit.policy(user_context, policy_resource)
|
73
70
|
end
|
74
71
|
|
75
|
-
def show_menu_item?(_tag, options)
|
76
|
-
return true if options[:policy].blank?
|
77
|
-
|
78
|
-
policy = resource_policy(options[:policy_resource])
|
79
|
-
|
80
|
-
policy_verdict(policy, options)
|
81
|
-
end
|
82
|
-
|
83
72
|
def iri_template
|
84
73
|
base_template = resource.send(resource.try(:singular_resource?) ? :singular_iri_template : :iri_template)
|
85
74
|
|
@@ -58,10 +58,7 @@ module LinkedRails
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def new_resource_from_parent
|
61
|
-
if requested_resource.is_a?(
|
62
|
-
requested_resource.is_a?(LinkedRails.collection_view_class)
|
63
|
-
return requested_resource.child_resource
|
64
|
-
end
|
61
|
+
return requested_resource.child_resource if requested_resource.is_a?(Collection)
|
65
62
|
|
66
63
|
parent_resource.build_child(
|
67
64
|
controller_class,
|
@@ -38,7 +38,7 @@ module LinkedRails
|
|
38
38
|
params = Rails.application.routes.recognize_path(iri.to_s, method: method)
|
39
39
|
|
40
40
|
route_params_to_opts(params.merge(query), iri.to_s)
|
41
|
-
rescue ActionController::RoutingError
|
41
|
+
rescue ActionController::RoutingError
|
42
42
|
EMPTY_IRI_OPTS.dup
|
43
43
|
end
|
44
44
|
|
@@ -17,6 +17,8 @@ module LinkedRails
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
|
20
|
+
private
|
21
|
+
|
20
22
|
def publish_create
|
21
23
|
publish_message('io.ontola.transactions.Created')
|
22
24
|
end
|
@@ -29,14 +31,14 @@ module LinkedRails
|
|
29
31
|
publish_message('io.ontola.transactions.Deleted')
|
30
32
|
end
|
31
33
|
|
32
|
-
private
|
33
|
-
|
34
34
|
def publish_message(type)
|
35
35
|
LinkedRails::InvalidationStreamWorker.perform_now(type, iri.to_s, self.class.iri.to_s)
|
36
36
|
rescue StandardError
|
37
37
|
LinkedRails::InvalidationStreamWorker.perform_later(type, iri.to_s, self.class.iri.to_s)
|
38
38
|
end
|
39
39
|
|
40
|
+
private
|
41
|
+
|
40
42
|
def should_publish_changes
|
41
43
|
cacheable? && !Rails.env.test?
|
42
44
|
end
|
@@ -118,13 +118,9 @@ module LinkedRails
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def parse_attribute(klass, field_options, value)
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
def parse_attribute_value(klass, field_options, value)
|
125
|
-
return nil if value == Vocab.libro[:null]
|
121
|
+
parsed_value = parse_enum_attribute(klass, field_options.key, value) || value
|
126
122
|
|
127
|
-
|
123
|
+
[field_options.key, parsed_value.to_s]
|
128
124
|
end
|
129
125
|
|
130
126
|
def parse_enum_attribute(klass, key, value)
|
@@ -137,15 +133,9 @@ module LinkedRails
|
|
137
133
|
|
138
134
|
def parse_iri_param(iri, reflection)
|
139
135
|
key = foreign_key_for_reflection(reflection)
|
140
|
-
|
136
|
+
value = parse_iri_param_value(iri, reflection) if key
|
141
137
|
|
142
|
-
|
143
|
-
[key, nil]
|
144
|
-
else
|
145
|
-
value = parse_iri_param_value(iri, reflection)
|
146
|
-
|
147
|
-
[key, value.to_s] if value
|
148
|
-
end
|
138
|
+
[key, value.to_s] if value
|
149
139
|
end
|
150
140
|
|
151
141
|
def parse_iri_param_value(iri, reflection)
|
data/lib/linked_rails/storage.rb
CHANGED
data/lib/linked_rails.rb
CHANGED
@@ -54,10 +54,8 @@ module LinkedRails
|
|
54
54
|
@@scheme ||= Rails.application.routes.default_url_options[:protocol] || :http # rubocop:disable Style/ClassVars
|
55
55
|
end
|
56
56
|
|
57
|
-
def iri(**
|
58
|
-
|
59
|
-
opts[:path] = opts[:path].presence || '/'
|
60
|
-
RDF::URI.new(**opts)
|
57
|
+
def iri(**opts)
|
58
|
+
RDF::URI.new(**{scheme: LinkedRails.scheme, host: LinkedRails.host}.merge(opts))
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
@@ -108,5 +106,4 @@ require 'linked_rails/routes'
|
|
108
106
|
require 'linked_rails/serializer'
|
109
107
|
require 'linked_rails/translate'
|
110
108
|
require 'linked_rails/railtie'
|
111
|
-
require 'linked_rails/url'
|
112
109
|
require 'linked_rails/storage'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linked_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.pre.
|
4
|
+
version: 0.0.4.pre.gc3dfc6914
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Dingemans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_response
|
@@ -429,7 +429,6 @@ files:
|
|
429
429
|
- lib/linked_rails/translate.rb
|
430
430
|
- lib/linked_rails/types/iri_type.rb
|
431
431
|
- lib/linked_rails/uri_template.rb
|
432
|
-
- lib/linked_rails/url.rb
|
433
432
|
- lib/linked_rails/version.rb
|
434
433
|
- lib/linked_rails/vocab.rb
|
435
434
|
- lib/nill_class_renderer.rb
|