bullet_train 1.35.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: 25534acd68cfd6da1b0e05199b35c0795bbd98d9fa1314fd1c1180b154e7c043
4
- data.tar.gz: cc0cad473683e187e5dcaeca068748a3fe979cf7ebca0687766d4710e97cb164
3
+ metadata.gz: ac0619828c18dd73c0bd24b703b49c9055b3e2dbc8e9e17b3093c1f0b902c1dd
4
+ data.tar.gz: a7656a675b55ca274086d9001b35c7d32c46616198d8cec19c38357d2796eebb
5
5
  SHA512:
6
- metadata.gz: a221a9c961bbd7f379d340f9a97d98cdaa4c4c74b88c593778d4b81e517b73e863a497a739fc465fb77d2ff6751e29d0d851b118e67957c1ffac4d82396a9690
7
- data.tar.gz: c94b9763df8e2182a9f041771921c1d0299fcfdec7618ff44f167249378f9879ca21521c58d9903bdc09a501c42e1100d79c53f9c9ded2030e117a4b561bdb63
6
+ metadata.gz: 5be720efef93b47c086bf5432ca141d244c22996aaed1ce73325833caedb006fa795ae32fc910068dde432398f87373b36bf0ddfb96bc5eeecc492d9c9bae3cc
7
+ data.tar.gz: db0d4c4fdecb6f0a5f0f6e8f8b35420bc412f508948700443eb3ab4b65c16dc0629cfdc5d1ae24060f6466023f24598b818fd6a1aa8c232a00bbb86e827c6c8d
@@ -14,6 +14,8 @@ module Invitations::Base
14
14
  after_create :set_added_by_membership
15
15
  after_create :send_invitation_email
16
16
 
17
+ after_validation :hoist_membership_email_error
18
+
17
19
  attribute :uuid, default: -> { SecureRandom.hex }
18
20
 
19
21
  def roles
@@ -44,4 +46,13 @@ module Invitations::Base
44
46
  def is_for?(user)
45
47
  user.email.downcase.strip == email.downcase.strip
46
48
  end
49
+
50
+ def hoist_membership_email_error
51
+ # This is special handling for the email field because we have a uniqueness validation in the
52
+ # `Membership` model for the `user_email` field. Since we copy the value from `invitation.email`
53
+ # into `invitation.membership.user_email` the error isn't passed through to the form in the normal way.
54
+ errors[:"membership.user_email"]&.each do |error|
55
+ errors.add(:email, error)
56
+ end
57
+ end
47
58
  end
@@ -44,6 +44,7 @@ module Users::Base
44
44
  # callbacks
45
45
  after_validation :remove_profile_photo, if: :profile_photo_removal?
46
46
  after_update :set_teams_time_zone
47
+ after_update :set_memberships_email
47
48
  end
48
49
 
49
50
  def email_is_oauth_placeholder?
@@ -159,6 +160,12 @@ module Users::Base
159
160
  end
160
161
  end
161
162
 
163
+ def set_memberships_email
164
+ if email_previously_changed?
165
+ memberships.where.not(user_email: email).update(user_email: email)
166
+ end
167
+ end
168
+
162
169
  def profile_photo_removal?
163
170
  profile_photo_removal.present?
164
171
  end
@@ -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.35.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.35.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