bullet_train 1.36.0 → 1.37.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c1d33c15093050889618d0a58e53899f22dbbee55e6792adad049b36107eec6
4
- data.tar.gz: a7a547ddbb60545ee9b2f37e984aa1b293a84ddd231a3233542ea85e5a2c5a61
3
+ metadata.gz: ac0619828c18dd73c0bd24b703b49c9055b3e2dbc8e9e17b3093c1f0b902c1dd
4
+ data.tar.gz: a7656a675b55ca274086d9001b35c7d32c46616198d8cec19c38357d2796eebb
5
5
  SHA512:
6
- metadata.gz: dafe1f7e4ec075acbd7fd8417a2080b7dc51c496eaf2b8d3b63e14262d9a43b2bce61e8ed8b42678688ba48c4346026c2ae3ce87e4b778532e7bec7931dab8e7
7
- data.tar.gz: f25805b74ba7e7f77ccadfe2404350a312f6de5d4f223b4940f8a881c5017cccc4aa2d348fa9fca3acd3a247d2fd9b994b85dfa63b1d0c46727ee683ea85e9e8
6
+ metadata.gz: 5be720efef93b47c086bf5432ca141d244c22996aaed1ce73325833caedb006fa795ae32fc910068dde432398f87373b36bf0ddfb96bc5eeecc492d9c9bae3cc
7
+ data.tar.gz: db0d4c4fdecb6f0a5f0f6e8f8b35420bc412f508948700443eb3ab4b65c16dc0629cfdc5d1ae24060f6466023f24598b818fd6a1aa8c232a00bbb86e827c6c8d
@@ -0,0 +1,29 @@
1
+ <figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
2
+ <% if blob.video? %>
3
+ <video controls width="<%= local_assigns[:in_gallery] ? 800 : 1024 %>" preload="metadata" class="max-w-full h-auto rounded-md"
4
+ poster="<%= url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>"
5
+ >
6
+ <source src="<%= rails_blob_url(blob) %>" type="<%= blob.content_type %>">
7
+ </video>
8
+ <% elsif blob.representable? %>
9
+ <%
10
+ # loader_options are passed through to lib-vips: https://www.libvips.org/API/current/ctor.Image.gifload.html
11
+ # By default the loader uses page = 1, and n = 1 to pick just the first "page" (aka frame) of a GIF.
12
+ # We pass -1 for n to indicate that it should pull all the frames and give us a scaled verison of the whole GIF.
13
+ loader_options = {}
14
+ if blob.filename.extension.casecmp("gif")
15
+ loader_options[:n] = -1
16
+ end
17
+ %>
18
+ <%= image_tag blob.representation(loader: loader_options, resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
19
+ <% end %>
20
+
21
+ <figcaption class="attachment__caption">
22
+ <% if caption = blob.try(:caption) %>
23
+ <%= caption %>
24
+ <% else %>
25
+ <span class="attachment__name"><%= blob.filename %></span>
26
+ <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
27
+ <% end %>
28
+ </figcaption>
29
+ </figure>
@@ -0,0 +1,3 @@
1
+ <div class="trix-content">
2
+ <%= yield -%>
3
+ </div>
@@ -0,0 +1,15 @@
1
+ # This is to render previews for video attachments in Action Text
2
+ # Source: https://mileswoodroffe.com/articles/action-text-video-support
3
+ #
4
+ # NOTE: This is all way more verbose that I'd like it to be. Maybe we can
5
+ # slim it down if this Rails issue is ever fixed:
6
+ # https://github.com/rails/rails/issues/54478
7
+ Rails.application.config.after_initialize do
8
+ default_allowed_attributes = Rails::HTML5::Sanitizer.safe_list_sanitizer.allowed_attributes + ActionText::Attachment::ATTRIBUTES.to_set
9
+ custom_allowed_attributes = Set.new(%w[controls poster type])
10
+ ActionText::ContentHelper.allowed_attributes = (default_allowed_attributes + custom_allowed_attributes).freeze
11
+
12
+ default_allowed_tags = Rails::HTML5::Sanitizer.safe_list_sanitizer.allowed_tags + Set.new([ActionText::Attachment.tag_name, "figure", "figcaption"])
13
+ custom_allowed_tags = Set.new(%w[audio video source])
14
+ ActionText::ContentHelper.allowed_tags = (default_allowed_tags + custom_allowed_tags).freeze
15
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # We're using this monkey patch: https://github.com/rails/rails/pull/39113#issuecomment-1729082686
4
+ # To work around this long-standing bug: https://github.com/rails/rails/issues/38027
5
+ # If PR #39113 is ever merged and released in Rails we can ditch this entire file.
6
+
7
+ require "active_support/core_ext/object/try"
8
+ module ActionText
9
+ module Attachments
10
+ module TrixConversion
11
+ def to_trix_attachment(content = trix_attachment_content)
12
+ attributes = full_attributes.dup
13
+ attributes["content"] = content if content
14
+ attributes["url"] = trix_attachable_url if previewable_attachable? && previewable?
15
+ TrixAttachment.from_attributes(attributes)
16
+ end
17
+
18
+ def trix_attachable_url
19
+ Rails.application.routes.url_helpers.rails_blob_url(preview_image.blob, only_path: true)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.36.0"
2
+ VERSION = "1.37.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.36.0
4
+ version: 1.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
@@ -506,6 +506,7 @@ files:
506
506
  - app/views/account/users/_oauth.html.erb
507
507
  - app/views/account/users/edit.html.erb
508
508
  - app/views/account/users/show.html.erb
509
+ - app/views/active_storage/blobs/_blob.html.erb
509
510
  - app/views/bullet_train/partial_resolver.html.erb
510
511
  - app/views/devise/confirmations/new.html.erb
511
512
  - app/views/devise/mailer/confirmation_instructions.html.erb
@@ -524,6 +525,7 @@ files:
524
525
  - app/views/devise/shared/_oauth.html.erb
525
526
  - app/views/devise/unlocks/new.html.erb
526
527
  - app/views/layouts/account.html.erb
528
+ - app/views/layouts/action_text/contents/_content.html.erb
527
529
  - app/views/layouts/devise.html.erb
528
530
  - app/views/layouts/docs.html.erb
529
531
  - app/views/layouts/mailer.html.erb
@@ -534,6 +536,8 @@ files:
534
536
  - app/views/user_mailer/welcome.html.erb
535
537
  - config/addresses/countries.json
536
538
  - config/addresses/states.json
539
+ - config/initializers/action_text_sanitzer.rb
540
+ - config/initializers/actiontext_override.rb
537
541
  - config/initializers/concerns/inflections_base.rb
538
542
  - config/initializers/concerns/turbo_failure_app.rb
539
543
  - config/locales/en/addresses.en.yml