redmine_plugin_asset_pipeline 0.2.0 → 0.2.1

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/Gemfile +2 -0
  4. data/README.md +1 -1
  5. data/lib/generators/redmine_plugin_asset_pipeline/initializers/initializers_generator.rb +16 -0
  6. data/lib/generators/redmine_plugin_asset_pipeline/initializers/templates/09-save_original_path_to_asset.rb +11 -0
  7. data/lib/generators/redmine_plugin_asset_pipeline/initializers/templates/15-restore_original_path_to_asset.rb +11 -0
  8. data/lib/generators/redmine_plugin_asset_pipeline/initializers/templates/28-patch_redmine_plugin_for_sprockets.rb +5 -0
  9. data/lib/redmine_plugin_asset_pipeline.rb +3 -16
  10. data/lib/redmine_plugin_asset_pipeline/infectors.rb +9 -4
  11. data/lib/redmine_plugin_asset_pipeline/infectors/application_helper.rb +92 -83
  12. data/lib/redmine_plugin_asset_pipeline/infectors/redmine.rb +11 -5
  13. data/lib/redmine_plugin_asset_pipeline/infectors/redmine/plugin.rb +63 -56
  14. data/lib/redmine_plugin_asset_pipeline/plugin.rb +45 -41
  15. data/lib/redmine_plugin_asset_pipeline/sprockets_processor.rb +15 -6
  16. data/lib/redmine_plugin_asset_pipeline/version.rb +3 -1
  17. data/redmine_plugin_asset_pipeline.gemspec +9 -9
  18. metadata +20 -39
  19. data/Rakefile +0 -1
  20. data/init.rb +0 -7
  21. data/lib/generators/redmine_pipeline/private_assets_initializer/private_assets_initializer_generator.rb +0 -11
  22. data/lib/generators/redmine_pipeline/private_assets_initializer/templates/09-unpatch_10_patches.rb +0 -7
  23. data/lib/generators/redmine_pipeline/private_assets_initializer/templates/25-patch_assets_mirror.rb +0 -20
  24. data/lib/redmine_plugin_asset_pipeline/configuration.rb +0 -11
  25. data/lib/redmine_plugin_asset_pipeline/infectors/redmine/themes.rb +0 -4
  26. data/lib/redmine_plugin_asset_pipeline/infectors/redmine/themes/theme.rb +0 -7
  27. data/test/test_helper.rb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffcd3856eb4d11cdb694dae4afa70bf45370a69fdb088cbca9e6196b96e9f0fc
4
- data.tar.gz: e21850d1c631583c5b2e1a2a92557511fb3a3e32d28f042b53b17e5b933b74de
3
+ metadata.gz: d7d1a03fb7135a16db604b8360a66eba81f3c977df4045cc3b6d4f517f9ac86f
4
+ data.tar.gz: 9fddbed14c4cd27b1c048cbda5095b38d3566a66f7335aed3ac2e6e781f4ef54
5
5
  SHA512:
6
- metadata.gz: 6651a7e5fb0cb81234fb1cac4267e1a4e42bd663cabe892f0578fb65f86e5cf62bad7c0e5616e7d0273d23757254e77d35d835bc2b4061314ec9aa2a8a259b77
7
- data.tar.gz: 24212ae60dbba13c33f45b93d3f907cf57d934bf817db3dbcdb31d153eb1d83342738fccefa649d5fd686f16a08facb1dae93113b48f95ac334fb1b9331f7fd7
6
+ metadata.gz: 3691542db719c734b09bf8c5648fc2c1cff2f313acdd6b382a08c5747c8cfc931225f9c615087973eea28090a44204b9e9ec7ce6fa648d976d4154c35818f496
7
+ data.tar.gz: e14659ccd62485ca8a841be9491fcc2a7181c177f2bcba47a205c32e43a3d49a1af0b4b17e7c70e909d06b0164b45b95cde8a02e139f4e164546037dbd2c3da2
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Naming/FileName:
5
+ Exclude:
6
+ - 'lib/generators/redmine_plugin_asset_pipeline/initializers/templates/**'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec :path => File.dirname(__FILE__)
data/README.md CHANGED
@@ -67,7 +67,7 @@ Our recommendations:
67
67
 
