dato 0.7.8 → 0.7.9
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/CHANGELOG.md +4 -0
- data/lib/dato/local/field_type/file.rb +137 -7
- data/lib/dato/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2faaeda3b7c9f1317aeaa5291274cd1e66f7ec352f45f4513ca3e44747d6d816
|
4
|
+
data.tar.gz: 4a8afc49f92605e0c1bcbdd5473d07bbc83f34d7f71e20cf44414489eaa48504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e64850f3e6bb5d754e1d365d03538d42e37b6798ac177bd6e6eb1297e5431a43f4261c1ad29c05f9d0ecb29d8e7c5200c1d9f4fecb1b4440e3fa37f9b7c7bfc7
|
7
|
+
data.tar.gz: cd164fe876d2bd58d23c742ae8b96bffa66e58f896d43f641ac0fe5c2ba736b4d5476aac7b17091c78154ec96a617d210d841039fcd92a34c562a356c4dda053
|
data/CHANGELOG.md
CHANGED
@@ -74,19 +74,138 @@ module Dato
|
|
74
74
|
@upload.copyright
|
75
75
|
end
|
76
76
|
|
77
|
+
def filename
|
78
|
+
@upload.filename
|
79
|
+
end
|
80
|
+
|
81
|
+
def basename
|
82
|
+
@upload.basename
|
83
|
+
end
|
84
|
+
|
77
85
|
def alt
|
78
|
-
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
79
|
-
|
86
|
+
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
87
|
+
.fetch(I18n.locale.to_s, {})
|
88
|
+
@alt || default_metadata['alt']
|
80
89
|
end
|
81
90
|
|
82
91
|
def title
|
83
|
-
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
84
|
-
|
92
|
+
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
93
|
+
.fetch(I18n.locale.to_s, {})
|
94
|
+
@title || default_metadata['title']
|
85
95
|
end
|
86
96
|
|
87
97
|
def custom_data
|
88
|
-
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
89
|
-
|
98
|
+
default_metadata = @upload.default_field_metadata.deep_stringify_keys
|
99
|
+
.fetch(I18n.locale.to_s, {})
|
100
|
+
@custom_data.merge(default_metadata.fetch('custom_data', {}))
|
101
|
+
end
|
102
|
+
|
103
|
+
def tags
|
104
|
+
@upload.tags
|
105
|
+
end
|
106
|
+
|
107
|
+
def smart_tags
|
108
|
+
@upload.smart_tags
|
109
|
+
end
|
110
|
+
|
111
|
+
def is_image
|
112
|
+
@upload.is_image
|
113
|
+
end
|
114
|
+
|
115
|
+
def exif_info
|
116
|
+
@upload.exif_info
|
117
|
+
end
|
118
|
+
|
119
|
+
def mime_type
|
120
|
+
@upload.mime_type
|
121
|
+
end
|
122
|
+
|
123
|
+
def colors
|
124
|
+
@upload.colors.map { |color| Color.parse(color, nil) }
|
125
|
+
end
|
126
|
+
|
127
|
+
def blurhash
|
128
|
+
@upload.blurhash
|
129
|
+
end
|
130
|
+
|
131
|
+
class VideoAttributes
|
132
|
+
def initialize(upload)
|
133
|
+
@upload = upload
|
134
|
+
end
|
135
|
+
|
136
|
+
def mux_playback_id
|
137
|
+
@upload.mux_playback_id
|
138
|
+
end
|
139
|
+
|
140
|
+
def frame_rate
|
141
|
+
@upload.frame_rate
|
142
|
+
end
|
143
|
+
|
144
|
+
def duration
|
145
|
+
@upload.duration
|
146
|
+
end
|
147
|
+
|
148
|
+
def streaming_url
|
149
|
+
"https://stream.mux.com/#{@upload.mux_playback_id}.m3u8"
|
150
|
+
end
|
151
|
+
|
152
|
+
def thumbnail_url(format = :jpg)
|
153
|
+
if format == :gif
|
154
|
+
"https://image.mux.com/#{@upload.mux_playback_id}/animated.gif"
|
155
|
+
else
|
156
|
+
"https://image.mux.com/#{@upload.mux_playback_id}/thumbnail.#{format}"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def mp4_url(options = nil)
|
161
|
+
@upload.mux_mp4_highest_res or
|
162
|
+
return nil
|
163
|
+
|
164
|
+
if options && options[:exact_res]
|
165
|
+
if options[:exact_res] == :low
|
166
|
+
raw_mp4_url("low")
|
167
|
+
elsif options[:exact_res] == :medium
|
168
|
+
if %w[medium high].include?(@upload.mux_mp4_highest_res)
|
169
|
+
raw_mp4_url("medium")
|
170
|
+
end
|
171
|
+
elsif @upload.mux_mp4_highest_res == :high
|
172
|
+
raw_mp4_url("high")
|
173
|
+
end
|
174
|
+
elsif options && options[:res] == :low
|
175
|
+
raw_mp4_url("low")
|
176
|
+
elsif options && options[:res] == :medium
|
177
|
+
if %w[low medium].include?(@upload.mux_mp4_highest_res)
|
178
|
+
raw_mp4_url(@upload.mux_mp4_highest_res)
|
179
|
+
else
|
180
|
+
raw_mp4_url("medium")
|
181
|
+
end
|
182
|
+
else
|
183
|
+
raw_mp4_url(@upload.mux_mp4_highest_res)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def to_hash
|
188
|
+
{
|
189
|
+
mux_playback_id: mux_playback_id,
|
190
|
+
frame_rate: frame_rate,
|
191
|
+
duration: duration,
|
192
|
+
streaming_url: streaming_url,
|
193
|
+
thumbnail_url: thumbnail_url,
|
194
|
+
mp4_url: mp4_url,
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
private
|
199
|
+
|
200
|
+
def raw_mp4_url(res)
|
201
|
+
"https://stream.mux.com/#{@upload.mux_playback_id}/#{res}.mp4"
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def video
|
206
|
+
if @upload.mux_playback_id
|
207
|
+
VideoAttributes.new(@upload)
|
208
|
+
end
|
90
209
|
end
|
91
210
|
|
92
211
|
def file
|
@@ -111,7 +230,18 @@ module Dato
|
|
111
230
|
alt: alt,
|
112
231
|
title: title,
|
113
232
|
custom_data: custom_data,
|
114
|
-
url: url
|
233
|
+
url: url,
|
234
|
+
copyright: copyright,
|
235
|
+
tags: tags,
|
236
|
+
smart_tags: smart_tags,
|
237
|
+
filename: filename,
|
238
|
+
basename: basename,
|
239
|
+
is_image: is_image,
|
240
|
+
exif_info: exif_info,
|
241
|
+
mime_type: mime_type,
|
242
|
+
colors: colors.map(&:to_hash),
|
243
|
+
blurhash: blurhash,
|
244
|
+
video: video && video.to_hash
|
115
245
|
}
|
116
246
|
end
|
117
247
|
end
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|