dato 0.7.14 → 0.7.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dato/api_client.rb +4 -3
- data/lib/dato/json_api_serializer.rb +10 -4
- data/lib/dato/local/field_type/file.rb +29 -2
- data/lib/dato/upload/create_upload_path.rb +1 -1
- data/lib/dato/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7779edc00921c84e0f98aee2008bb8fd3f89d893c02107d965db12d1f5bc7882
|
4
|
+
data.tar.gz: 25ba5f84f8a6236c40d2846ef976987501f4977d481c9c445e298b666bc6b1ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955b67a6fadad2fb96e1342ec2e8907f5084085e0f18737655ebac56a4a8661e5d670ff9e662b3afc21381636139480f86ae48d47f268b571a21fcfa470de8c2
|
7
|
+
data.tar.gz: 479fe2e231a44cdf9518961c98bfddbd67ac06d4cd511e37a7369d668e5f0fa4eeca195d8af09bd981277a5c195f01d5f368f6b134562ebdd8f43df0c47a8c91
|
data/lib/dato/api_client.rb
CHANGED
@@ -100,10 +100,11 @@ module Dato
|
|
100
100
|
sleep(1)
|
101
101
|
request(*args)
|
102
102
|
else
|
103
|
+
# puts body.inspect
|
104
|
+
# puts '===='
|
105
|
+
# puts error.message
|
106
|
+
# puts '===='
|
103
107
|
error = ApiError.new(e.response)
|
104
|
-
puts '===='
|
105
|
-
puts error.message
|
106
|
-
puts '===='
|
107
108
|
raise error
|
108
109
|
end
|
109
110
|
end
|
@@ -23,8 +23,10 @@ module Dato
|
|
23
23
|
data[:type] = type
|
24
24
|
data[:attributes] = serialized_attributes(resource)
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
serialized_relationships = serialized_relationships(resource)
|
27
|
+
|
28
|
+
if serialized_relationships
|
29
|
+
data[:relationships] = serialized_relationships
|
28
30
|
end
|
29
31
|
|
30
32
|
{ data: data }
|
@@ -82,7 +84,7 @@ module Dato
|
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
85
|
-
result
|
87
|
+
result.empty? ? nil : result
|
86
88
|
end
|
87
89
|
|
88
90
|
def attributes(resource)
|
@@ -110,7 +112,11 @@ module Dato
|
|
110
112
|
end
|
111
113
|
|
112
114
|
def required_relationships
|
113
|
-
|
115
|
+
if link.schema.properties['data'].required.include?("relationships")
|
116
|
+
(link_relationships.required || []).map(&:to_sym)
|
117
|
+
else
|
118
|
+
[]
|
119
|
+
end
|
114
120
|
end
|
115
121
|
|
116
122
|
def link_attributes
|
@@ -18,6 +18,7 @@ module Dato
|
|
18
18
|
v[:alt],
|
19
19
|
v[:title],
|
20
20
|
v[:custom_data],
|
21
|
+
v[:focal_point],
|
21
22
|
repo.site.entity.imgix_host
|
22
23
|
)
|
23
24
|
end
|
@@ -29,12 +30,14 @@ module Dato
|
|
29
30
|
alt,
|
30
31
|
title,
|
31
32
|
custom_data,
|
33
|
+
focal_point,
|
32
34
|
imgix_host
|
33
35
|
)
|
34
36
|
@upload = upload
|
35
37
|
@alt = alt
|
36
38
|
@title = title
|
37
39
|
@custom_data = custom_data
|
40
|
+
@focal_point = focal_point
|
38
41
|
@imgix_host = imgix_host
|
39
42
|
end
|
40
43
|
|
@@ -100,6 +103,12 @@ module Dato
|
|
100
103
|
@custom_data.merge(default_metadata.fetch('custom_data', {}))
|
101
104
|
end
|
102
105
|
|
106
|
+
def focal_point
|
107
|
+
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
108
|
+
.fetch(I18n.locale.to_s, {})
|
109
|
+
@focal_point || default_metadata['focal_point']
|
110
|
+
end
|
111
|
+
|
103
112
|
def tags
|
104
113
|
@upload.tags
|
105
114
|
end
|
@@ -216,8 +225,25 @@ module Dato
|
|
216
225
|
).path(path)
|
217
226
|
end
|
218
227
|
|
219
|
-
def url(
|
220
|
-
|
228
|
+
def url(query = {})
|
229
|
+
query.deep_stringify_keys!
|
230
|
+
|
231
|
+
if focal_point &&
|
232
|
+
query["fit"] == "crop" &&
|
233
|
+
(query["h"] || query["height"]) &&
|
234
|
+
(query["w"] || query["width"]) &&
|
235
|
+
[nil, "focalpoint"].include?(query["crop"]) &&
|
236
|
+
query["fp-x"].nil? &&
|
237
|
+
query["fp-y"].nil?
|
238
|
+
|
239
|
+
query.merge!(
|
240
|
+
"crop" => "focalpoint",
|
241
|
+
"fp-x" => focal_point[:x],
|
242
|
+
"fp-y" => focal_point[:y],
|
243
|
+
)
|
244
|
+
end
|
245
|
+
|
246
|
+
file.to_url(query)
|
221
247
|
end
|
222
248
|
|
223
249
|
def lqip_data_url(opts = {})
|
@@ -241,6 +267,7 @@ module Dato
|
|
241
267
|
alt: alt,
|
242
268
|
title: title,
|
243
269
|
custom_data: custom_data,
|
270
|
+
focal_point: focal_point,
|
244
271
|
url: url,
|
245
272
|
copyright: copyright,
|
246
273
|
tags: tags,
|
data/lib/dato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -464,7 +464,7 @@ homepage: https://github.com/datocms/ruby-datocms-client
|
|
464
464
|
licenses:
|
465
465
|
- MIT
|
466
466
|
metadata: {}
|
467
|
-
post_install_message:
|
467
|
+
post_install_message:
|
468
468
|
rdoc_options: []
|
469
469
|
require_paths:
|
470
470
|
- lib
|
@@ -479,9 +479,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
479
479
|
- !ruby/object:Gem::Version
|
480
480
|
version: '0'
|
481
481
|
requirements: []
|
482
|
-
rubyforge_project:
|
482
|
+
rubyforge_project:
|
483
483
|
rubygems_version: 2.7.6
|
484
|
-
signing_key:
|
484
|
+
signing_key:
|
485
485
|
specification_version: 4
|
486
486
|
summary: Ruby client for DatoCMS API
|
487
487
|
test_files: []
|