68
68
  * Move redmine assets to directory `private/assets` (simple create it in root of Redmine)
69
69
  * Run `rails generate redmine_pipeline:private_assets_initializer` (that create initializers
70
- `09-unpatch-10-patches` and `25-patch_assets_mirror`, that patch Plugin class of Redmine for copy plugin assets to
70
+ `09-save_original_path_to_asset`, `15-restore_original_path_to_asset` and `28-patch_redmine_plugin_for_sprockets`, that patch Plugin class of Redmine for copy plugin assets to
71
71
  private directory and cancel redmine patch that broke sprockets)
72
72
  * Fix standard Redmine \*.css files (some paths in css hardcoded to the public root)
73
73
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedminePluginAssetPipeline
4
+ # :nodoc:
5
+ class InitializersGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def copy_initializer_file
9
+ save = '09-save_original_path_to_asset'
10
+ copy_file "#{save}.rb", "config/initializers/#{save}.rb"
11
+
12
+ restore = '25-restore_original_path_to_asset'
13
+ copy_file "#{restore}.rb", "config/initializers/#{restore}.rb"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ # save original method before it will overridden
6
+ # (in 10-patches initializer in redmine)
7
+ module AssetUrlHelper
8
+ alias original_path_to_asset path_to_asset
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ # return original method after override
6
+ # (in 10-patches initializer in redmine)
7
+ module AssetUrlHelper
8
+ alias path_to_asset original_path_to_asset
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'redmine/plugin'
4
+
5
+ Redmine::Plugin.include(RedminePluginAssetPipeline::Infectors::Redmine::Plugin)
@@ -1,24 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'redmine_plugin_asset_pipeline/version'
2
4
  require 'redmine_plugin_asset_pipeline/plugin'
3
5
 
6
+ # Library for activate asset pipeline in redmine
4
7
  module RedminePluginAssetPipeline
5
8
  extend ActiveSupport::Autoload
6
9
  autoload :Configuration
7
10
  autoload :Infectors
8
- autoload :Rails
9
-
10
- def self.configure
11
- self.config ||= Configuration.new
12
- yield(self.config)
13
- end
14
-
15
- def self.config
16
- @config
17
- end
18
-
19
- private
20
-
21
- def self.config=(value)
22
- @config = value
23
- end
24
11
  end
@@ -1,5 +1,10 @@
1
- module RedminePluginAssetPipeline::Infectors
2
- extend ActiveSupport::Autoload
3
- autoload :Redmine
4
- autoload :ApplicationHelper
1
+ # frozen_string_literal: true
2
+
3
+ module RedminePluginAssetPipeline
4
+ # collection of monkey patches
5
+ module Infectors
6
+ extend ActiveSupport::Autoload
7
+ autoload :Redmine
8
+ autoload :ApplicationHelper
9
+ end
5
10
  end
@@ -1,102 +1,111 @@
1
- module RedminePluginAssetPipeline::Infectors::ApplicationHelper
2
- extend ActiveSupport::Concern
1
+ # frozen_string_literal: true
3
2
 
4
- included do
5
- def stylesheet_link_tag(*sources)
6
- options = sources.last.is_a?(Hash) ? sources.pop : {}
7
- plugin = options.delete(:plugin)
8
- sources = sources.map do |source|
9
- if plugin
10
- "#{plugin}/stylesheets/#{source}"
11
- elsif current_theme && current_theme.stylesheets.include?(source)
12
- current_theme.stylesheet_path(source)
13
- else
14
- # @note: assets from gems
15
- [source, "stylesheets/#{source}"].find do |s|
16
- asset_digest_path("#{s}#{compute_asset_extname(s, type: :stylesheet)}").present?
17
- end || source
3
+ module RedminePluginAssetPipeline
4
+ module Infectors
5
+ # Collection of monkey patches for ApplicationHelper of redmine
6
+ # several fixes for using sprockets context
7
+ module ApplicationHelper
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ def stylesheet_link_tag(*sources)
12
+ options = sources.last.is_a?(Hash) ? sources.pop : {}
13
+ plugin = options.delete(:plugin)
14
+ sources = sources.map do |source|
15
+ if plugin
16
+ "#{plugin}/stylesheets/#{source}"
17
+ elsif current_theme && current_theme.stylesheets.include?(source)
18
+ current_theme.stylesheet_path(source)
19
+ else
20
+ # @note: assets from gems
21
+ [source, "stylesheets/#{source}"].find do |s|
22
+ asset_digest_path("#{s}#{compute_asset_extname(s, type: :stylesheet)}").present?
23
+ end || source
24
+ end
25
+ end
26
+ sprockets_helper_context.stylesheet_link_tag(*sources, options)
18
27
  end
