Merge branch 'jamie/master'

This commit is contained in:
Kris Brown 2010-01-05 22:59:43 +00:00
commit b8c04dfb6d
5 changed files with 40 additions and 1 deletions

View File

@ -62,6 +62,14 @@ opts = OptionParser.new do |opts|
end end
end end
opts.on("--extensions", "Load Jekyll extensions from _lib directory") do
options['extensions'] = true
end
opts.on("--no-extensions", "Do not load Jekyll extensions") do
options['extensions'] = false
end
opts.on("--version", "Display current version") do opts.on("--version", "Display current version") do
puts "Jekyll " + Jekyll.version puts "Jekyll " + Jekyll.version
exit 0 exit 0

View File

@ -61,3 +61,21 @@ Feature: Site configuration
When I run jekyll When I run jekyll
Then the _site directory should exist Then the _site directory should exist
And I should see "puts 'Hello world!'" in "_site/index.html" And I should see "puts 'Hello world!'" in "_site/index.html"
Scenario: Load an extension from _lib
Given I have an "index.html" page that contains "{{ 'extension' | hello }}"
And I have a _lib directory
And I have a "_lib/hello.rb" file that contains "module Jekyll::Filters ; def hello(input) ; "hello #{input}" ; end ; end"
And I have a configuration file with "extensions" set to "true"
When I run jekyll
Then the _site directory should exist
And I should see "hello extension" in "_site/index.html"
Scenario: Skip loading extensions from _lib
Given I have an "index.html" page that contains "{{ 'extension' | hello }}"
And I have a _lib directory
And I have a "_lib/hello.rb" file that contains "module Jekyll::Filters ; def hello(input) ; "hello #{input}" ; end ; end"
And I have a configuration file with "extensions" set to "false"
When I run jekyll
Then the _site directory should exist
And I should not see "hello extension" in "_site/index.html"

View File

@ -119,6 +119,10 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
assert_match Regexp.new(text), File.open(file).readlines.join assert_match Regexp.new(text), File.open(file).readlines.join
end end
Then /^I should not see "(.*)" in "(.*)"$/ do |text, file|
assert_no_match Regexp.new(text), File.open(file).readlines.join
end
Then /^the "(.*)" file should exist$/ do |file| Then /^the "(.*)" file should exist$/ do |file|
assert File.file?(file) assert File.file?(file)
end end

View File

@ -43,6 +43,7 @@ module Jekyll
'pygments' => false, 'pygments' => false,
'markdown' => 'maruku', 'markdown' => 'maruku',
'permalink' => 'date', 'permalink' => 'date',
'extensions' => false,
'maruku' => { 'maruku' => {
'use_tex' => false, 'use_tex' => false,

View File

@ -2,7 +2,8 @@ module Jekyll
class Site class Site
attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude, attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
:source, :dest, :lsi, :pygments, :permalink_style, :tags :source, :dest, :lsi, :pygments, :permalink_style, :tags,
:extensions
# Initialize the site # Initialize the site
# +config+ is a Hash containing site configurations details # +config+ is a Hash containing site configurations details
@ -17,6 +18,7 @@ module Jekyll
self.pygments = config['pygments'] self.pygments = config['pygments']
self.permalink_style = config['permalink'].to_sym self.permalink_style = config['permalink'].to_sym
self.exclude = config['exclude'] || [] self.exclude = config['exclude'] || []
self.extensions = config['extensions']
self.reset self.reset
self.setup self.setup
@ -82,6 +84,12 @@ module Jekyll
else else
raise "Invalid Markdown processor: '#{self.config['markdown']}' -- did you mean 'maruku' or 'rdiscount'?" raise "Invalid Markdown processor: '#{self.config['markdown']}' -- did you mean 'maruku' or 'rdiscount'?"
end end
# Load extensions from _lib folder
if self.extensions
# load instead of require so that jekyll --auto reloads changes
Dir["#{source}/_lib/*.rb"].each {|f| load f}
end
end end
def textile(content) def textile(content)