unpoly-rails 3.9.5 → 3.10.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/assets/unpoly/unpoly-bootstrap3.js +3 -2
- data/assets/unpoly/unpoly-bootstrap3.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap4.js +3 -2
- data/assets/unpoly/unpoly-bootstrap4.min.js +1 -1
- data/assets/unpoly/unpoly-bootstrap5.js +3 -2
- data/assets/unpoly/unpoly-bootstrap5.min.js +1 -1
- data/assets/unpoly/unpoly-migrate.js +29 -6
- data/assets/unpoly/unpoly-migrate.min.js +1 -1
- data/assets/unpoly/unpoly.es6.js +1565 -1030
- data/assets/unpoly/unpoly.es6.min.js +1 -1
- data/assets/unpoly/unpoly.js +1540 -1013
- data/assets/unpoly/unpoly.min.js +1 -1
- data/lib/unpoly/rails/change/field_definition.rb +12 -4
- data/lib/unpoly/rails/change.rb +26 -11
- data/lib/unpoly/rails/util.rb +8 -0
- data/lib/unpoly/rails/version.rb +1 -1
- metadata +3 -3
| @@ -97,12 +97,20 @@ module Unpoly | |
| 97 97 |  | 
| 98 98 | 
             
                        define_method "write_#{method}_to_response_headers" do
         | 
| 99 99 | 
             
                          value = send(method)
         | 
| 100 | 
            -
                           | 
| 100 | 
            +
                          if Util.blank?(value)
         | 
| 101 | 
            +
                            # Blank values like [] have a present serialization ("[]".present? => true),
         | 
| 102 | 
            +
                            # so we must check the Ruby value here.
         | 
| 103 | 
            +
                            return
         | 
| 104 | 
            +
                          end
         | 
| 101 105 |  | 
| 102 | 
            -
                           | 
| 103 | 
            -
             | 
| 104 | 
            -
                             | 
| 106 | 
            +
                          stringified = field.stringify(value)
         | 
| 107 | 
            +
                          if Util.blank?(stringified)
         | 
| 108 | 
            +
                            # App servers don't like blank header values
         | 
| 109 | 
            +
                            return
         | 
| 105 110 | 
             
                          end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                          header_name = send("#{method}_response_header_name")
         | 
| 113 | 
            +
                          response.headers[header_name] = stringified
         | 
| 106 114 | 
             
                        end
         | 
| 107 115 |  | 
| 108 116 | 
             
                      end
         | 
    
        data/lib/unpoly/rails/change.rb
    CHANGED
    
    | @@ -66,7 +66,11 @@ module Unpoly | |
| 66 66 | 
             
                  end
         | 
| 67 67 |  | 
| 68 68 | 
             
                  def target_changed?
         | 
| 69 | 
            -
                    # The target  | 
| 69 | 
            +
                    # The target is present if the original request contained an X-Up-Target header.
         | 
| 70 | 
            +
                    # That means it is also present if it was never changed on the server.
         | 
| 71 | 
            +
                    #
         | 
| 72 | 
            +
                    # To check whether the server has *changed* the target, we must look at either condition:
         | 
| 73 | 
            +
                    #
         | 
| 70 74 | 
             
                    # (1) The #target= setter was called, setting @server_target
         | 
| 71 75 | 
             
                    # (2) An up[target] param was set to preserve a previously changed target through a redirect.
         | 
| 72 76 | 
             
                    (@server_target && @server_target != target_from_request_headers) || !!target_from_params
         | 
| @@ -256,10 +260,7 @@ module Unpoly | |
| 256 260 |  | 
| 257 261 | 
             
                      write_expire_cache_to_response_headers
         | 
| 258 262 | 
             
                      write_evict_cache_to_response_headers
         | 
| 259 | 
            -
             | 
| 260 | 
            -
                      if context_changes.present?
         | 
| 261 | 
            -
                        write_context_changes_to_response_headers
         | 
| 262 | 
            -
                      end
         | 
| 263 | 
            +
                      write_context_changes_to_response_headers
         | 
| 263 264 |  | 
| 264 265 | 
             
                      if target_changed?
         | 