19
- end
20
- sprockets_helper_context.stylesheet_link_tag(*sources, options)
21
- end
22
28
 
23
- def javascript_include_tag(*sources)
24
- options = sources.last.is_a?(Hash) ? sources.pop : {}
25
- plugin = options.delete(:plugin)
26
- sources = sources.map do |source|
27
- if plugin
28
- "#{plugin}/javascripts/#{source}"
29
- else
30
- # @note: assets from gems
31
- [source, "javascripts/#{source}"].find do |s|
32
- asset_digest_path("#{s}#{compute_asset_extname(s, type: :javascript)}").present?
33
- end || source
29
+ def javascript_include_tag(*sources)
30
+ options = sources.last.is_a?(Hash) ? sources.pop : {}
31
+ plugin = options.delete(:plugin)
32
+ sources = sources.map do |source|
33
+ if plugin
34
+ "#{plugin}/javascripts/#{source}"
35
+ else
36
+ # @note: assets from gems
37
+ [source, "javascripts/#{source}"].find do |s|
38
+ asset_digest_path("#{s}#{compute_asset_extname(s, type: :javascript)}").present?
39
+ end || source
40
+ end
41
+ end
42
+ sprockets_helper_context.javascript_include_tag(*sources, options)
34
43
  end
35
- end
36
- sprockets_helper_context.javascript_include_tag(*sources, options)
37
- end
38
44
 
39
- def image_tag(source, options={})
40
- plugin = options.delete(:plugin)
41
- if plugin
42
- source = "#{plugin}/images/#{source}"
43
- elsif current_theme && current_theme.images.include?(source)
44
- source = current_theme.image_path(source)
45
- else
46
- source = [source, "images/#{source}"].find{ |s| asset_digest_path(s).present? } || source
47
- end
48
- sprockets_helper_context.image_tag(source, options)
49
- end
45
+ def image_tag(source, options={})
46
+ plugin = options.delete(:plugin)
47
+ if plugin
48
+ source = "#{plugin}/images/#{source}"
49
+ elsif current_theme && current_theme.images.include?(source)
50
+ source = current_theme.image_path(source)
51
+ else
52
+ source = [source, "images/#{source}"].find{ |s| asset_digest_path(s).present? } || source
53
+ end
54
+ sprockets_helper_context.image_tag(source, options)
55
+ end
50
56
 
51
- # Only one fix - remove leading slash in path_to_image
52
- def include_calendar_headers_tags
53
- unless @calendar_headers_tags_included
54
- tags = ''.html_safe
55
- @calendar_headers_tags_included = true
56
- content_for :header_tags do
57
- start_of_week = Setting.start_of_week
58
- start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
59
- # Redmine uses 1..7 (monday..sunday) in settings and locales
60
- # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
61
- start_of_week = start_of_week.to_i % 7
62
- tags << javascript_tag(
63
- "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
57
+ # Only one fix - remove leading slash in path_to_image
58
+ def include_calendar_headers_tags
59
+ unless @calendar_headers_tags_included
60
+ tags = ''.html_safe
61
+ @calendar_headers_tags_included = true
62
+ content_for :header_tags do
63
+ start_of_week = Setting.start_of_week
64
+ start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
65
+ # Redmine uses 1..7 (monday..sunday) in settings and locales
66
+ # JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
67
+ start_of_week = start_of_week.to_i % 7
68
+ tags << javascript_tag(
69
+ "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
64
70
  "showOn: 'button', buttonImageOnly: true, buttonImage: '" +
65
71
  path_to_image('images/calendar.png') +
66
72
  "', showButtonPanel: true, showWeek: true, showOtherMonths: true, " +
67
- "selectOtherMonths: true, changeMonth: true, changeYear: true, " +
68
- "beforeShow: beforeShowDatePicker};")
69
- jquery_locale = l('jquery.locale', :default => current_language.to_s)
70
- unless jquery_locale == 'en'
71
- tags << javascript_include_tag("i18n/datepicker-#{jquery_locale}.js")
73
+ 'selectOtherMonths: true, changeMonth: true, changeYear: true, ' +
74
+ 'beforeShow: beforeShowDatePicker};')
75
+ jquery_locale = l('jquery.locale', :default => current_language.to_s)
76
+ unless jquery_locale == 'en'
77
+ tags << javascript_include_tag("i18n/datepicker-#{jquery_locale}.js")
78
+ end
79
+ tags
80
+ end
72
81
  end
