active_storage-async_variants-ui 0.1.0 → 0.2.0
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 +7 -0
- data/app/controllers/active_storage/async_variants/states_controller.rb +21 -7
- data/app/views/active_storage/async_variants/states/_failed.html.erb +1 -1
- data/app/views/active_storage/async_variants/states/show.html.erb +1 -0
- data/lib/active_storage/async_variants/helper.rb +5 -0
- data/lib/active_storage/async_variants/ui/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e005a7ad73b45c7f8d6e7ede189bb0aa1e17a295d7ca68096ba745a3e8dfa264
|
|
4
|
+
data.tar.gz: 4da955bf3e81bdd833602160fc8508f79c3d05c159ec6229ffb241254df1894e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98a2bc9515eb63b696f92936673124ecd33234f924c7b8fc00741da28ab5e1d5aad21923565645e1be0c042f42c57e5b7930af2845b46deddd215f2cb392a647
|
|
7
|
+
data.tar.gz: 8bc97a17fd4641e9c4824c768f2fb72e23c247014e906d6279f15e750a60337a16d20d1d6ece692588494f213bd8520aaf9b76e5f7a2d7d7e5837702b5be8691
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [0.2.0]
|
|
2
|
+
|
|
3
|
+
- Video previews on the stock preview graph: a video's image variant keeps its record on the extracted-frame blob (`preview_image`), so the state endpoint now rebuilds a `Preview` (via a `repr=preview` param the helper round-trips) and reads state, progress, and the processed URL from there. Format-bearing variations are canonicalized to the declared named variant so a URL-rebuilt digest matches the stored record.
|
|
4
|
+
- Retry goes through the representation's `retry!`, so a video preview's failed record on the frame blob is actually replaced; previously the endpoint searched the source blob with the wrong digest and retry silently did nothing for videos.
|
|
5
|
+
- Fix: the failed state's retry form now carries `repr`, so retrying a video preview replaces its frame record instead of recording a stray variant on the video blob.
|
|
6
|
+
- Requires `active_storage-async_variants` >= 0.10. Hand `image_tag`/`video_tag` a video's `representation(...)` (a `Preview`), not its `variant(...)`, while it is unprocessed.
|
|
7
|
+
|
|
1
8
|
## [0.1.0]
|
|
2
9
|
|
|
3
10
|
- Initial release. Extracted from `active_storage-async_variants` (≤ 0.8.0), which now ships the UI-free plumbing. This gem layers on the opinionated UI:
|
|
@@ -26,17 +26,14 @@ module ActiveStorage
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def retry
|
|
29
|
-
@variant.
|
|
30
|
-
variation_digest: @variant.variation.digest,
|
|
31
|
-
state: "failed",
|
|
32
|
-
).destroy_all
|
|
33
|
-
@variant.enqueue!
|
|
29
|
+
@variant.retry!
|
|
34
30
|
|
|
35
31
|
redirect_to Rails.application.routes.url_helpers.async_variant_state_path(
|
|
36
32
|
signed_blob_id: params[:signed_blob_id],
|
|
37
33
|
variation_key: params[:variation_key],
|
|
38
34
|
kind: params[:kind],
|
|
39
35
|
direct: params[:direct],
|
|
36
|
+
repr: params[:repr],
|
|
40
37
|
opts: async_variant_html_options.presence,
|
|
41
38
|
), status: :see_other
|
|
42
39
|
end
|
|
@@ -47,12 +44,29 @@ module ActiveStorage
|
|
|
47
44
|
|
|
48
45
|
def set_variant
|
|
49
46
|
blob = ActiveStorage::Blob.find_signed!(params[:signed_blob_id])
|
|
50
|
-
variation = ActiveStorage::Variation.decode(params[:variation_key])
|
|
51
|
-
|
|
47
|
+
variation = canonical_variation(blob, ActiveStorage::Variation.decode(params[:variation_key]))
|
|
48
|
+
# A video's image preview keeps its variant record on the extracted-frame
|
|
49
|
+
# blob, so rebuild it as a Preview to read state from the right place;
|
|
50
|
+
# everything else is a plain Variant. The helper round-trips which one
|
|
51
|
+
# via the `repr` param.
|
|
52
|
+
@variant = params[:repr] == "preview" ? blob.preview(variation) : blob.variant(variation)
|
|
52
53
|
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
|
53
54
|
head :not_found
|
|
54
55
|
end
|
|
55
56
|
|
|
57
|
+
# The URL key round-trips a declared variant's transformations to strings
|
|
58
|
+
# (format: :webp -> "webp"), which Marshal-digests differently from the
|
|
59
|
+
# symbol form the variant record was created with -- so the record lookup
|
|
60
|
+
# would miss. Recover the declared transformations (symbol-preserving) when
|
|
61
|
+
# this variation matches a named variant; NamedVariantScan is itself
|
|
62
|
+
# format-string/symbol tolerant.
|
|
63
|
+
def canonical_variation(blob, variation)
|
|
64
|
+
found = ActiveStorage::AsyncVariants::NamedVariantScan.find(blob, variation)
|
|
65
|
+
return variation unless found
|
|
66
|
+
attachment, name, _ = found
|
|
67
|
+
ActiveStorage::Variation.wrap(attachment.send(:named_variants)[name].transformations)
|
|
68
|
+
end
|
|
69
|
+
|
|
56
70
|
def async_variant_kind
|
|
57
71
|
params[:kind].to_s == "video" ? :video : :image
|
|
58
72
|
end
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</style>
|
|
17
17
|
<%# In the light DOM so its submit reaches Turbo, and so preventDefault on the
|
|
18
18
|
buttons doesn't also cancel the submit. %>
|
|
19
|
-
<form action="<%= Rails.application.routes.url_helpers.async_variant_state_retry_path(signed_blob_id:, variation_key:, kind:, direct:, opts: html_options) %>"
|
|
19
|
+
<form action="<%= Rails.application.routes.url_helpers.async_variant_state_retry_path(signed_blob_id:, variation_key:, kind:, direct:, repr:, opts: html_options) %>"
|
|
20
20
|
method="post"
|
|
21
21
|
id="<%= form_id %>"
|
|
22
22
|
data-turbo-frame="<%= async_variant_frame_id(variant) %>"
|
|
@@ -56,6 +56,11 @@ module ActiveStorage
|
|
|
56
56
|
variation_key: variant.variation.key,
|
|
57
57
|
kind:,
|
|
58
58
|
direct:,
|
|
59
|
+
# Preserve which representation the caller passed: a video's image
|
|
60
|
+
# preview keeps its variant record on the extracted-frame blob, so the
|
|
61
|
+
# state endpoint must rebuild it as a Preview (blob.preview), not a
|
|
62
|
+
# Variant (blob.variant) -- otherwise it reads state off the wrong blob.
|
|
63
|
+
repr: variant.is_a?(ActiveStorage::Preview) ? "preview" : "variant",
|
|
59
64
|
opts: html_options.slice(*PASS_THROUGH_HTML_OPTIONS),
|
|
60
65
|
)
|
|
61
66
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_storage-async_variants-ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-11-14 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: active_storage-async_variants
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '0.
|
|
18
|
+
version: '0.10'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '0.
|
|
25
|
+
version: '0.10'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: turbo-rails
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|