jekyll-assets 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -45,6 +45,14 @@ module Jekyll
|
|
45
45
|
#
|
46
46
|
# Default: 'assets'
|
47
47
|
#
|
48
|
+
#
|
49
|
+
# ##### baseurl
|
50
|
+
#
|
51
|
+
# Base URL for assets paths. By default equals dirname surrunded with
|
52
|
+
# slashes. You ight want to change it if your blog has baseurl configuration
|
53
|
+
# and served not from the root of the server, or if you want to keep your
|
54
|
+
# assets on CDN.
|
55
|
+
#
|
48
56
|
class Configuration < OpenStruct
|
49
57
|
@@defaults = {
|
50
58
|
:dirname => 'assets',
|
@@ -60,6 +68,9 @@ module Jekyll
|
|
60
68
|
self.bundles = [ self.bundles ] if self.bundles.is_a? String
|
61
69
|
self.compress = OpenStruct.new(self.compress)
|
62
70
|
self.dirname = self.dirname.gsub(/^\/+|\/+$/, '')
|
71
|
+
|
72
|
+
# if baseurl not given - autoguess base on dirname
|
73
|
+
self.baseurl ||= "/#{self.dirname}/".squeeze '/'
|
63
74
|
end
|
64
75
|
|
65
76
|
# Returns bundles array with pattern strings converted to RegExps
|
@@ -57,7 +57,7 @@ module Jekyll
|
|
57
57
|
JAVASCRIPT = '<script type="text/javascript" src="%s"></script>'
|
58
58
|
EXTENSIONS = { 'stylesheet' => '.css', 'javascript' => '.js' }
|
59
59
|
|
60
|
-
@@errors
|
60
|
+
@@errors = Set.new
|
61
61
|
|
62
62
|
def initialize tag_name, logical_path, tokens
|
63
63
|
super
|
@@ -108,7 +108,7 @@ module Jekyll
|
|
108
108
|
def render_asset_path context
|
109
109
|
with_asset context do |asset, site|
|
110
110
|
return asset_not_bundled unless site.has_bundled_asset? asset
|
111
|
-
return "
|
111
|
+
return "#{site.assets_config.baseurl.chomp '/'}/#{asset.digest_path}"
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -6,6 +6,7 @@ module Jekyll::AssetsPlugin
|
|
6
6
|
let(:defaults) do
|
7
7
|
{
|
8
8
|
:dirname => 'assets',
|
9
|
+
:baseurl => '/assets/',
|
9
10
|
:sources => %w{_assets/javascripts _assets/stylesheets _assets/images},
|
10
11
|
:bundles => %w{app.css app.js **.jpg **.png **.gif}
|
11
12
|
}
|
@@ -19,6 +20,11 @@ module Jekyll::AssetsPlugin
|
|
19
20
|
it { should == defaults[:dirname] }
|
20
21
|
end
|
21
22
|
|
23
|
+
context 'assets baseurl' do
|
24
|
+
subject { config.baseurl }
|
25
|
+
it { should == defaults[:baseurl] }
|
26
|
+
end
|
27
|
+
|
22
28
|
context 'sources list' do
|
23
29
|
subject { config.sources }
|
24
30
|
it { should =~ defaults[:sources] }
|
@@ -53,6 +59,25 @@ module Jekyll::AssetsPlugin
|
|
53
59
|
config.compress.css.should == 'sass'
|
54
60
|
end
|
55
61
|
|
62
|
+
context '#baseurl' do
|
63
|
+
it 'should respect explicit overrides' do
|
64
|
+
config = Configuration.new({
|
65
|
+
:dirname => 'foo',
|
66
|
+
:baseurl => '/bar/'
|
67
|
+
})
|
68
|
+
|
69
|
+
config.baseurl.should == '/bar/'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should be auto-guessed from dirname' do
|
73
|
+
config = Configuration.new({
|
74
|
+
:dirname => 'foo'
|
75
|
+
})
|
76
|
+
|
77
|
+
config.baseurl.should == '/foo/'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
56
81
|
context '#js_compressor' do
|
57
82
|
context 'when js compressor is given as "uglify"' do
|
58
83
|
let(:config){ Configuration.new(:compress => {:js => 'uglify'}) }
|
@@ -76,6 +76,12 @@ module Jekyll::AssetsPlugin
|
|
76
76
|
subject { render('{% asset_path vapor.js %}') }
|
77
77
|
it { should be_empty }
|
78
78
|
end
|
79
|
+
|
80
|
+
context 'with baseurl given as /foobar/' do
|
81
|
+
before { context[:registers][:site].assets_config.baseurl = '/foobar/' }
|
82
|
+
subject { render('{% asset_path app.css %}') }
|
83
|
+
it { should match(%r{^/foobar/app-[a-f0-9]{32}\.css$}) }
|
84
|
+
end
|
79
85
|
end
|
80
86
|
|
81
87
|
context '{% asset <file.ext> %}' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: jekyll
|
@@ -164,24 +164,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
164
|
- - ! '>='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
-
segments:
|
168
|
-
- 0
|
169
|
-
hash: 346987987
|
170
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
168
|
none: false
|
172
169
|
requirements:
|
173
170
|
- - ! '>='
|
174
171
|
- !ruby/object:Gem::Version
|
175
172
|
version: '0'
|
176
|
-
segments:
|
177
|
-
- 0
|
178
|
-
hash: 346987987
|
179
173
|
requirements: []
|
180
174
|
rubyforge_project:
|
181
175
|
rubygems_version: 1.8.23
|
182
176
|
signing_key:
|
183
177
|
specification_version: 3
|
184
|
-
summary: jekyll-assets-0.1.
|
178
|
+
summary: jekyll-assets-0.1.2
|
185
179
|
test_files:
|
186
180
|
- spec/fixtures/.gitignore
|
187
181
|
- spec/fixtures/_assets/app.css.erb
|
@@ -201,3 +195,4 @@ test_files:
|
|
201
195
|
- spec/lib/jekyll/assets_plugin/tag_spec.rb
|
202
196
|
- spec/spec_helper.rb
|
203
197
|
- spec/support/fixtures_path.rb
|
198
|
+
has_rdoc:
|