73
- tags
74
82
  end
75
- end
76
- end
77
83
 
78
- def sprockets_helper_context
79
- @context ||= Class.new do
80
- include Sprockets::Rails::Helper
81
- # Copy relevant config to AV context
82
- app = Rails.application
83
- config = app.config
84
+ def sprockets_helper_context
85
+ @context ||= Class.new do
86
+ include Sprockets::Rails::Helper
87
+ # Copy relevant config to AV context
88
+ app = Rails.application
89
+ config = app.config
84
90
 
85
- self.debug_assets = config.assets.debug
86
- self.digest_assets = config.assets.digest
87
- self.assets_prefix = config.assets.prefix
88
- self.assets_precompile = config.assets.precompile
91
+ self.debug_assets = config.assets.debug
92
+ self.digest_assets = config.assets.digest
93
+ self.assets_prefix = config.assets.prefix
94
+ self.assets_precompile = config.assets.precompile
89
95
 
90
- self.assets_environment = app.assets
91
- self.assets_manifest = app.assets_manifest
96
+ self.assets_environment = app.assets
97
+ self.assets_manifest = app.assets_manifest
92
98
 
93
- self.resolve_assets_with = config.assets.resolve_with
99
+ self.resolve_assets_with = config.assets.resolve_with
94
100
 
95
- self.check_precompiled_asset = config.assets.check_precompiled_asset
96
- self.unknown_asset_fallback = config.assets.unknown_asset_fallback
97
- # Expose the app precompiled asset check to the view
98
- self.precompiled_asset_checker = -> logical_path { app.asset_precompiled? logical_path }
99
- end.new
101
+ self.check_precompiled_asset = config.assets.check_precompiled_asset
102
+ self.unknown_asset_fallback = config.assets.unknown_asset_fallback
103
+ # Expose the app precompiled asset check to the view
104
+ self.precompiled_asset_checker = -> logical_path { app.asset_precompiled? logical_path }
105
+ end.new
106
+ end
107
+ end
100
108
  end
101
109
  end
102
110
  end
111
+
@@ -1,5 +1,11 @@
1
- module RedminePluginAssetPipeline::Infectors::Redmine
2
- extend ActiveSupport::Autoload
3
- autoload :Plugin
4
- autoload :Themes
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module RedminePluginAssetPipeline
4
+ module Infectors
5
+ # Collection of patches
6
+ module Redmine
7
+ extend ActiveSupport::Autoload
8
+ autoload :Plugin
9
+ end
10
+ end
11
+ end
@@ -1,69 +1,76 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Patch for copy plugin assets sources to private directory
2
- module RedminePluginAssetPipeline::Infectors::Redmine::Plugin
3
- extend ActiveSupport::Concern
4
+ module RedminePluginAssetPipeline
5
+ module Infectors
6
+ module Redmine
7
+ # Monkey Patch for Redmine::Plugin
8
+ # move assets from all plugins to separate directory
9
+ module Plugin
10
+ extend ActiveSupport::Concern
4
11
 
5
- included do
6
- alias_method :mirror_assets_to_public, :mirror_assets
7
- alias_method :mirror_assets, :mirror_assets_to_private
12
+ included do
13
+ alias_method :mirror_assets, :mirror_assets_to_private
8
14
 
9
- class << self
10
- cattr_accessor :private_directory_base
11
- self.private_directory_base = File.join(Rails.root, 'private', 'plugin_assets')
12
- end
13
- end
15
+ class << self
16
+ cattr_accessor :private_directory_base
14
17
 
