Project

General

Profile

Feature #39111 » 0002-Upgrade-propshaft-to-1.1.0.patch

Takashi Kato, 2024-10-29 15:41

View differences:

Gemfile
14 14
gem 'rbpdf', '~> 1.21.3'
15 15
gem 'addressable'
16 16
gem 'rubyzip', '~> 2.3.0'
17
gem 'propshaft', '~> 0.8.0'
17
gem 'propshaft', '~> 1.1.0'
18 18
gem 'rack', '>= 3.1.3'
19 19

  
20 20
#  Ruby Standard Gems
config/initializers/10-patches.rb
132 132
    end
133 133

  
134 134
    def load_path
135
      @load_path ||= Redmine::AssetLoadPath.new(config)
135
      @load_path ||= Redmine::AssetLoadPath.new(config, compilers)
136 136
    end
137 137
  end)
138 138

  
lib/redmine/asset_path.rb
29 29
      @version = Rails.application.config.assets.version
30 30
    end
31 31

  
32
    def update(transition_map:, assets:)
32
    def update(transition_map:, assets:, load_path:)
33 33
      each_file do |file, intermediate_path, logical_path|
34 34
        @transition.add_src  intermediate_path, logical_path
35 35
        @transition.add_dest intermediate_path, logical_path
36 36
        asset = if file.extname == '.css'
37
                  Redmine::Asset.new(file,   logical_path: logical_path, version: version, transition_map: transition_map)
37
                  Redmine::Asset.new(file,   logical_path: logical_path, load_path: load_path, transition_map: transition_map)
38 38
                else
39
                  Propshaft::Asset.new(file, logical_path: logical_path, version: version)
39
                  Propshaft::Asset.new(file, logical_path: logical_path, load_path: load_path)
40 40
                end
41 41
        assets[asset.logical_path.to_s] ||= asset
42 42
      end
......
132 132
  class AssetLoadPath < Propshaft::LoadPath
133 133
    attr_reader :extension_paths, :default_asset_path, :transition_map
134 134

  
135
    def initialize(config)
135
    def initialize(config, compilers)
136 136
      @extension_paths    = config.redmine_extension_paths
137 137
      @default_asset_path = config.redmine_default_asset_path
138
      super(config.paths, version: config.version)
138
      super(config.paths, compilers: compilers, version: config.version)
139 139
    end
140 140

  
141 141
    def asset_files
......
156 156
      super
157 157
      if merge_required
158 158
        @transition_map = {}
159
        default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map)
159
        default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self)
160 160
        extension_paths.each do |asset_path|
161 161
          # Support link from extension assets to assets in the application
162 162
          default_asset_path.each_file do |file, intermediate_path, logical_path|
163 163
            asset_path.instance_eval { @transition.add_dest intermediate_path, logical_path }
164 164
          end
165
          asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map)
165
          asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self)
166 166
        end
167 167
      end
168 168
      @cached_assets_by_path
......
189 189
  end
190 190

  
191 191
  class Asset < Propshaft::Asset
192
    def initialize(file, logical_path:, version:, transition_map:)
192
    def initialize(file, logical_path:, load_path:, transition_map:)
193 193
      @transition_map = transition_map
194
      super(file, logical_path: logical_path, version: version)
194
      super(file, logical_path: logical_path, load_path: load_path)
195 195
    end
196 196

  
197 197
    def content
test/unit/lib/redmine/asset_path_test.rb
26 26
    @asset_path = Redmine::AssetPath.new(assets_dir, paths, 'plugin_assets/foo/')
27 27
    @assets = {}
28 28
    @transition_map = {}
29
    @asset_path.update(transition_map: @transition_map, assets: @assets)
29
    @asset_path.update(transition_map: @transition_map, assets: @assets, load_path: nil)
30 30
  end
31 31

  
32 32
  test "asset path size" do
(7-7/10)