Project

General

Profile

Defect #41726 » 0001-Set-either-app-assets-or-assets-as-assets_dir.patch

Takashi Kato, 2024-11-11 11:06

View differences:

lib/redmine/plugin_loader.rb
21 21
  class PluginPath
22 22
    attr_reader :assets_dir, :initializer
23 23

  
24
    ASSET_PATHS = ['app/assets', 'assets']
25

  
24 26
    def initialize(dir)
25 27
      @dir = dir
26
      @assets_dir = File.join dir, 'assets'
28
      @assets_dir = find_assets_dir dir
27 29
      @initializer = File.join dir, 'init.rb'
28 30
    end
29 31

  
......
35 37
      @dir
36 38
    end
37 39

  
40
    def find_assets_dir(dir)
41
      paths = ASSET_PATHS.filter_map do |entry|
42
        path = Pathname.new(dir).join(entry)
43
        path if path.exist? && path.directory?
44
      end
45
      paths.first
46
    end
47

  
38 48
    def has_assets_dir?
39
      File.directory?(@assets_dir)
49
      return false unless assets_dir
50

  
51
      File.directory?(assets_dir)
40 52
    end
41 53

  
42 54
    def has_initializer?
(2-2/2)