| 265 266 | 
             
                        # Only write the target to the response if it has changed.
         | 
| @@ -405,18 +406,32 @@ module Unpoly | |
| 405 406 | 
             
                  end
         | 
| 406 407 |  | 
| 407 408 | 
             
                  def fields_as_params
         | 
| 408 | 
            -
                    params = {}
         | 
| 409 | 
            -
             | 
| 410 409 | 
             
                    # When the browser sees a redirect it will automatically resend the request headers
         | 
| 411 410 | 
             
                    # from the original request. This means that headers we set on the client (X-Up-Target, X-Up-Mode, etc.)
         | 
| 412 411 | 
             
                    # are automatically preserved through redirects.
         | 
| 413 412 | 
             
                    #
         | 
| 414 413 | 
             
                    # We still need to handle all the response headers that we set on the server.
         | 
| 415 414 | 
             
                    # There are encoded as params.
         | 
| 416 | 
            -
                    params | 
| 417 | 
            -
             | 
| 418 | 
            -
                     | 
| 419 | 
            -
             | 
| 415 | 
            +
                    params = {}
         | 
| 416 | 
            +
             | 
| 417 | 
            +
                    if Util.present?(context_changes)
         | 
| 418 | 
            +
                      # Don't send an empty hash as _up_context_changes=%7B%7D
         | 
| 419 | 
            +
                      params[context_changes_param_name] = serialized_context_changes
         | 
| 420 | 
            +
                    end
         | 
| 421 | 
            +
             | 
| 422 | 
            +
                    if Util.present?(events)
         | 
| 423 | 
            +
                      # Don't send an empty array as _up_events=%5B%5D
         | 
| 424 | 
            +
                      params[events_param_name] = serialized_events
         | 
| 425 | 
            +
                    end
         | 
| 426 | 
            +
             | 
| 427 | 
            +
                    if Util.present?(expire_cache)
         | 
| 428 | 
            +
                      # Note that we must support evict_cache == false for up.cache.keep
         | 
| 429 | 
            +
                      params[expire_cache_param_name] = serialized_expire_cache
         | 
| 430 | 
            +
                    end
         | 
| 431 | 
            +
             | 
| 432 | 
            +
                    if Util.present?(evict_cache)
         | 
| 433 | 
            +
                      params[evict_cache_param_name] = serialized_evict_cache
         | 
| 434 | 
            +
                    end
         | 
| 420 435 |  | 
| 421 436 | 
             
                    if target_changed?
         | 
| 422 437 | 
             
                      # Only write the target to the response if it has changed.
         | 
    
        data/lib/unpoly/rails/util.rb
    CHANGED
    
    | @@ -37,6 +37,14 @@ module Unpoly | |
| 37 37 | 
             
                      unicode_string.gsub(/[[:^ascii:]]/) { |char| "\\u" + char.ord.to_s(16).rjust(4, "0") }
         | 
| 38 38 | 
             
                    end
         | 
| 39 39 |  | 
| 40 | 
            +
                    def blank?(value)
         | 
| 41 | 
            +
                      value.blank? && value != false
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    def present?(value)
         | 
| 45 | 
            +
                      !blank?(value)
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
             | 
| 40 48 | 
             
                  end
         | 
| 41 49 | 
             
                end
         | 
| 42 50 | 
             
              end
         | 
    
        data/lib/unpoly/rails/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: unpoly-rails
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3. | 
| 4 | 
            +
              version: 3.10.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Henning Koch
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2025-01-23 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: railties
         | 
| @@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 157 157 | 
             
                - !ruby/object:Gem::Version
         | 
| 158 158 | 
             
                  version: '0'
         | 
| 159 159 | 
             
            requirements: []
         | 
| 160 | 
            -
            rubygems_version: 3. | 
| 160 | 
            +
            rubygems_version: 3.2.3
         | 
| 161 161 | 
             
            signing_key: 
         | 
| 162 162 | 
             
            specification_version: 4
         | 
| 163 163 | 
             
            summary: Rails bindings for Unpoly, the unobtrusive JavaScript framework
         |