redmine_plugin_asset_pipeline 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/redmine_pipeline/private_assets_initializer/templates/35-patch_assets_mirror.rb +6 -0
- data/lib/redmine_plugin_asset_pipeline.rb +46 -0
- data/lib/redmine_plugin_asset_pipeline/application_helper_patch.rb +7 -7
- data/lib/redmine_plugin_asset_pipeline/plugin_patch.rb +30 -28
- data/lib/redmine_plugin_asset_pipeline/sprockets_processor.rb +28 -0
- data/lib/redmine_plugin_asset_pipeline/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32c6c1262932a660105027633a4db9595fad559d
|
4
|
+
data.tar.gz: 2858b901fdcb9c87e905f11f8fc971ca3a093e7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c4fbcc94210ccf17a0292abeef07d2751f4bcad8b4425811ca857b910baccb401ce9198b785ac2ac081e6437be0f8377cae9eea0bd2b7d92132ddbae5dd4d0a
|
7
|
+
data.tar.gz: bc4d527cf689a5547ae7921457f5204e6d1e5cdae71b14ecf81e42cc38b2aca6221a90686e0d41d4bfa85246a525525ca0a2d4420053df4d3a1db565a52951aa
|
data/README.md
CHANGED
data/lib/generators/redmine_pipeline/private_assets_initializer/templates/35-patch_assets_mirror.rb
CHANGED
@@ -3,4 +3,10 @@ Rails.configuration.before_configuration do
|
|
3
3
|
unless Redmine::Plugin.included_modules.include? RedminePluginAssetPipeline::PluginPatch
|
4
4
|
Redmine::Plugin.send(:include, RedminePluginAssetPipeline::PluginPatch)
|
5
5
|
end
|
6
|
+
end
|
7
|
+
|
8
|
+
RedminePluginAssetPipeline.configure do |config|
|
9
|
+
if Rails.env.development?
|
10
|
+
config.use_ln = true
|
11
|
+
end
|
6
12
|
end
|
@@ -1,6 +1,27 @@
|
|
1
1
|
require 'redmine_plugin_asset_pipeline/version'
|
2
2
|
|
3
3
|
module RedminePluginAssetPipeline
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :use_ln
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@use_ln = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](value)
|
12
|
+
self.public_send(value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
self.config ||= Configuration.new
|
18
|
+
yield(self.config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.config
|
22
|
+
@config
|
23
|
+
end
|
24
|
+
|
4
25
|
# Run the classic redmine plugin initializer after rails boot
|
5
26
|
class Plugin < ::Rails::Engine
|
6
27
|
config.after_initialize do
|
@@ -23,9 +44,34 @@ module RedminePluginAssetPipeline
|
|
23
44
|
end
|
24
45
|
end
|
25
46
|
|
47
|
+
#add all plugin directories in case some js/css/images are included directly or via relative css
|
48
|
+
#it also avoids Sprocket's FileOutsidePaths errors
|
49
|
+
# config.assets.paths += Dir.glob("#{config.root}/plugins/*/assets")
|
50
|
+
#add our directory
|
51
|
+
# config.assets.paths += Dir.glob("#{File.dirname(__FILE__)}/assets")
|
52
|
+
#compression
|
53
|
+
# config.assets.compress = true
|
54
|
+
# config.assets.css_compressor = :yui
|
55
|
+
# config.assets.js_compressor = :yui
|
56
|
+
|
57
|
+
# Register our processor (subclass of the standard one which adds a directive for redmine plugins)
|
58
|
+
initializer 'redmine.sprockets_processor', after: 'sprockets.environment' do
|
59
|
+
require 'redmine_plugin_asset_pipeline/sprockets_processor'
|
60
|
+
env = RedmineApp::Application.assets
|
61
|
+
env.unregister_preprocessor('text/css', Sprockets::DirectiveProcessor)
|
62
|
+
env.unregister_preprocessor('application/javascript', Sprockets::DirectiveProcessor)
|
63
|
+
env.register_preprocessor('text/css', RedminePluginAssetPipeline::SprocketsProcessor)
|
64
|
+
env.register_preprocessor('application/javascript', RedminePluginAssetPipeline::SprocketsProcessor)
|
65
|
+
end
|
66
|
+
|
26
67
|
config.to_prepare do
|
27
68
|
require_dependency 'redmine_plugin_asset_pipeline/application_helper_patch'
|
28
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
29
73
|
|
74
|
+
def self.config=(value)
|
75
|
+
@config = value
|
30
76
|
end
|
31
77
|
end
|
@@ -19,10 +19,10 @@ module ApplicationHelper
|
|
19
19
|
sources.collect do |source|
|
20
20
|
if debug && asset = asset_for(source, 'css')
|
21
21
|
asset.to_a.map { |dep|
|
22
|
-
super(dep.pathname.to_s, { :
|
22
|
+
super(dep.pathname.to_s, { href: asset_path(dep, ext: 'css', body: true, protocol: :request, digest: digest) }.merge!(options))
|
23
23
|
}
|
24
24
|
else
|
25
|
-
super(source.to_s, { :
|
25
|
+
super(source.to_s, { href: asset_path(source, ext: 'css', body: body, protocol: :request, digest: digest) }.merge!(options))
|
26
26
|
end
|
27
27
|
end.flatten.uniq.join("\n").html_safe
|
28
28
|
end
|
@@ -43,10 +43,10 @@ module ApplicationHelper
|
|
43
43
|
sources.collect do |source|
|
44
44
|
if debug && asset = asset_for(source, 'js')
|
45
45
|
asset.to_a.map { |dep|
|
46
|
-
super(dep.pathname.to_s, { :
|
46
|
+
super(dep.pathname.to_s, { src: asset_path(dep, ext: 'js', body: true, digest: digest) }.merge!(options))
|
47
47
|
}
|
48
48
|
else
|
49
|
-
super(source.to_s, { :
|
49
|
+
super(source.to_s, { src: asset_path(source, ext: 'js', body: body, digest: digest) }.merge!(options))
|
50
50
|
end
|
51
51
|
end.flatten.uniq.join("\n").html_safe
|
52
52
|
end
|
@@ -67,7 +67,7 @@ module ApplicationHelper
|
|
67
67
|
@calendar_headers_tags_included = true
|
68
68
|
content_for :header_tags do
|
69
69
|
start_of_week = Setting.start_of_week
|
70
|
-
start_of_week = l(:general_first_day_of_week, :
|
70
|
+
start_of_week = l(:general_first_day_of_week, default: '1') if start_of_week.blank?
|
71
71
|
# Redmine uses 1..7 (monday..sunday) in settings and locales
|
72
72
|
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
|
73
73
|
start_of_week = start_of_week.to_i % 7
|
@@ -77,7 +77,7 @@ module ApplicationHelper
|
|
77
77
|
"showOn: 'button', buttonImageOnly: true, buttonImage: '" +
|
78
78
|
path_to_image('images/calendar.png') +
|
79
79
|
"', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};")
|
80
|
-
jquery_locale = l('jquery.locale', :
|
80
|
+
jquery_locale = l('jquery.locale', default: current_language.to_s)
|
81
81
|
unless jquery_locale == 'en'
|
82
82
|
tags << javascript_include_tag("i18n/jquery.ui.datepicker-#{jquery_locale}.js")
|
83
83
|
end
|
@@ -105,7 +105,7 @@ module ApplicationHelper
|
|
105
105
|
|
106
106
|
def asset_path(source, options = {})
|
107
107
|
source = source.logical_path if source.respond_to?(:logical_path)
|
108
|
-
path = asset_paths.compute_public_path(source, assets_prefix, options.merge(:
|
108
|
+
path = asset_paths.compute_public_path(source, assets_prefix, options.merge(body: true))
|
109
109
|
options[:body] ? "#{path}?body=1" : path
|
110
110
|
end
|
111
111
|
|
@@ -33,38 +33,40 @@ module RedminePluginAssetPipeline
|
|
33
33
|
end
|
34
34
|
return unless File.directory?(source)
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
if RedminePluginAssetPipeline.config.use_ln
|
37
|
+
FileUtils.ln_s(source, destination)
|
38
|
+
else
|
39
|
+
source_files = Dir[source + "/**/*"]
|
40
|
+
source_dirs = source_files.select { |d| File.directory?(d) }
|
41
|
+
source_files -= source_dirs
|
42
|
+
unless source_files.empty?
|
43
|
+
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
|
44
|
+
begin
|
45
|
+
FileUtils.mkdir_p(base_target_dir)
|
46
|
+
rescue Exception => e
|
47
|
+
raise "Could not create directory #{base_target_dir}: " + e.message
|
48
|
+
end
|
46
49
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
raise "Could not create directory #{target_dir}: " + e.message
|
50
|
+
source_dirs.each do |dir|
|
51
|
+
# strip down these paths so we have simple, relative paths we can
|
52
|
+
# add to the destination
|
53
|
+
target_dir = File.join(destination, dir.gsub(source, ''))
|
54
|
+
begin
|
55
|
+
FileUtils.mkdir_p(target_dir)
|
56
|
+
rescue Exception => e
|
57
|
+
raise "Could not create directory #{target_dir}: " + e.message
|
58
|
+
end
|
57
59
|
end
|
58
|
-
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
source_files.each do |file|
|
62
|
+
begin
|
63
|
+
target = File.join(destination, file.gsub(source, ''))
|
64
|
+
unless File.exist?(target) && FileUtils.identical?(file, target)
|
65
|
+
FileUtils.cp(file, target)
|
66
|
+
end
|
67
|
+
rescue Exception => e
|
68
|
+
raise "Could not copy #{file} to #{target}: " + e.message
|
65
69
|
end
|
66
|
-
rescue Exception => e
|
67
|
-
raise "Could not copy #{file} to #{target}: " + e.message
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RedminePluginAssetPipeline
|
2
|
+
class SprocketsProcessor < Sprockets::DirectiveProcessor
|
3
|
+
# This processor subclasses the standard Sprockets::DirectiveProcessor
|
4
|
+
# as advised in Sprockets, to add a new directive called
|
5
|
+
# "require_redmine_plugins". This directive is relative to the
|
6
|
+
# #{Rails.root}/plugins/ directory and accepts wildcards.
|
7
|
+
#
|
8
|
+
# For convenience, it also replaces "ALL" by a star ("*") before
|
9
|
+
# evaluating the globing. Otherwise, "*/" is interpreted as the end of
|
10
|
+
# the comment in CSS files, which is obviously problematic.
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# For the record, here's the example custom require provided in sprockets:
|
14
|
+
#
|
15
|
+
# def process_require_glob_directive
|
16
|
+
# Dir["#{pathname.dirname}/#{glob}"].sort.each do |filename|
|
17
|
+
# require(filename)
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
def process_require_redmine_plugins_directive(type)
|
22
|
+
mask = Rails.root.join(Redmine::Plugin.private_directory, "*/#{type}/_common_part*").expand_path
|
23
|
+
Dir.glob(mask).sort.each do |entry|
|
24
|
+
context.require_asset(pathname.dirname.join(entry).expand_path)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_plugin_asset_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tab10id
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/redmine_plugin_asset_pipeline.rb
|
57
57
|
- lib/redmine_plugin_asset_pipeline/application_helper_patch.rb
|
58
58
|
- lib/redmine_plugin_asset_pipeline/plugin_patch.rb
|
59
|
+
- lib/redmine_plugin_asset_pipeline/sprockets_processor.rb
|
59
60
|
- lib/redmine_plugin_asset_pipeline/version.rb
|
60
61
|
- redmine_plugin_asset_pipeline.gemspec
|
61
62
|
- test/test_helper.rb
|