From: Marius Balteanu Date: Thu, 31 Oct 2024 08:17:01 +0000 (+0000) Subject: Upgrades propshaft to 1.1.0 (#39111). X-Git-Tag: 6.0.0~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=826980bc40c5485aebef922b6984c3aa334e6bb4;p=redmine.git Upgrades propshaft to 1.1.0 (#39111). Patch by Takashi Kato (user:tohosaku). git-svn-id: https://svn.redmine.org/redmine/trunk@23174 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/Gemfile b/Gemfile index 14dabb626..7ccb60b1d 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'i18n', '~> 1.14.1' gem 'rbpdf', '~> 1.21.3' gem 'addressable' gem 'rubyzip', '~> 2.3.0' -gem 'propshaft', '~> 0.8.0' +gem 'propshaft', '~> 1.1.0' gem 'rack', '>= 3.1.3' # Ruby Standard Gems diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb index 52e6d2a21..0cee95cce 100644 --- a/config/initializers/10-patches.rb +++ b/config/initializers/10-patches.rb @@ -132,7 +132,7 @@ module Propshaft end def load_path - @load_path ||= Redmine::AssetLoadPath.new(config) + @load_path ||= Redmine::AssetLoadPath.new(config, compilers) end end) diff --git a/lib/redmine/asset_path.rb b/lib/redmine/asset_path.rb index d425d39f0..4c7959a58 100644 --- a/lib/redmine/asset_path.rb +++ b/lib/redmine/asset_path.rb @@ -29,14 +29,14 @@ module Redmine @version = Rails.application.config.assets.version end - def update(transition_map:, assets:) + def update(transition_map:, assets:, load_path:) each_file do |file, intermediate_path, logical_path| @transition.add_src intermediate_path, logical_path @transition.add_dest intermediate_path, logical_path asset = if file.extname == '.css' - Redmine::Asset.new(file, logical_path: logical_path, version: version, transition_map: transition_map) + Redmine::Asset.new(file, logical_path: logical_path, load_path: load_path, transition_map: transition_map) else - Propshaft::Asset.new(file, logical_path: logical_path, version: version) + Propshaft::Asset.new(file, logical_path: logical_path, load_path: load_path) end assets[asset.logical_path.to_s] ||= asset end @@ -132,10 +132,10 @@ module Redmine class AssetLoadPath < Propshaft::LoadPath attr_reader :extension_paths, :default_asset_path, :transition_map - def initialize(config) + def initialize(config, compilers) @extension_paths = config.redmine_extension_paths @default_asset_path = config.redmine_default_asset_path - super(config.paths, version: config.version) + super(config.paths, compilers: compilers, version: config.version) end def asset_files @@ -156,13 +156,13 @@ module Redmine super if merge_required @transition_map = {} - default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map) + default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self) extension_paths.each do |asset_path| # Support link from extension assets to assets in the application default_asset_path.each_file do |file, intermediate_path, logical_path| asset_path.instance_eval { @transition.add_dest intermediate_path, logical_path } end - asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map) + asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self) end end @cached_assets_by_path @@ -189,9 +189,9 @@ module Redmine end class Asset < Propshaft::Asset - def initialize(file, logical_path:, version:, transition_map:) + def initialize(file, logical_path:, load_path:, transition_map:) @transition_map = transition_map - super(file, logical_path: logical_path, version: version) + super(file, logical_path: logical_path, load_path: load_path) end def content diff --git a/test/unit/lib/redmine/asset_path_test.rb b/test/unit/lib/redmine/asset_path_test.rb index a4f12f0e3..bad93f8b0 100644 --- a/test/unit/lib/redmine/asset_path_test.rb +++ b/test/unit/lib/redmine/asset_path_test.rb @@ -26,7 +26,7 @@ class Redmine::AssetPathTest < ActiveSupport::TestCase @asset_path = Redmine::AssetPath.new(assets_dir, paths, 'plugin_assets/foo/') @assets = {} @transition_map = {} - @asset_path.update(transition_map: @transition_map, assets: @assets) + @asset_path.update(transition_map: @transition_map, assets: @assets, load_path: nil) end test "asset path size" do