Defect #41726 » 0001-Support-plugin-multiple-asset-path.patch
| config/initializers/30-redmine.rb | ||
|---|---|---|
| 34 | 34 | 
    end  | 
| 35 | 35 | |
| 36 | 36 | 
    Redmine::Plugin.all.each do |plugin|  | 
| 37 | 
    paths = plugin.asset_paths  | 
|
| 38 | 
    Rails.application.config.assets.redmine_extension_paths << paths if paths.present?  | 
|
| 37 | 
    plugin.asset_paths.each do |paths|  | 
|
| 38 | 
    Rails.application.config.assets.redmine_extension_paths << paths if paths.present?  | 
|
| 39 | 
    end  | 
|
| 39 | 40 | 
    end  | 
| 40 | 41 | |
| 41 | 42 | 
    Redmine::Themes.themes.each do |theme|  | 
| lib/redmine/plugin.rb | ||
|---|---|---|
| 192 | 192 | 
    def asset_paths  | 
| 193 | 193 | 
    return unless path.has_assets_dir?  | 
| 194 | 194 | |
| 195 | 
    base_dir = Pathname.new(path.assets_dir)  | 
|
| 196 | 
    paths = base_dir.children.select(&:directory?)  | 
|
| 197 | 
    Redmine::AssetPath.new(base_dir, paths, asset_prefix)  | 
|
| 195 | 
    path.assets_dir.map do |dir|  | 
|
| 196 | 
    base_dir = Pathname.new(dir)  | 
|
| 197 | 
    paths = base_dir.children.select(&:directory?)  | 
|
| 198 | 
    Redmine::AssetPath.new(base_dir, paths, asset_prefix)  | 
|
| 199 | 
    end  | 
|
| 198 | 200 | 
    end  | 
| 199 | 201 | |
| 200 | 202 | 
    def <=>(plugin)  | 
| lib/redmine/plugin_loader.rb | ||
|---|---|---|
| 21 | 21 | 
    class PluginPath  | 
| 22 | 22 | 
    attr_reader :assets_dir, :initializer  | 
| 23 | 23 | |
| 24 | 
    ASSET_PATHS = ['assets', 'app/assets']  | 
|
| 25 | ||
| 24 | 26 | 
    def initialize(dir)  | 
| 25 | 27 | 
    @dir = dir  | 
| 26 | 
          @assets_dir = File.join dir, 'assets'
   | 
|
| 28 | 
          @assets_dir = ASSET_PATHS.map{|asset_path| File.join dir, asset_path}.select{|dir| File.directory? dir}
   | 
|
| 27 | 29 | 
    @initializer = File.join dir, 'init.rb'  | 
| 28 | 30 | 
    end  | 
| 29 | 31 | |
| ... | ... | |
| 36 | 38 | 
    end  | 
| 37 | 39 | |
| 38 | 40 | 
    def has_assets_dir?  | 
| 39 | 
          File.directory?(@assets_dir)
   | 
|
| 41 | 
          assets_dir.any?{|dir| File.directory?(dir)}
   | 
|
| 40 | 42 | 
    end  | 
| 41 | 43 | |
| 42 | 44 | 
    def has_initializer?  | 
| test/unit/lib/redmine/plugin_test.rb | ||
|---|---|---|
| 59 | 59 | 
    assert_equal 'http://example.net/jsmith', plugin.author_url  | 
| 60 | 60 | 
    assert_equal 'This is a test plugin', plugin.description  | 
| 61 | 61 | 
    assert_equal '0.0.1', plugin.version  | 
| 62 | 
    assert_equal File.join(@klass.directory, 'foo_plugin', 'assets'), plugin.assets_directory  | 
|
| 62 | 
        assert plugin.assets_directory.find{|dir| dir == File.join(@klass.directory, 'foo_plugin', 'assets')}
   | 
|
| 63 | 
        assert plugin.assets_directory.find{|dir| dir == File.join(@klass.directory, 'foo_plugin', 'app', 'assets')}
   | 
|
| 63 | 64 | 
    end  | 
| 64 | 65 | |
| 65 | 66 | 
    ::FooModel = Class.new(ApplicationRecord)  |