15
- def private_directory
16
- File.join(self.class.private_directory_base, id.to_s)
17
- end
18
+ self.private_directory_base =
19
+ File.join(Rails.root, 'private', 'plugin_assets')
20
+ end
21
+ end
18
22
 
19
- def mirror_assets_to_private
20
- source = assets_directory
21
- destination = private_directory
23
+ def private_directory
24
+ File.join(self.class.private_directory_base, id.to_s)
25
+ end
22
26
 
23
- unless File.exist?(self.class.private_directory_base)
24
- FileUtils.mkdir_p(self.class.private_directory_base)
25
- end
27
+ def mirror_assets_to_private
28
+ source = assets_directory
29
+ destination = private_directory
26
30
 
27
- if File.exist?(destination)
28
- FileUtils.rm_rf(destination)
29
- end
30
- return unless File.directory?(source)
31
+ unless File.exist?(self.class.private_directory_base)
32
+ FileUtils.mkdir_p(self.class.private_directory_base)
33
+ end
31
34
 
32
- if RedminePluginAssetPipeline.config.use_ln
33
- if File.exist?(source)
34
- FileUtils.ln_s(source, destination)
35
- end
36
- else
37
- source_files = Dir[source + '/**/*']
38
- source_dirs = source_files.select { |d| File.directory?(d) }
39
- source_files -= source_dirs
40
- unless source_files.empty?
41
- base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
42
- begin
43
- FileUtils.mkdir_p(base_target_dir)
44
- rescue Exception => e
45
- raise "Could not create directory #{base_target_dir}: " + e.message
46
- end
47
- end
48
- source_dirs.each do |dir|
49
- # strip down these paths so we have simple, relative paths we can
50
- # add to the destination
51
- target_dir = File.join(destination, dir.gsub(source, ''))
52
- begin
53
- FileUtils.mkdir_p(target_dir)
54
- rescue Exception => e
55
- raise "Could not create directory #{target_dir}: " + e.message
56
- end
57
- end
35
+ FileUtils.rm_rf(destination) if File.exist?(destination)
36
+ return unless File.directory?(source)
37
+
38
+ if RedmineApp::Application.config.assets.compile
39
+ FileUtils.ln_s(source, destination) if File.exist?(source)
40
+ else
41
+ source_files = Dir[source + '/**/*']
42
+ source_dirs = source_files.select { |d| File.directory?(d) }
43
+ source_files -= source_dirs
44
+ unless source_files.empty?
45
+ base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
46
+ begin
47
+ FileUtils.mkdir_p(base_target_dir)
48
+ rescue StandardError => e
49
+ raise "Could not create directory #{base_target_dir}: " + e.message
50
+ end
51
+ end
52
+ source_dirs.each do |dir|
53
+ # strip down these paths so we have simple, relative paths we can
54
+ # add to the destination
55
+ target_dir = File.join(destination, dir.gsub(source, ''))
56
+ begin
57
+ FileUtils.mkdir_p(target_dir)
58
+ rescue StandardError => e
59
+ raise "Could not create directory #{target_dir}: " + e.message
60
+ end
61
+ end
58
62
 
59
- source_files.each do |file|
60
- begin
61
- target = File.join(destination, file.gsub(source, ''))
62
- unless File.exist?(target) && FileUtils.identical?(file, target)
63
- FileUtils.cp(file, target)
63
+ source_files.each do |file|
64
+ begin
65
+ target = File.join(destination, file.gsub(source, ''))
66
+ unless File.exist?(target) && FileUtils.identical?(file, target)
67
+ FileUtils.cp(file, target)
68
+ end
69
+ rescue StandardError => e
70
+ raise "Could not copy #{file} to #{target}: " + e.message
71
+ end
72
+ end
64
73
  end
65
- rescue Exception => e
66
- raise "Could not copy #{file} to #{target}: " + e.message
67
74
  end
68
75
  end
69
76
  end
@@ -1,49 +1,53 @@
1
- class RedminePluginAssetPipeline::Plugin < ::Rails::Engine
2
- config.after_initialize do
3
- require File.expand_path('../../../init', __FILE__)
4
- end
1
+ # frozen_string_literal: true
5
2
 
