Skip to content

Commit

Permalink
Allow specify baseurl in asets configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Dec 20, 2012
1 parent 6759d8c commit 949d65d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/jekyll/assets_plugin/configuration.rb
Expand Up @@ -60,6 +60,9 @@ def initialize config = {}
self.bundles = [ self.bundles ] if self.bundles.is_a? String
self.compress = OpenStruct.new(self.compress)
self.dirname = self.dirname.gsub(/^\/+|\/+$/, '')

# if baseurl not given - autoguess base on dirname
self.baseurl ||= "/#{self.dirname}/".squeeze '/'
end

# Returns bundles array with pattern strings converted to RegExps
Expand Down
25 changes: 25 additions & 0 deletions spec/lib/jekyll/assets_plugin/configuration_spec.rb
Expand Up @@ -6,6 +6,7 @@ module Jekyll::AssetsPlugin
let(:defaults) do
{
:dirname => 'assets',
:baseurl => '/assets/',
:sources => %w{_assets/javascripts _assets/stylesheets _assets/images},
:bundles => %w{app.css app.js **.jpg **.png **.gif}
}
Expand All @@ -19,6 +20,11 @@ module Jekyll::AssetsPlugin
it { should == defaults[:dirname] }
end

context 'assets baseurl' do
subject { config.baseurl }
it { should == defaults[:baseurl] }
end

context 'sources list' do
subject { config.sources }
it { should =~ defaults[:sources] }
Expand Down Expand Up @@ -53,6 +59,25 @@ module Jekyll::AssetsPlugin
config.compress.css.should == 'sass'
end

context '#baseurl' do
it 'should respect explicit overrides' do
config = Configuration.new({
:dirname => 'foo',
:baseurl => '/bar/'
})

config.baseurl.should == '/bar/'
end

it 'should be auto-guessed from dirname' do
config = Configuration.new({
:dirname => 'foo'
})

config.baseurl.should == '/foo/'
end
end

context '#js_compressor' do
context 'when js compressor is given as "uglify"' do
let(:config){ Configuration.new(:compress => {:js => 'uglify'}) }
Expand Down

0 comments on commit 949d65d

Please sign in to comment.