redmine_plugin_asset_pipeline 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d07290f1684d5ec6bfe22814f714c95df2a63c1
|
4
|
+
data.tar.gz: 2a5f97eeb66b6db63536ac70305f136117920b8e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c7ec52e075c6421346c24401dd65a167ffece1abc46fb88bb35cd32450ce022b1d6855f23054435eed520e8b84206b10be2006acb76d926bca846cdf7a8b556
|
7
|
+
data.tar.gz: 3fc74085c4002e619d9f29c227591247b8b9c9028e4670f80bef8bafac1f836115cd5b61689495f726d594a84f661181e258872425de9d67b8825368c1348c3f
|
@@ -1,45 +1,63 @@
|
|
1
1
|
require_dependency 'application_helper'
|
2
2
|
|
3
3
|
module ApplicationHelper
|
4
|
-
def assets_prefix
|
5
|
-
Rails.application.config.assets.prefix.gsub(/^\//, '')
|
6
|
-
end
|
7
|
-
|
8
4
|
def stylesheet_link_tag(*sources)
|
9
|
-
options = sources.
|
5
|
+
options = sources.extract_options!
|
10
6
|
plugin = options.delete(:plugin)
|
11
|
-
|
7
|
+
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
|
8
|
+
body = options.key?(:body) ? options.delete(:body) : false
|
9
|
+
digest = options.key?(:digest) ? options.delete(:digest) : digest_assets?
|
10
|
+
sources.map! do |source|
|
12
11
|
if plugin
|
13
|
-
"
|
12
|
+
"#{plugin}/stylesheets/#{source}"
|
14
13
|
elsif current_theme && current_theme.stylesheets.include?(source)
|
15
14
|
current_theme.stylesheet_path(source)
|
16
15
|
else
|
17
|
-
"
|
16
|
+
"stylesheets/#{source}"
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
19
|
+
sources.collect do |source|
|
20
|
+
if debug && asset = asset_for(source, 'css')
|
21
|
+
asset.to_a.map { |dep|
|
22
|
+
super(dep.pathname.to_s, { :href => asset_path(dep, :ext => 'css', :body => true, :protocol => :request, :digest => digest) }.merge!(options))
|
23
|
+
}
|
24
|
+
else
|
25
|
+
super(source.to_s, { :href => asset_path(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest) }.merge!(options))
|
26
|
+
end
|
27
|
+
end.flatten.uniq.join("\n").html_safe
|
21
28
|
end
|
22
29
|
|
23
30
|
def javascript_include_tag(*sources)
|
24
31
|
options = sources.last.is_a?(Hash) ? sources.pop : {}
|
25
32
|
plugin = options.delete(:plugin)
|
26
|
-
|
33
|
+
debug = options.key?(:debug) ? options.delete(:debug) : debug_assets?
|
34
|
+
body = options.key?(:body) ? options.delete(:body) : false
|
35
|
+
digest = options.key?(:digest) ? options.delete(:digest) : digest_assets?
|
36
|
+
sources.map! do |source|
|
27
37
|
if plugin
|
28
|
-
"
|
38
|
+
"#{plugin}/javascripts/#{source}"
|
29
39
|
else
|
30
|
-
"
|
40
|
+
"javascripts/#{source}"
|
31
41
|
end
|
32
42
|
end
|
33
|
-
|
43
|
+
sources.collect do |source|
|
44
|
+
if debug && asset = asset_for(source, 'js')
|
45
|
+
asset.to_a.map { |dep|
|
46
|
+
super(dep.pathname.to_s, { :src => asset_path(dep, :ext => 'js', :body => true, :digest => digest) }.merge!(options))
|
47
|
+
}
|
48
|
+
else
|
49
|
+
super(source.to_s, { :src => asset_path(source, :ext => 'js', :body => body, :digest => digest) }.merge!(options))
|
50
|
+
end
|
51
|
+
end.flatten.uniq.join("\n").html_safe
|
34
52
|
end
|
35
53
|
|
36
54
|
def image_tag(source, options={})
|
37
55
|
if plugin = options.delete(:plugin)
|
38
|
-
source = "
|
56
|
+
source = "#{plugin}/images/#{source}"
|
39
57
|
elsif current_theme && current_theme.images.include?(source)
|
40
58
|
source = current_theme.image_path(source)
|
41
59
|
elsif source[0] != '/'
|
42
|
-
source = "
|
60
|
+
source = "images/#{source}"
|
43
61
|
end
|
44
62
|
super source, options
|
45
63
|
end
|
@@ -67,4 +85,61 @@ module ApplicationHelper
|
|
67
85
|
end
|
68
86
|
end
|
69
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# copy-paste from Sprocket
|
92
|
+
def debug_assets?
|
93
|
+
compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])
|
94
|
+
rescue NameError
|
95
|
+
false
|
96
|
+
end
|
97
|
+
|
98
|
+
def compile_assets?
|
99
|
+
Rails.application.config.assets.compile
|
100
|
+
end
|
101
|
+
|
102
|
+
def digest_assets?
|
103
|
+
Rails.application.config.assets.digest
|
104
|
+
end
|
105
|
+
|
106
|
+
def asset_path(source, options = {})
|
107
|
+
source = source.logical_path if source.respond_to?(:logical_path)
|
108
|
+
path = asset_paths.compute_public_path(source, assets_prefix, options.merge(:body => true))
|
109
|
+
options[:body] ? "#{path}?body=1" : path
|
110
|
+
end
|
111
|
+
|
112
|
+
def assets_prefix
|
113
|
+
Rails.application.config.assets.prefix.gsub(/^\//, '')
|
114
|
+
end
|
115
|
+
|
116
|
+
def asset_for(source, ext)
|
117
|
+
source = source.to_s
|
118
|
+
return nil if asset_paths.is_uri?(source)
|
119
|
+
source = rewrite_extension(source, ext)
|
120
|
+
Rails.application.assets[source]
|
121
|
+
rescue Sprockets::FileOutsidePaths
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def rewrite_extension(source, ext)
|
126
|
+
source_ext = File.extname(source)[1..-1]
|
127
|
+
|
128
|
+
if !ext || ext == source_ext
|
129
|
+
source
|
130
|
+
elsif source_ext.blank?
|
131
|
+
"#{source}.#{ext}"
|
132
|
+
elsif File.exists?(source) || exact_match_present?(source)
|
133
|
+
source
|
134
|
+
else
|
135
|
+
"#{source}.#{ext}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def exact_match_present?(source)
|
140
|
+
pathname = Rails.application.assets.resolve(source)
|
141
|
+
pathname.to_s =~ /#{Regexp.escape(source)}\Z/
|
142
|
+
rescue Sprockets::FileNotFound
|
143
|
+
false
|
144
|
+
end
|
70
145
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_plugin_asset_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tab10id
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,17 +27,15 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: Asset pipeline for Redmine
|
@@ -67,27 +62,26 @@ files:
|
|
67
62
|
homepage: https://github.com/Tab10id/redmine_plugin_asset_pipeline
|
68
63
|
licenses:
|
69
64
|
- MIT
|
65
|
+
metadata: {}
|
70
66
|
post_install_message:
|
71
67
|
rdoc_options: []
|
72
68
|
require_paths:
|
73
69
|
- lib
|
74
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
71
|
requirements:
|
77
|
-
- -
|
72
|
+
- - '>='
|
78
73
|
- !ruby/object:Gem::Version
|
79
74
|
version: '0'
|
80
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
76
|
requirements:
|
83
|
-
- -
|
77
|
+
- - '>='
|
84
78
|
- !ruby/object:Gem::Version
|
85
79
|
version: '0'
|
86
80
|
requirements: []
|
87
81
|
rubyforge_project:
|
88
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.0.2
|
89
83
|
signing_key:
|
90
|
-
specification_version:
|
84
|
+
specification_version: 4
|
91
85
|
summary: Asset pipeline for Redmine
|
92
86
|
test_files:
|
93
87
|
- test/test_helper.rb
|