redmine_plugin_asset_pipeline 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +1 -0
- data/init.rb +10 -0
- data/lib/generators/redmine_pipeline/private_assets_initializer/private_assets_initializer_generator.rb +9 -0
- data/lib/generators/redmine_pipeline/private_assets_initializer/templates/35-patch_assets_mirror.rb +6 -0
- data/lib/redmine_plugin_asset_pipeline.rb +44 -0
- data/lib/redmine_plugin_asset_pipeline/application_helper_patch.rb +54 -0
- data/lib/redmine_plugin_asset_pipeline/plugin_patch.rb +70 -0
- data/lib/redmine_plugin_asset_pipeline/version.rb +3 -0
- data/redmine_plugin_asset_pipeline.gemspec +23 -0
- data/test/test_helper.rb +2 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8607b90303306caa6ac05676ebedc9c1c93e151
|
4
|
+
data.tar.gz: b3784b2ab2839be947d3c33107beeac1e3911b9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c13d262d64bec8c75d3825756bb14bb8200b539fd1e95488f1cf1cb91fce1e12ecd40e59e90f8b6c343646182763337bb7012bbae33a8002b5a575a334e90b1
|
7
|
+
data.tar.gz: 7d017dc542ca8ca39d787c739f264363d00212fc1bcb8f37d15f05bb9b65a7bb174794ee8bb16ec76094f5a16ea5073ebf42716b4d0f265c71f9ead7c871b9d4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 jbbarth
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Redmine Asset Pipeline plugin
|
2
|
+
=============================
|
3
|
+
|
4
|
+
This plugin adds asset pipeline awesomeness to Redmine and Redmine plugins.
|
5
|
+
|
6
|
+
For who ?
|
7
|
+
---------
|
8
|
+
This plugin only targets plugin developers. You shouldn't try to install this without a deep understanding of the benefits and the way to make it work.
|
9
|
+
|
10
|
+
Why ?
|
11
|
+
-----
|
12
|
+
By default, Redmine made the deliberate (and wise) choice to disable the asset pipeline for core development. Enabling the asset pipeline by default would bring a thousand questions for people who are not in Rails and have a deep understanding of how it works. See [some of my thoughs about this here](http://www.redmine.org/issues/11445#note-9).
|
13
|
+
|
14
|
+
Having the asset pipeline enabled would be interesting though if you have a lot of plugins, which is my case. The average page on my biggest Redmine instance downloads ~50 js/css individual files, which is a big waste in terms of performance and bandwith. I'd really like them to be minified and bundled into one application.js and one application.css.
|
15
|
+
|
16
|
+
How ?
|
17
|
+
-----
|
18
|
+
The plugin reconfigures asset-related options in the main app.
|
19
|
+
|
20
|
+
Features of this plugin
|
21
|
+
-----------------------
|
22
|
+
* serve main app assets with the asset pipeline : disabled
|
23
|
+
* serve plugin assets with the asset pipeline : disabled for standard plugins ; enabled for redmine gems
|
24
|
+
* minify assets in the pipeline : disabled
|
25
|
+
* concatenate all plugin assets into one js + one css : ok for redmine gems
|
26
|
+
* concatenate core resources with the ones of plugins : abandonned (useless)
|
27
|
+
* compile coffeescript/sass/etc. : not tested yet
|
28
|
+
|
29
|
+
Known problems
|
30
|
+
--------------
|
31
|
+
* for now it seems that all_plugins.js loads everything already loaded in all_core.js, resulting in unecessary wasted bandwith.
|
32
|
+
|
33
|
+
Installation
|
34
|
+
------------
|
35
|
+
|
36
|
+
This plugin is only compatible with Redmine 2.1.0+. It is distributed as a ruby gem.
|
37
|
+
|
38
|
+
Add this line to your redmine's Gemfile.local:
|
39
|
+
|
40
|
+
gem 'redmine_asset_pipeline'
|
41
|
+
|
42
|
+
And then execute:
|
43
|
+
|
44
|
+
$ bundle install
|
45
|
+
|
46
|
+
Then restart your Redmine instance.
|
47
|
+
|
48
|
+
Note that general instructions for plugins [here](http://www.redmine.org/wiki/redmine/Plugins) don't apply here.
|
49
|
+
|
50
|
+
Contributing
|
51
|
+
------------
|
52
|
+
|
53
|
+
1. Fork it
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/init.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'redmine'
|
2
|
+
require 'redmine_plugin_asset_pipeline/version'
|
3
|
+
|
4
|
+
Redmine::Plugin.register :redmine_plugin_asset_pipeline do
|
5
|
+
name 'Redmine Plugin Asset Pipeline plugin'
|
6
|
+
description 'This plugin adds asset pipeline support for redmine plugins'
|
7
|
+
url 'https://github.com/Tab10id/redmine_plugin_asset_pipeline'
|
8
|
+
version RedminePluginAssetPipeline::VERSION
|
9
|
+
requires_redmine :version_or_higher => '2.1.0'
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module RedminePipeline
|
2
|
+
class PrivateAssetsInitializerGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("../templates", __FILE__)
|
4
|
+
def copy_initializer_file
|
5
|
+
file_name = '35-patch_assets_mirror'
|
6
|
+
copy_file "#{file_name}.rb", "config/initializers/#{file_name}.rb"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/generators/redmine_pipeline/private_assets_initializer/templates/35-patch_assets_mirror.rb
ADDED
@@ -0,0 +1,6 @@
|
|
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
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'redmine_plugin_asset_pipeline/version'
|
2
|
+
|
3
|
+
module RedminePluginAssetPipeline
|
4
|
+
# Run the classic redmine plugin initializer after rails boot
|
5
|
+
class Plugin < ::Rails::Engine
|
6
|
+
config.after_initialize do
|
7
|
+
require File.expand_path('../../init', __FILE__)
|
8
|
+
end
|
9
|
+
|
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.enabled = true
|
15
|
+
config.assets.paths << "#{config.root}/private/plugin_assets"
|
16
|
+
config.assets.precompile += %w(*/stylesheets/*.css */javascripts/*.js)
|
17
|
+
|
18
|
+
# Custom settings. Edit configs of your application
|
19
|
+
# See: http://guides.rubyonrails.org/asset_pipeline.html
|
20
|
+
#
|
21
|
+
# Redmine save all assets in root of public =(
|
22
|
+
# If you need to change that value
|
23
|
+
# manually move assets in public directory and edit it
|
24
|
+
# config.assets.prefix = ''
|
25
|
+
#
|
26
|
+
# config.assets.js_compressor = :uglifier
|
27
|
+
#
|
28
|
+
# config.assets.debug = true
|
29
|
+
#
|
30
|
+
# config.assets.compile = true
|
31
|
+
#
|
32
|
+
# config.assets.compress = false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
config.after_initialize do
|
37
|
+
require_dependency 'redmine_plugin_asset_pipeline/application_helper_patch'
|
38
|
+
unless ApplicationHelper.included_modules.include? RedminePluginAssetPipeline::ApplicationHelperPatch
|
39
|
+
ApplicationHelper.send(:include, RedminePluginAssetPipeline::ApplicationHelperPatch)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module RedminePluginAssetPipeline
|
2
|
+
module ApplicationHelperPatch
|
3
|
+
def self.included(base)
|
4
|
+
base.send(:include, InstanceMethods)
|
5
|
+
base.class_eval do
|
6
|
+
def assets_prefix
|
7
|
+
Rails.application.config.assets.prefix.gsub(/^\//, '')
|
8
|
+
end
|
9
|
+
|
10
|
+
def stylesheet_link_tag(*sources)
|
11
|
+
options = sources.last.is_a?(Hash) ? sources.pop : {}
|
12
|
+
plugin = options.delete(:plugin)
|
13
|
+
sources = sources.map do |source|
|
14
|
+
if plugin
|
15
|
+
"/#{[assets_prefix, "#{plugin}/stylesheets/#{source}"].join('/')}"
|
16
|
+
elsif current_theme && current_theme.stylesheets.include?(source)
|
17
|
+
current_theme.stylesheet_path(source)
|
18
|
+
else
|
19
|
+
"/#{[assets_prefix, "stylesheets/#{source}"].join('/')}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
super *sources, options
|
23
|
+
end
|
24
|
+
|
25
|
+
def javascript_include_tag(*sources)
|
26
|
+
options = sources.last.is_a?(Hash) ? sources.pop : {}
|
27
|
+
plugin = options.delete(:plugin)
|
28
|
+
sources = sources.map do |source|
|
29
|
+
if plugin
|
30
|
+
"/#{[assets_prefix, "#{plugin}/javascripts/#{source}"].join('/')}"
|
31
|
+
else
|
32
|
+
"/#{[assets_prefix, "javascripts/#{source}"].join('/')}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
super *sources, options
|
36
|
+
end
|
37
|
+
|
38
|
+
def image_tag(source, options={})
|
39
|
+
if plugin = options.delete(:plugin)
|
40
|
+
source = "/#{[assets_prefix, "#{plugin}/images/#{source}"].join('/')}"
|
41
|
+
elsif current_theme && current_theme.images.include?(source)
|
42
|
+
source = current_theme.image_path(source)
|
43
|
+
else
|
44
|
+
source = "/#{[assets_prefix, "images/#{source}"].join('/')}"
|
45
|
+
end
|
46
|
+
super source, options
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
module InstanceMethods
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Patch for copy plugin assets sources to private directory
|
2
|
+
module RedminePluginAssetPipeline
|
3
|
+
module PluginPatch
|
4
|
+
def self.included(base)
|
5
|
+
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.send(:include, InstanceMethods)
|
8
|
+
|
9
|
+
base.class_eval do
|
10
|
+
class << self
|
11
|
+
cattr_accessor :private_directory
|
12
|
+
self.private_directory = File.join(Rails.root, 'private', 'plugin_assets')
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :mirror_assets_to_public, :mirror_assets
|
16
|
+
alias_method :mirror_assets, :mirror_assets_to_private
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
end
|
22
|
+
|
23
|
+
module InstanceMethods
|
24
|
+
def private_directory
|
25
|
+
File.join(self.class.private_directory, id.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
def mirror_assets_to_private
|
29
|
+
source = assets_directory
|
30
|
+
destination = private_directory
|
31
|
+
return unless File.directory?(source)
|
32
|
+
|
33
|
+
source_files = Dir[source + "/**/*"]
|
34
|
+
source_dirs = source_files.select { |d| File.directory?(d) }
|
35
|
+
source_files -= source_dirs
|
36
|
+
|
37
|
+
unless source_files.empty?
|
38
|
+
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
|
39
|
+
begin
|
40
|
+
FileUtils.mkdir_p(base_target_dir)
|
41
|
+
rescue Exception => e
|
42
|
+
raise "Could not create directory #{base_target_dir}: " + e.message
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
source_dirs.each do |dir|
|
47
|
+
# strip down these paths so we have simple, relative paths we can
|
48
|
+
# add to the destination
|
49
|
+
target_dir = File.join(destination, dir.gsub(source, ''))
|
50
|
+
begin
|
51
|
+
FileUtils.mkdir_p(target_dir)
|
52
|
+
rescue Exception => e
|
53
|
+
raise "Could not create directory #{target_dir}: " + e.message
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
source_files.each do |file|
|
58
|
+
begin
|
59
|
+
target = File.join(destination, file.gsub(source, ''))
|
60
|
+
unless File.exist?(target) && FileUtils.identical?(file, target)
|
61
|
+
FileUtils.cp(file, target)
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
raise "Could not copy #{file} to #{target}: " + e.message
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'redmine_plugin_asset_pipeline/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "redmine_plugin_asset_pipeline"
|
8
|
+
spec.version = RedminePluginAssetPipeline::VERSION
|
9
|
+
spec.authors = ["Tab10id"]
|
10
|
+
spec.email = ["tabloidmeister@gmail.com"]
|
11
|
+
spec.description = %q{Asset pipeline for Redmine}
|
12
|
+
spec.summary = %q{Asset pipeline for Redmine}
|
13
|
+
spec.homepage = "https://github.com/Tab10id/redmine_plugin_asset_pipeline"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redmine_plugin_asset_pipeline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tab10id
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Asset pipeline for Redmine
|
42
|
+
email:
|
43
|
+
- tabloidmeister@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- init.rb
|
54
|
+
- lib/generators/redmine_pipeline/private_assets_initializer/private_assets_initializer_generator.rb
|
55
|
+
- lib/generators/redmine_pipeline/private_assets_initializer/templates/35-patch_assets_mirror.rb
|
56
|
+
- lib/redmine_plugin_asset_pipeline.rb
|
57
|
+
- lib/redmine_plugin_asset_pipeline/application_helper_patch.rb
|
58
|
+
- lib/redmine_plugin_asset_pipeline/plugin_patch.rb
|
59
|
+
- lib/redmine_plugin_asset_pipeline/version.rb
|
60
|
+
- redmine_plugin_asset_pipeline.gemspec
|
61
|
+
- test/test_helper.rb
|
62
|
+
homepage: https://github.com/Tab10id/redmine_plugin_asset_pipeline
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.0.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Asset pipeline for Redmine
|
86
|
+
test_files:
|
87
|
+
- test/test_helper.rb
|
88
|
+
has_rdoc:
|