6
- #asset pipeline configuration
7
- #enable asset pipeline before sprockets boots
8
- initializer 'redmine.asset_pipeline', before: 'sprockets.environment' do
9
- RedmineApp::Application.configure do
10
- config.assets.paths << "#{config.root}/private/plugin_assets"
11
- config.assets.precompile += %w(*/stylesheets/*.css */javascripts/*.js */images/* */fonts/*)
12
- # Custom settings. Edit configs of your application
13
- # See: http://guides.rubyonrails.org/asset_pipeline.html
14
- #
15
- # Redmine save all assets in root of public =(
16
- # If you need to change that value
17
- # manually move assets in public directory and edit it
18
- # config.assets.prefix = ''
19
- end
20
- end
3
+ require 'redmine_plugin_asset_pipeline/sprockets_processor'
21
4
 
22
- #add all plugin directories in case some js/css/images are included directly or via relative css
23
- #it also avoids Sprocket's FileOutsidePaths errors
24
- # config.assets.paths += Dir.glob("#{config.root}/plugins/*/assets")
25
- #add our directory
26
- # config.assets.paths += Dir.glob("#{File.dirname(__FILE__)}/assets")
27
- #compression
28
- # config.assets.compress = true
29
- # config.assets.css_compressor = :yui
30
- # config.assets.js_compressor = :yui
5
+ module RedminePluginAssetPipeline
6
+ # Initialize Sprockets
7
+ # Register `require_redmine_plugins` directives
8
+ # MonkeyPatching of `ApplicationHelper`
9
+ class Plugin < ::Rails::Engine
10
+ # asset pipeline configuration
11
+ # enable asset pipeline before sprockets boots
12
+ initializer 'redmine.asset_pipeline', before: 'sprockets.environment' do
13
+ RedmineApp::Application.configure do
14
+ config.assets.paths << "#{config.root}/private/plugin_assets"
15
+ config.assets.precompile +=
16
+ %w[*/stylesheets/*.css */javascripts/*.js */images/* */fonts/*]
17
+ end
18
+ end
31
19
 
32
- # Register our processor (subclass of the standard one which adds a directive for redmine plugins)
33
- initializer 'redmine.sprockets_processor', after: 'sprockets.environment' do
34
- require 'redmine_plugin_asset_pipeline/sprockets_processor'
35
- RedmineApp::Application.config.assets.configure do |env|
36
- env.unregister_preprocessor('text/css', Sprockets::DirectiveProcessor)
37
- env.unregister_preprocessor('application/javascript', Sprockets::DirectiveProcessor)
38
- env.register_preprocessor('text/css', RedminePluginAssetPipeline::SprocketsProcessor)
39
- env.register_preprocessor('application/javascript', RedminePluginAssetPipeline::SprocketsProcessor)
20
+ # Register our processor
21
+ # (subclass of the standard one which adds a directive for redmine plugins)
22
+ initializer 'redmine.sprockets_processor', after: 'sprockets.environment' do
23
+ RedmineApp::Application.config.assets.configure do |env|
24
+ env.unregister_preprocessor(
25
+ 'text/css',
26
+ Sprockets::DirectiveProcessor
27
+ )
28
+ env.register_preprocessor(
29
+ 'text/css',
30
+ RedminePluginAssetPipeline::SprocketsProcessor
31
+ )
32
+ env.unregister_preprocessor(
33
+ 'application/javascript',
34
+ Sprockets::DirectiveProcessor
35
+ )
36
+ env.register_preprocessor(
37
+ 'application/javascript',
38
+ RedminePluginAssetPipeline::SprocketsProcessor
39
+ )
40
+ end
40
41
  end
41
- end
42
42
 
43
- config.to_prepare do
44
- require_dependency 'application_helper'
45
- unless ApplicationHelper.included_modules.include? RedminePluginAssetPipeline::Infectors::ApplicationHelper
46
- ApplicationHelper.send(:include, RedminePluginAssetPipeline::Infectors::ApplicationHelper)
43
+ config.to_prepare do
44
+ require_dependency 'application_helper'
45
+
46
+ helper_patch = RedminePluginAssetPipeline::Infectors::ApplicationHelper
47
+
48
+ unless ApplicationHelper.included_modules.include?(helper_patch)
49
+ ApplicationHelper.include(helper_patch)
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -1,4 +1,6 @@
1
- class RedminePluginAssetPipeline::SprocketsProcessor < Sprockets::DirectiveProcessor
1
+ # frozen_string_literal: true
2
+
3
+ module RedminePluginAssetPipeline
2
4
  # This processor subclasses the standard Sprockets::DirectiveProcessor
3
5
  # as advised in Sprockets, to add a new directive called
4
6
  # "require_redmine_plugins". This directive is relative to the
@@ -16,11 +18,18 @@ class RedminePluginAssetPipeline::SprocketsProcessor < Sprockets::DirectiveProce
16
18
  # require(filename)
17
19
  # end
18
20
  # end
19
-
20
- def process_require_redmine_plugins_directive(type, prefix='')
21
- mask = Rails.root.join(Redmine::Plugin.private_directory_base, "*/#{type}/#{prefix}_common_part*").expand_path
22
- Dir.glob(mask).sort.each do |entry|
23
- context.require_asset(pathname.dirname.join(entry).expand_path)
21
+ class SprocketsProcessor < Sprockets::DirectiveProcessor
22
+ def process_require_redmine_plugins_directive(type, prefix = '')
23
+ assets_root = Rails.root.join(Redmine::Plugin.private_directory_base)
24
+ mask = assets_root.join("*/#{type}/#{prefix}_common_part*").expand_path
25
+ Dir.glob(mask).sort.each do |entry|
26
+ @required <<
27
+ resolve(
28
+ Pathname.new(entry).relative_path_from(assets_root).to_s,
29
+ accept: @content_type,
30
+ pipeline: :self
31
+ )
32
+ end
24
33
  end
25
34
  end
26
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RedminePluginAssetPipeline
2
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
3
5
  end
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'redmine_plugin_asset_pipeline/version'
5
6
 
@@ -8,18 +9,17 @@ Gem::Specification.new do |spec|
8
9
  spec.version = RedminePluginAssetPipeline::VERSION
9
10
  spec.authors = ['Tab10id']
10
11
  spec.email = ['tabloidmeister@gmail.com']
11
- spec.description = %q{Asset pipeline for Redmine}
12
- spec.summary = %q{Asset pipeline for Redmine}
12
+ spec.description = 'Asset pipeline for Redmine'
13
+ spec.summary = 'Asset pipeline for Redmine'
13
14
  spec.homepage = 'https://github.com/Tab10id/redmine_plugin_asset_pipeline'
14
15
  spec.license = 'MIT'
15
16
 
16
- spec.files = `git ls-files`.split($/)
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
20
  spec.require_paths = ['lib']
20
21
 
21
- spec.add_dependency 'actionview', '>= 4.0'
22
- spec.add_dependency 'sprockets', '>= 2.0'
23
- spec.add_development_dependency 'bundler', '~> 1.3'
24
- spec.add_development_dependency 'rake'
22
+ spec.add_dependency 'rails', '~> 5.2'
23
+ spec.add_dependency 'sprockets-rails', '~> 3.2'
24
+ spec.add_development_dependency 'bundler', '~> 2.0'
25
25
  end
metadata CHANGED
@@ -1,71 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugin_asset_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tab10id
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-30 00:00:00.000000000 Z
11
+ date: 2019-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: actionview
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: sprockets
28
+ name: sprockets-rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
54
+ version: '2.0'
69
55
  description: Asset pipeline for Redmine
70
56
  email:
71
57
  - tabloidmeister@gmail.com
@@ -74,27 +60,23 @@ extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
76
62
  - ".gitignore"
63
+ - ".rubocop.yml"
77
64
  - Gemfile
78
65
  - LICENSE.txt
79
66
  - README.md
80
- - Rakefile
81
- - init.rb
82
- - lib/generators/redmine_pipeline/private_assets_initializer/private_assets_initializer_generator.rb
83
- - lib/generators/redmine_pipeline/private_assets_initializer/templates/09-unpatch_10_patches.rb
84
- - lib/generators/redmine_pipeline/private_assets_initializer/templates/25-patch_assets_mirror.rb
67
+ - lib/generators/redmine_plugin_asset_pipeline/initializers/initializers_generator.rb
68
+ - lib/generators/redmine_plugin_asset_pipeline/initializers/templates/09-save_original_path_to_asset.rb
69
+ - lib/generators/redmine_plugin_asset_pipeline/initializers/templates/15-restore_original_path_to_asset.rb
70
+ - lib/generators/redmine_plugin_asset_pipeline/initializers/templates/28-patch_redmine_plugin_for_sprockets.rb
85
71
  - lib/redmine_plugin_asset_pipeline.rb
86
- - lib/redmine_plugin_asset_pipeline/configuration.rb
87
72
  - lib/redmine_plugin_asset_pipeline/infectors.rb
88
73
  - lib/redmine_plugin_asset_pipeline/infectors/application_helper.rb
89
74
  - lib/redmine_plugin_asset_pipeline/infectors/redmine.rb
90
75
  - lib/redmine_plugin_asset_pipeline/infectors/redmine/plugin.rb
91
- - lib/redmine_plugin_asset_pipeline/infectors/redmine/themes.rb
92
- - lib/redmine_plugin_asset_pipeline/infectors/redmine/themes/theme.rb
93
76
  - lib/redmine_plugin_asset_pipeline/plugin.rb
94
77
  - lib/redmine_plugin_asset_pipeline/sprockets_processor.rb
95
78
  - lib/redmine_plugin_asset_pipeline/version.rb
96
79
  - redmine_plugin_asset_pipeline.gemspec
97
- - test/test_helper.rb
98
80
  homepage: https://github.com/Tab10id/redmine_plugin_asset_pipeline
99
81
  licenses:
100
82
  - MIT
@@ -118,5 +100,4 @@ rubygems_version: 3.0.3
118
100
  signing_key:
119
101
  specification_version: 4
120
102
  summary: Asset pipeline for Redmine
121
- test_files:
122
- - test/test_helper.rb
103
+ test_files: []
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
data/init.rb DELETED
@@ -1,7 +0,0 @@
1
- Redmine::Plugin.register :redmine_plugin_asset_pipeline do
2
- name 'Redmine Plugin Asset Pipeline plugin'
3
- description 'This plugin adds asset pipeline support for redmine plugins'
4
- url 'https://github.com/Tab10id/redmine_plugin_asset_pipeline'
5
- version RedminePluginAssetPipeline::VERSION
6
- requires_redmine version_or_higher: '3.0.0'
7
- end
@@ -1,11 +0,0 @@
1
- module RedminePipeline
2
- class PrivateAssetsInitializerGenerator < Rails::Generators::Base
3
- source_root File.expand_path("../templates", __FILE__)
4
- def copy_initializer_file
5
- unpatch = '09-unpatch_10_patches'
6
- copy_file "#{unpatch}.rb", "config/initializers/#{unpatch}.rb"
7
- patch = '25-patch_assets_mirror'
8
- copy_file "#{patch}.rb", "config/initializers/#{patch}.rb"
9
- end
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- module ActionView
2
- module Helpers
3
- module AssetUrlHelper
4
- alias original_path_to_asset path_to_asset
5
- end
6
- end
7
- end
@@ -1,20 +0,0 @@
1
- Rails.configuration.before_configuration do
2
- require_dependency 'redmine_plugin_asset_pipeline/plugin_patch'
3
- unless Redmine::Plugin.included_modules.include? RedminePluginAssetPipeline::PluginPatch
4
- Redmine::Plugin.send(:include, RedminePluginAssetPipeline::PluginPatch)
5
- end
6
- end
7
-
8
- RedminePluginAssetPipeline.configure do |config|
9
- if Rails.env.development?
10
- config.use_ln = true
11
- end
12
- end
13
-
14
- module ActionView
15
- module Helpers
16
- module AssetUrlHelper
17
- alias path_to_asset original_path_to_asset
18
- end
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- class RedminePluginAssetPipeline::Configuration
2
- attr_accessor :use_ln
3
-
4
- def initialize
5
- @use_ln = false
6
- end
7
-
8
- def [](value)
9
- self.public_send(value)
10
- end
11
- end
@@ -1,4 +0,0 @@
1
- module RedminePluginAssetPipeline::Infectors::Redmine::Themes
2
- extend ActiveSupport::Autoload
3
- autoload :Theme
4
- end
@@ -1,7 +0,0 @@
1
- class RedminePluginAssetPipeline::Infectors::Redmine::Themes::Theme
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
-
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- # Load the normal Rails helper
2
- require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')