linked_rails 0.0.4.pre.g9b7bc9073 → 0.0.4.pre.g14b377f91
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad7cb510016bb7b42c2b472031bb0eebcd976cd93f0a20cfca9f70b87271a4c9
|
4
|
+
data.tar.gz: 5965b0ffb3715273ed446f29d3544124145b06162a66c866f899731c85819acb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f82190e18c85082737f30ff5ed4b5ef1e13cf90b5a3b2c8941589a8812eb79dbf34948005a28895c6aa12884134c66e869258374759506bb7b1642829072773
|
7
|
+
data.tar.gz: 3abb5a9fe9fedde3040d55d89f2a3af74d13e97f93b07dca126a6dcbebcfd27309cee9548b0b95b09dec84cdc6519acd6f44c8e11a4d978e47eca82c4ee88cca
|
@@ -5,6 +5,31 @@ module LinkedRails
|
|
5
5
|
include ActiveModel::Model
|
6
6
|
include LinkedRails::Model
|
7
7
|
|
8
|
+
MANIFEST_KEY = 'cache:Manifest'
|
9
|
+
CACHE_DB = ENV.fetch('PERSISTENT_REDIS_DATABASE', '6')
|
10
|
+
|
11
|
+
def save
|
12
|
+
self.class.redis_client.hset(
|
13
|
+
MANIFEST_KEY,
|
14
|
+
{
|
15
|
+
LinkedRails.iri.to_s => web_manifest.to_json
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def web_manifest
|
21
|
+
web_manifest_base.merge(
|
22
|
+
ontola: web_manifest_ontola_section,
|
23
|
+
serviceworker: web_manifest_sw_section
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def allowed_external_sources
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
8
33
|
def app_name
|
9
34
|
Rails.application.railtie_name.chomp('_application').humanize
|
10
35
|
end
|
@@ -17,8 +42,27 @@ module LinkedRails
|
|
17
42
|
'#eef0f2'
|
18
43
|
end
|
19
44
|
|
45
|
+
def blob_preview_iri
|
46
|
+
return unless ActiveStorage::Blob.service.present?
|
47
|
+
|
48
|
+
LinkedRails.iri(path: 'rails/active_storage/blobs/redirect/{signed_id}/preview')
|
49
|
+
end
|
50
|
+
|
51
|
+
def blob_upload_iri
|
52
|
+
return unless ActiveStorage::Blob.service.present?
|
53
|
+
|
54
|
+
LinkedRails.iri(path: 'rails/active_storage/direct_uploads')
|
55
|
+
end
|
56
|
+
|
20
57
|
def css_class; end
|
21
58
|
|
59
|
+
def csp_entries
|
60
|
+
{
|
61
|
+
connectSrc: [ActiveStorage::Blob.service.try(:bucket)&.url].compact,
|
62
|
+
scriptSrc: [ActiveStorage::Blob.service.try(:bucket)&.url].compact
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
22
66
|
def header_background
|
23
67
|
:primary
|
24
68
|
end
|
@@ -27,17 +71,16 @@ module LinkedRails
|
|
27
71
|
:white
|
28
72
|
end
|
29
73
|
|
30
|
-
def
|
31
|
-
[
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
]
|
74
|
+
def icons
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
def lang
|
79
|
+
:nl
|
37
80
|
end
|
38
81
|
|
39
82
|
def scope
|
40
|
-
|
83
|
+
LinkedRails.iri.to_s
|
41
84
|
end
|
42
85
|
|
43
86
|
def site_theme_color
|
@@ -52,43 +95,46 @@ module LinkedRails
|
|
52
95
|
app_name
|
53
96
|
end
|
54
97
|
|
98
|
+
def start_url
|
99
|
+
scope == '/' ? scope : "#{scope}/"
|
100
|
+
end
|
101
|
+
|
55
102
|
def theme; end
|
56
103
|
|
57
104
|
def theme_options
|
58
105
|
{}
|
59
106
|
end
|
60
107
|
|
61
|
-
def web_manifest
|
62
|
-
web_manifest_base.merge(
|
63
|
-
ontola: web_manifest_ontola_section,
|
64
|
-
serviceworker: web_manifest_sw_section
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
108
|
def web_manifest_base # rubocop:disable Metrics/MethodLength
|
69
109
|
{
|
70
110
|
background_color: background_color,
|
71
111
|
dir: :rtl,
|
72
112
|
display: :standalone,
|
73
|
-
|
113
|
+
icons: icons,
|
114
|
+
lang: lang,
|
74
115
|
name: app_name,
|
75
116
|
scope: scope,
|
76
117
|
short_name: app_name,
|
77
|
-
start_url:
|
118
|
+
start_url: start_url,
|
78
119
|
theme_color: site_theme_color
|
79
120
|
}
|
80
121
|
end
|
81
122
|
|
82
123
|
def web_manifest_ontola_section # rubocop:disable Metrics/MethodLength
|
83
124
|
{
|
84
|
-
|
125
|
+
allowed_external_sources: allowed_external_sources,
|
126
|
+
blob_preview_iri: blob_preview_iri,
|
127
|
+
blob_upload_iri: blob_upload_iri,
|
128
|
+
csp: csp_entries,
|
85
129
|
header_background: header_background,
|
86
130
|
header_text: header_text,
|
87
|
-
|
131
|
+
preconnect: preconnect,
|
88
132
|
primary_color: site_theme_color,
|
89
133
|
secondary_color: site_secondary_color,
|
134
|
+
styled_headers: styled_headers,
|
90
135
|
theme: theme,
|
91
136
|
theme_options: theme_options.to_query,
|
137
|
+
tracking: tracking,
|
92
138
|
website_iri: LinkedRails.iri.to_s,
|
93
139
|
websocket_path: websocket_path
|
94
140
|
}
|
@@ -96,7 +142,7 @@ module LinkedRails
|
|
96
142
|
|
97
143
|
def web_manifest_sw_section
|
98
144
|
{
|
99
|
-
src: "#{scope}/sw.js
|
145
|
+
src: "#{scope}/sw.js",
|
100
146
|
scope: scope
|
101
147
|
}
|
102
148
|
end
|
@@ -104,5 +150,35 @@ module LinkedRails
|
|
104
150
|
def websocket_path
|
105
151
|
Rails.application.config.try(:action_cable).try(:mount_path).try(:[], 1..-1)
|
106
152
|
end
|
153
|
+
|
154
|
+
def preconnect
|
155
|
+
[]
|
156
|
+
end
|
157
|
+
|
158
|
+
def styled_headers
|
159
|
+
false
|
160
|
+
end
|
161
|
+
|
162
|
+
def tracking
|
163
|
+
[]
|
164
|
+
end
|
165
|
+
|
166
|
+
class << self
|
167
|
+
def destroy(iri)
|
168
|
+
redis_client.hdel(MANIFEST_KEY, iri)
|
169
|
+
end
|
170
|
+
|
171
|
+
def move(from, to)
|
172
|
+
data = redis_client.hget(MANIFEST_KEY, from)
|
173
|
+
|
174
|
+
redis_client.hset(MANIFEST_KEY, to, data) if data
|
175
|
+
|
176
|
+
destroy(from)
|
177
|
+
end
|
178
|
+
|
179
|
+
def redis_client
|
180
|
+
@redis_client = Redis.new(db: CACHE_DB)
|
181
|
+
end
|
182
|
+
end
|
107
183
|
end
|
108
184
|
end
|
@@ -5,20 +5,8 @@ module LinkedRails
|
|
5
5
|
module Delta
|
6
6
|
include LinkedRails::Helpers::DeltaHelper
|
7
7
|
|
8
|
-
def changes_triples(resource)
|
8
|
+
def changes_triples(resource)
|
9
9
|
resource_serializer(resource)&.send(:repository).statements
|
10
|
-
|
11
|
-
# resource.previous_changes_by_predicate.map do |predicate, (_old_value, _new_value)|
|
12
|
-
# serializer_attributes = resource.class.predicate_mapping[predicate]
|
13
|
-
# next if serializer_attributes.is_a?(FastJsonapi::Relationship)
|
14
|
-
#
|
15
|
-
# attr_name = serializer_attributes.key
|
16
|
-
# serialized_value =
|
17
|
-
# serializer.class.attributes_to_serialize[attr_name]&.serialize(resource, serializer_params, {})
|
18
|
-
# (serialized_value.is_a?(Array) ? serialized_value : [serialized_value]).map do |value|
|
19
|
-
# change_triple(resource, predicate, value)
|
20
|
-
# end
|
21
|
-
# end.compact.flatten
|
22
10
|
end
|
23
11
|
|
24
12
|
def changed_relations_triples(resource, inverted = nil) # rubocop:disable Metrics/AbcSize
|
@@ -35,14 +23,6 @@ module LinkedRails
|
|
35
23
|
|
36
24
|
private
|
37
25
|
|
38
|
-
def change_triple(resource, predicate, value)
|
39
|
-
if value.nil?
|
40
|
-
RDF::Statement.new(resource.iri, predicate, Vocab.sp[:Variable], graph_name: delta_iri(:remove))
|
41
|
-
else
|
42
|
-
RDF::Statement.new(resource.iri, predicate, value, graph_name: delta_iri(:replace))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
26
|
def changed_relation_triples(predicate, destructed, resources, inverted)
|
47
27
|
related_resource_invalidations =
|
48
28
|
resources.flat_map do |resource|
|
@@ -22,17 +22,6 @@ module LinkedRails
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def previous_changes_by_predicate
|
26
|
-
serializer_class = RDF::Serializers.serializer_for(self)
|
27
|
-
return {} unless respond_to?(:previous_changes) && serializer_class
|
28
|
-
|
29
|
-
Hash[
|
30
|
-
previous_changes
|
31
|
-
.map { |k, v| [self.class.predicate_for_key(k.to_sym), v] }
|
32
|
-
.select { |k, _v| k.present? }
|
33
|
-
]
|
34
|
-
end
|
35
|
-
|
36
25
|
def previously_changed_relations(inverted = nil)
|
37
26
|
serializer_class = RDF::Serializers.serializer_for(self)
|
38
27
|
return {} unless serializer_class.try(:relationships_to_serialize)
|
@@ -3,8 +3,7 @@
|
|
3
3
|
module LinkedRails
|
4
4
|
class ParamsParser # rubocop:disable Metrics/ClassLength
|
5
5
|
include ::Empathy::EmpJson::Helpers::Slices
|
6
|
-
include ::Empathy::EmpJson::Helpers::
|
7
|
-
include ::Empathy::EmpJson::Helpers::Values
|
6
|
+
include ::Empathy::EmpJson::Helpers::Parsing
|
8
7
|
|
9
8
|
attr_accessor :params, :slice, :user_context
|
10
9
|
delegate :filter_params, to: :collection_params_parser
|
@@ -63,11 +62,11 @@ module LinkedRails
|
|
63
62
|
def associated_class_from_params(reflection, object)
|
64
63
|
return reflection.klass unless reflection.polymorphic?
|
65
64
|
|
66
|
-
|
65
|
+
type = values_from_slice(slice, object, Vocab.rdfv[:type])
|
67
66
|
|
68
|
-
raise("No type given for '#{object}' referenced by polymorphic association '#{reflection.name}'") if
|
67
|
+
raise("No type given for '#{object}' referenced by polymorphic association '#{reflection.name}'") if type.blank?
|
69
68
|
|
70
|
-
iri_to_class(
|
69
|
+
iri_to_class(type)
|
71
70
|
end
|
72
71
|
|
73
72
|
def collection_params_parser
|
@@ -78,11 +77,11 @@ module LinkedRails
|
|
78
77
|
options = serializer_field(klass, predicate)
|
79
78
|
return unless value.count == 1 && options.present?
|
80
79
|
|
81
|
-
parsed_value = value.first.start_with?('http') ? RDF::URI(value.first) :
|
80
|
+
parsed_value = value.first.start_with?('http') ? RDF::URI(value.first) : value.first
|
82
81
|
parse_param(
|
83
82
|
klass,
|
84
83
|
options.predicate,
|
85
|
-
parsed_value
|
84
|
+
object_to_value(parsed_value)
|
86
85
|
)
|
87
86
|
end
|
88
87
|
|
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.g14b377f91
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_response
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: kaminari-activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redis
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rdf
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|