From b2ab24583569623ddc0681be56bcfac31fa89754 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sat, 4 Jun 2011 21:35:04 -0400 Subject: [PATCH 01/23] gave the assertion a failure message --- features/step_definitions/jekyll_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 27239bd5..29abccec 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -121,7 +121,7 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text| end Then /^the (.*) directory should exist$/ do |dir| - assert File.directory?(dir) + assert File.directory?(dir), "The directory \"#{dir}\" does not exist" end Then /^I should see "(.*)" in "(.*)"$/ do |text, file| From 2b8017dfdc3d1a237bc7aa63427228701bbe01f7 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sat, 4 Jun 2011 21:36:29 -0400 Subject: [PATCH 02/23] can now set a custom pagination location with pagination_path --- features/pagination.feature | 29 ++++++++++++++++++++++++++++- lib/jekyll/generators/pagination.rb | 8 +++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/features/pagination.feature b/features/pagination.feature index 90b10578..cc3cf4d6 100644 --- a/features/pagination.feature +++ b/features/pagination.feature @@ -19,9 +19,36 @@ Feature: Site pagination And the "_site/page/index.html" file should exist And I should see "" in "_site/page/index.html" And the "_site/page/index.html" file should not exist - + Examples: | num | exist | posts | not_exist | | 1 | 4 | 1 | 5 | | 2 | 2 | 2 | 3 | | 3 | 2 | 1 | 3 | + + Scenario Outline: Setting a custom pagination path + Given I have a configuration file with: + | key | value | + | paginate | 1 | + | paginate_path | /blog/page-:num | + | permalink | /blog/:year/:month/:day/:title | + And I have a _layouts directory + And I have an "index.html" page that contains "{{ paginator.posts.size }}" + And I have a _posts directory + And I have the following post: + | title | date | layout | content | + | Wargames | 3/27/2009 | default | The only winning move is not to play. | + | Wargames2 | 4/27/2009 | default | The only winning move is not to play2. | + | Wargames3 | 5/27/2009 | default | The only winning move is not to play3. | + | Wargames4 | 6/27/2009 | default | The only winning move is not to play4. | + When I run jekyll + Then the _site/blog/page- directory should exist + And the "_site/blog/page-/index.html" file should exist + And I should see "" in "_site/blog/page-/index.html" + And the "_site/blog/page-/index.html" file should not exist + + Examples: + | exist | posts | not_exist | + | 2 | 1 | 5 | + | 3 | 1 | 6 | + | 4 | 1 | 7 | diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index 847de4f8..6fb8a3a5 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -37,13 +37,19 @@ module Jekyll if num_page > 1 newpage = Page.new(site, site.source, page.dir, page.name) newpage.pager = pager - newpage.dir = File.join(page.dir, "page#{num_page}") + newpage.dir = File.join(page.dir, paginate_path(site, num_page)) site.pages << newpage else page.pager = pager end end end + + private + def paginate_path(site, num_page) + format = site.config['paginate_path'] || "page:num" + format.sub(':num', num_page.to_s) + end end class Pager From 58d8fef7ecd3f8b900130dee003f328dfc563884 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sun, 5 Jun 2011 15:11:35 -0400 Subject: [PATCH 03/23] added command-line option --paginate_path --- bin/jekyll | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 2e33f377..515db603 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -102,7 +102,7 @@ opts = OptionParser.new do |opts| opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style| options['permalink'] = style unless style.nil? end - + opts.on("--paginate [POSTS_PER_PAGE]", "Paginate a blog's posts") do |per_page| begin options['paginate'] = per_page.to_i @@ -113,6 +113,16 @@ opts = OptionParser.new do |opts| end end + opts.on("--paginate_path [PAGINATED_URL_FORMAT]", "Leave blank for /page") do |paginate_path| + begin + options['paginate_path'] = paginate_path + raise ArgumentError if options['paginate_path'].nil? + rescue + puts 'You must specify a pagination url format' + exit 0 + end + end + opts.on("--limit_posts [MAX_POSTS]", "Limit the number of posts to publish") do |limit_posts| begin options['limit_posts'] = limit_posts.to_i @@ -148,12 +158,12 @@ if ARGV.size > 0 else migrator = migrator.downcase end - + cmd_options = [] ['file', 'dbname', 'user', 'pass', 'host', 'site'].each do |p| cmd_options << "\"#{options[p]}\"" unless options[p].nil? end - + # It's import time puts "Importing..." From ab08acace956ce834e474369967bc08650e6c6a4 Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Mon, 21 Nov 2011 21:09:39 -0600 Subject: [PATCH 04/23] Support plugins being a list of directories to scan. --- lib/jekyll/site.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 9c24f8e4..22a48a48 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -18,7 +18,13 @@ module Jekyll self.safe = config['safe'] self.source = File.expand_path(config['source']) self.dest = File.expand_path(config['destination']) - self.plugins = File.expand_path(config['plugins']) + self.plugins = if config['plugins'].respond_to?('each') + # If plugins is an array, process it. + config['plugins'].each { |directory| File.expand_path(directory) } + else + # Otherwise process a single entry as an array. + [File.expand_path(config['plugins'])] + end self.lsi = config['lsi'] self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym @@ -72,8 +78,10 @@ module Jekyll # If safe mode is off, load in any Ruby files under the plugins # directory. unless self.safe - Dir[File.join(self.plugins, "**/*.rb")].each do |f| - require f + self.plugins.each do |plugins| + Dir[File.join(plugins, "**/*.rb")].each do |f| + require f + end end end From dcf546275ba5a1497fb6988b934f8c5da6900080 Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Sun, 22 Jan 2012 22:10:12 -0800 Subject: [PATCH 05/23] Tweaked plugin directory handling, tests. --- lib/jekyll/site.rb | 9 ++++++--- test/test_site.rb | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 22a48a48..0788223f 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -14,16 +14,19 @@ module Jekyll # config - A Hash containing site configuration details. def initialize(config) self.config = config.clone - self.safe = config['safe'] self.source = File.expand_path(config['source']) self.dest = File.expand_path(config['destination']) self.plugins = if config['plugins'].respond_to?('each') # If plugins is an array, process it. - config['plugins'].each { |directory| File.expand_path(directory) } + Array(config['plugins']).map { |d| File.expand_path(d) } else # Otherwise process a single entry as an array. - [File.expand_path(config['plugins'])] + if config['plugins'].nil? + [] + else + [File.expand_path(config['plugins'])] + end end self.lsi = config['lsi'] self.pygments = config['pygments'] diff --git a/test/test_site.rb b/test/test_site.rb index c9b991b7..1c9b1534 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -1,6 +1,27 @@ require 'helper' class TestSite < Test::Unit::TestCase + context "configuring sites" do + should "have an array for plugins by default" do + site = Site.new(Jekyll::DEFAULTS) + assert_equal [File.join(Dir.pwd, '_plugins')], site.plugins + end + + should "have an array for plugins if passed as a string" do + site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => '/tmp/plugins'})) + assert_equal ['/tmp/plugins'], site.plugins + end + + should "have an array for plugins if passed as an array" do + site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => ['/tmp/plugins', '/tmp/otherplugins']})) + assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins + end + + should "have an array for plugins if nothing is passed" do + site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => []})) + assert_equal [], site.plugins + end + end context "creating sites" do setup do stub(Jekyll).configuration do From e6d89c6a0f62fb72245dd266e6d7a5c7ce3c235e Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Sun, 22 Jan 2012 22:17:25 -0800 Subject: [PATCH 06/23] More testing, whitespace and comment cleanup. --- lib/jekyll/site.rb | 3 ++- test/test_site.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 0788223f..c9eb481d 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -14,6 +14,7 @@ module Jekyll # config - A Hash containing site configuration details. def initialize(config) self.config = config.clone + self.safe = config['safe'] self.source = File.expand_path(config['source']) self.dest = File.expand_path(config['destination']) @@ -21,10 +22,10 @@ module Jekyll # If plugins is an array, process it. Array(config['plugins']).map { |d| File.expand_path(d) } else - # Otherwise process a single entry as an array. if config['plugins'].nil? [] else + # Otherwise process a single entry as an array. [File.expand_path(config['plugins'])] end end diff --git a/test/test_site.rb b/test/test_site.rb index 1c9b1534..d9037730 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -17,10 +17,15 @@ class TestSite < Test::Unit::TestCase assert_equal ['/tmp/plugins', '/tmp/otherplugins'], site.plugins end - should "have an array for plugins if nothing is passed" do + should "have an empty array for plugins if nothing is passed" do site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => []})) assert_equal [], site.plugins end + + should "have an empty array for plugins if nil is passed" do + site = Site.new(Jekyll::DEFAULTS.merge({'plugins' => nil})) + assert_equal [], site.plugins + end end context "creating sites" do setup do From 9d70088f01d41dccbc3e4eedd7f2435ff25dcd31 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 23 Jan 2012 00:18:19 -0800 Subject: [PATCH 07/23] Properly select dotfiles during directory scan. Fixes #363. Fixes #431. Fixes #377. --- History.txt | 1 + features/create_sites.feature | 6 ++++++ features/site_configuration.feature | 12 ++++++++++++ lib/jekyll/site.rb | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 53bd41c6..180ba898 100644 --- a/History.txt +++ b/History.txt @@ -8,6 +8,7 @@ * Allow some special characters in highlight names * URL escape category names in URL generation (#360) * Fix error with limit_posts (#442) + * Properly select dotfile during directory scan (#363, #431, #377) == 0.11.2 / 2011-12-27 * Bug Fixes diff --git a/features/create_sites.feature b/features/create_sites.feature index 8496a4e2..438ee358 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -104,3 +104,9 @@ Feature: Create sites When I run jekyll Then the _site directory should exist And I should see "URL: /2020/01/31/entry2/" in "_site/index.html" + + Scenario: Basic site with whitelisted dotfile + Given I have an ".htaccess" file that contains "SomeDirective" + When I run jekyll + Then the _site directory should exist + And I should see "SomeDirective" in "_site/.htaccess" diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 8d3bee5d..6935af3d 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -131,3 +131,15 @@ Feature: Site configuration And the "_site/2009/04/05/bananas.html" file should exist And the "_site/2009/04/01/oranges.html" file should exist And the "_site/2009/03/27/apples.html" file should not exist + + Scenario: Copy over normally excluded files when they are explicitly included + Given I have a ".gitignore" file that contains ".DS_Store" + And I have an ".htaccess" file that contains "SomeDirective" + And I have a configuration file with "include" set to: + | value | + | .gitignore | + | .foo | + When I run jekyll + Then the _site directory should exist + And I should see ".DS_Store" in "_site/.gitignore" + And the "_site/.htaccess" file should not exist diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index c47ccd2d..d394d7e1 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -124,7 +124,7 @@ module Jekyll # Returns nothing. def read_directories(dir = '') base = File.join(self.source, dir) - entries = Dir.chdir(base) { filter_entries(Dir['*']) } + entries = Dir.chdir(base) { filter_entries(Dir.entries('.')) } self.read_posts(dir) From 4499df80330ac70f9ac09f854941394542019b6a Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 29 Jan 2012 12:49:57 -0800 Subject: [PATCH 08/23] Shorten plugin loading code and update history. --- History.txt | 1 + lib/jekyll/site.rb | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/History.txt b/History.txt index 180ba898..1fc6d2e2 100644 --- a/History.txt +++ b/History.txt @@ -4,6 +4,7 @@ * Add --default-mimetype option (#279) * Allow setting of RedCloth options (#284) * Add post_url Liquid tag for internal post linking (#369) + * Allow multiple plugin dirs to be specified (#438) * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 4fb77397..9bdafa16 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -18,17 +18,7 @@ module Jekyll self.safe = config['safe'] self.source = File.expand_path(config['source']) self.dest = File.expand_path(config['destination']) - self.plugins = if config['plugins'].respond_to?('each') - # If plugins is an array, process it. - Array(config['plugins']).map { |d| File.expand_path(d) } - else - if config['plugins'].nil? - [] - else - # Otherwise process a single entry as an array. - [File.expand_path(config['plugins'])] - end - end + self.plugins = Array(config['plugins']).map { |d| File.expand_path(d) } self.lsi = config['lsi'] self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym From 316cc8559c78cd3aac8683d301d2baaff6cf454f Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sun, 26 Feb 2012 20:58:14 -0800 Subject: [PATCH 09/23] moved paginate_path to default config --- lib/jekyll.rb | 21 +++++++++++---------- lib/jekyll/generators/pagination.rb | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 36642a26..b434ea29 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -51,21 +51,22 @@ module Jekyll # Default options. Overriden by values in _config.yml or command-line opts. # (Strings rather symbols used for compatability with YAML). DEFAULTS = { - 'safe' => false, - 'auto' => false, - 'server' => false, - 'server_port' => 4000, + 'safe' => false, + 'auto' => false, + 'server' => false, + 'server_port' => 4000, 'source' => Dir.pwd, 'destination' => File.join(Dir.pwd, '_site'), 'plugins' => File.join(Dir.pwd, '_plugins'), - 'future' => true, - 'lsi' => false, - 'pygments' => false, - 'markdown' => 'maruku', - 'permalink' => 'date', - + 'future' => true, + 'lsi' => false, + 'pygments' => false, + 'markdown' => 'maruku', + 'permalink' => 'date', + 'paginate_path' => 'page:num', + 'markdown_ext' => 'markdown,mkd,mkdn,md', 'textile_ext' => 'textile', diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index 6fb8a3a5..dee5ad54 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -47,7 +47,7 @@ module Jekyll private def paginate_path(site, num_page) - format = site.config['paginate_path'] || "page:num" + format = site.config['paginate_path'] format.sub(':num', num_page.to_s) end end From e29490c1c6fbcd3bac5827bda958acb9082ff3ca Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 23 Apr 2012 15:34:07 -0700 Subject: [PATCH 10/23] Allow setting of Kramdown smart_quotes. Fixes #482. --- History.txt | 1 + jekyll.gemspec | 2 +- lib/jekyll.rb | 1 + lib/jekyll/converters/markdown.rb | 4 +++- test/test_kramdown.rb | 18 ++++++++++++++---- test/test_tags.rb | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/History.txt b/History.txt index 1fc6d2e2..9f6307a0 100644 --- a/History.txt +++ b/History.txt @@ -10,6 +10,7 @@ * URL escape category names in URL generation (#360) * Fix error with limit_posts (#442) * Properly select dotfile during directory scan (#363, #431, #377) + * Allow setting of Kramdown smart_quotes (#482) == 0.11.2 / 2011-12-27 * Bug Fixes diff --git a/jekyll.gemspec b/jekyll.gemspec index 970a8ddc..88655609 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('classifier', "~> 1.3") s.add_runtime_dependency('directory_watcher', "~> 1.1") s.add_runtime_dependency('maruku', "~> 0.5") - s.add_runtime_dependency('kramdown', "~> 0.13") + s.add_runtime_dependency('kramdown', "~> 0.13.4") s.add_runtime_dependency('albino', "~> 1.3") s.add_development_dependency('rake', "~> 0.9") diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 6d5afd85..cc6502e9 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -88,6 +88,7 @@ module Jekyll 'footnote_nr' => 1, 'entity_output' => 'as_char', 'toc_levels' => '1..6', + 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo', 'use_coderay' => false, 'coderay' => { diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index b5655476..78e313d9 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -97,6 +97,7 @@ module Jekyll :footnote_nr => @config['kramdown']['footnote_nr'], :entity_output => @config['kramdown']['entity_output'], :toc_levels => @config['kramdown']['toc_levels'], + :smart_quotes => @config['kramdown']['smart_quotes'], :coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'], :coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'], @@ -111,7 +112,8 @@ module Jekyll :auto_ids => @config['kramdown']['auto_ids'], :footnote_nr => @config['kramdown']['footnote_nr'], :entity_output => @config['kramdown']['entity_output'], - :toc_levels => @config['kramdown']['toc_levels'] + :toc_levels => @config['kramdown']['toc_levels'], + :smart_quotes => @config['kramdown']['smart_quotes'] }).to_html end when 'rdiscount' diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index 99a7b454..043752c3 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -3,21 +3,31 @@ require 'helper' class TestKramdown < Test::Unit::TestCase context "kramdown" do setup do - config = { + @config = { 'markdown' => 'kramdown', 'kramdown' => { 'auto_ids' => false, 'footnote_nr' => 1, 'entity_output' => 'as_char', - 'toc_levels' => '1..6' + 'toc_levels' => '1..6', + 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo' } } - @markdown = MarkdownConverter.new config end # http://kramdown.rubyforge.org/converter/html.html#options should "pass kramdown options" do - assert_equal "

Some Header

", @markdown.convert('# Some Header #').strip + markdown = MarkdownConverter.new(@config) + assert_equal "

Some Header

", markdown.convert('# Some Header #').strip + end + + should "convert quotes to smart quotes" do + markdown = MarkdownConverter.new(@config) + assert_equal "

“Pit’hy”

", markdown.convert(%{"Pit'hy"}).strip + + override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } } + markdown = MarkdownConverter.new(@config.deep_merge(override)) + assert_equal "

«Pit›hy»

", markdown.convert(%{"Pit'hy"}).strip end end end diff --git a/test/test_tags.rb b/test/test_tags.rb index 1af5d58c..ab0f3188 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -6,7 +6,7 @@ class TestTags < Test::Unit::TestCase def create_post(content, override = {}, converter_class = Jekyll::MarkdownConverter) stub(Jekyll).configuration do - Jekyll::DEFAULTS.merge({'pygments' => true}).merge(override) + Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override) end site = Site.new(Jekyll.configuration) From f5b2acf8cd84e986d374361f6d5b0c732df2dd96 Mon Sep 17 00:00:00 2001 From: Michishige Kaito Date: Sun, 15 May 2011 20:05:22 +0100 Subject: [PATCH 11/23] Added support for inline TOCs with RDiscount --- lib/jekyll/converters/markdown.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 78e313d9..32820ef4 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -117,7 +117,12 @@ module Jekyll }).to_html end when 'rdiscount' - RDiscount.new(content, *@rdiscount_extensions).to_html + rd = RDiscount.new(content, *@rdiscount_extensions) + html = rd.to_html + if rd.generate_toc and html.include? @config['rdiscount']['toc_token'] + html.gsub! @config['rdiscount']['toc_token'], rd.toc_content + end + html when 'maruku' Maruku.new(content).to_html end From fd5447a6e6921b3f3d465ae7bc105b3dd7940fa3 Mon Sep 17 00:00:00 2001 From: Michishige Kaito Date: Tue, 1 Nov 2011 15:07:49 +0000 Subject: [PATCH 12/23] Added a test case for rdiscount toc rendering. --- test/test_rdiscount.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb index 894ea18f..2669b446 100644 --- a/test/test_rdiscount.rb +++ b/test/test_rdiscount.rb @@ -5,7 +5,7 @@ class TestRdiscount < Test::Unit::TestCase context "rdiscount" do setup do config = { - 'rdiscount' => { 'extensions' => ['smart'] }, + 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }, 'markdown' => 'rdiscount' } @markdown = MarkdownConverter.new config @@ -14,5 +14,9 @@ class TestRdiscount < Test::Unit::TestCase should "pass rdiscount extensions" do assert_equal "

“smart”

", @markdown.convert('"smart"').strip end + + should "render toc" do + assert_equal "

Header 1

\n\n

Header 2

\n\n

\n

\n\n

", @markdown.convert("# Header 1\n\n## Header 2\n\n{:toc}").strip + end end end From 6471ebf0ef9244ea6944b2d88e5fd0ed36576e32 Mon Sep 17 00:00:00 2001 From: Michishige Kaito Date: Tue, 1 Nov 2011 15:08:29 +0000 Subject: [PATCH 13/23] Fixed helper inclusion in redcarpet test --- test/test_redcarpet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_redcarpet.rb b/test/test_redcarpet.rb index 1359c449..05596a92 100644 --- a/test/test_redcarpet.rb +++ b/test/test_redcarpet.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/helper' +require 'helper' class TestRedcarpet < Test::Unit::TestCase context "redcarpet" do From 8a0fbf02f5430a0ca53cf6399b6b9bfbf2e8fbc0 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 23 Apr 2012 16:15:44 -0700 Subject: [PATCH 14/23] Cleanup for RDiscount TOC support. Closes #333. --- History.txt | 1 + lib/jekyll/converters/markdown.rb | 4 ++-- test/test_rdiscount.rb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/History.txt b/History.txt index 9f6307a0..3fbe4da1 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,7 @@ * Allow setting of RedCloth options (#284) * Add post_url Liquid tag for internal post linking (#369) * Allow multiple plugin dirs to be specified (#438) + * Inline TOC token support for RDiscount (#333) * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 32820ef4..cb94c8d0 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -119,8 +119,8 @@ module Jekyll when 'rdiscount' rd = RDiscount.new(content, *@rdiscount_extensions) html = rd.to_html - if rd.generate_toc and html.include? @config['rdiscount']['toc_token'] - html.gsub! @config['rdiscount']['toc_token'], rd.toc_content + if rd.generate_toc and html.include?(@config['rdiscount']['toc_token']) + html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content) end html when 'maruku' diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb index 2669b446..01f18eb3 100644 --- a/test/test_rdiscount.rb +++ b/test/test_rdiscount.rb @@ -5,8 +5,8 @@ class TestRdiscount < Test::Unit::TestCase context "rdiscount" do setup do config = { - 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }, - 'markdown' => 'rdiscount' + 'markdown' => 'rdiscount', + 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' } } @markdown = MarkdownConverter.new config end From 305695398c8dae02145e76267ebb9e14ace8871a Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 23 Apr 2012 17:23:11 -0700 Subject: [PATCH 15/23] Update History. --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index 3fbe4da1..e7e832b1 100644 --- a/History.txt +++ b/History.txt @@ -6,6 +6,7 @@ * Add post_url Liquid tag for internal post linking (#369) * Allow multiple plugin dirs to be specified (#438) * Inline TOC token support for RDiscount (#333) + * Add the option to specify the paginated url format (#342) * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) From 7d88f72409dfe5d8d11f336c85e6dbea7861f416 Mon Sep 17 00:00:00 2001 From: Luca Grulla Date: Sat, 3 Mar 2012 17:15:08 +0000 Subject: [PATCH 16/23] avoiding to call site_payload one time per each post and page. Speed site creation up of a 20%. --- lib/jekyll/site.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 9bdafa16..8d989b21 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -195,12 +195,13 @@ module Jekyll # # Returns nothing. def render + payload = site_payload self.posts.each do |post| - post.render(self.layouts, site_payload) + post.render(self.layouts, payload) end self.pages.each do |page| - page.render(self.layouts, site_payload) + page.render(self.layouts, payload) end self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a } } From df2ad2ac595d3ed5d998108cc3b55fb0eef97bf0 Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Wed, 30 May 2012 21:39:43 -0400 Subject: [PATCH 17/23] Allow a custom 'layouts' directory * Add 'layouts' option to change the dir from '_layouts' to anything relative to the source directory * Add cucumber scenario for testing an alternative directory '_theme' * Closes #563 --- features/site_configuration.feature | 21 +++++++++++++++++++++ features/step_definitions/jekyll_steps.rb | 7 +++++++ lib/jekyll.rb | 1 + lib/jekyll/site.rb | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 6935af3d..5a83ee80 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -143,3 +143,24 @@ Feature: Site configuration Then the _site directory should exist And I should see ".DS_Store" in "_site/.gitignore" And the "_site/.htaccess" file should not exist + + Scenario: Using a different layouts directory + Given I have a _theme directory + And I have a page theme that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}" + And I have a post theme that contains "Post Layout: {{ content }}" + And I have an "index.html" page with layout "page" that contains "site index page" + And I have a configuration file with: + | key | value | + | time | 2010-01-01 | + | future | true | + | layouts | _theme | + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 12/31/2007 | post | content for entry1. | + | entry2 | 01/31/2020 | post | content for entry2. | + When I run jekyll + Then the _site directory should exist + And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html" + And I should see "Post Layout:

content for entry1.

" in "_site/2007/12/31/entry1.html" + And I should see "Post Layout:

content for entry2.

" in "_site/2020/01/31/entry2.html" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 29abccec..20128964 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -39,6 +39,13 @@ Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text| end end +Given /^I have a (.*) theme that contains "(.*)"$/ do |layout, text| + File.open(File.join('_theme', layout + '.html'), 'w') do |f| + f.write(text) + f.close + end +end + Given /^I have an? (.*) directory$/ do |dir| FileUtils.mkdir_p(dir) end diff --git a/lib/jekyll.rb b/lib/jekyll.rb index fd455fb5..30fcdfd6 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -59,6 +59,7 @@ module Jekyll 'source' => Dir.pwd, 'destination' => File.join(Dir.pwd, '_site'), 'plugins' => File.join(Dir.pwd, '_plugins'), + 'layouts' => '_layouts', 'future' => true, 'lsi' => false, diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 8d989b21..19480119 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -106,7 +106,7 @@ module Jekyll # # Returns nothing. def read_layouts(dir = '') - base = File.join(self.source, dir, "_layouts") + base = File.join(self.source, dir, self.config['layouts']) return unless File.exists?(base) entries = [] Dir.chdir(base) { entries = filter_entries(Dir['*.*']) } From c71d7d529006920450ac3c6869925278bddcd353 Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Thu, 31 May 2012 14:48:44 -0400 Subject: [PATCH 18/23] Add travis-ci configuration file * Tests against: 1.9.3, 1.9.2, 1.8.7, rbx-18mode * Fixes #387 --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..39412f0e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +before_script: + - "sudo pip install pygments" +rvm: + - 1.9.3 + - 1.9.2 + - 1.8.7 + - rbx-18mode + # - rbx-19mode # liquid seems to fail on 1.9 mode From b2a1d61c0407d6612450fe7d90a9a1a397aaa28e Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Thu, 31 May 2012 15:51:34 -0400 Subject: [PATCH 19/23] Swap out albino for pygments.rb --- jekyll.gemspec | 2 +- lib/jekyll.rb | 2 +- lib/jekyll/tags/highlight.rb | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 88655609..55201ae8 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('directory_watcher', "~> 1.1") s.add_runtime_dependency('maruku', "~> 0.5") s.add_runtime_dependency('kramdown', "~> 0.13.4") - s.add_runtime_dependency('albino', "~> 1.3") + s.add_runtime_dependency('pygments.rb', "~> 0.2.12") s.add_development_dependency('rake', "~> 0.9") s.add_development_dependency('rdoc', "~> 3.11") diff --git a/lib/jekyll.rb b/lib/jekyll.rb index fd455fb5..30da18a7 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -24,7 +24,7 @@ require 'English' # 3rd party require 'liquid' require 'maruku' -require 'albino' +require 'pygments' # internal requires require 'jekyll/core_ext' diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index ed3a0f70..9ad69b3e 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -48,7 +48,13 @@ module Jekyll end def render_pygments(context, code) - output = add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + @options[:encoding] = 'utf-8' + + output = add_code_tags( + Pygments.highlight(code, :lexer => @lang, :options => @options), + @lang + ) + output = context["pygments_prefix"] + output if context["pygments_prefix"] output = output + context["pygments_suffix"] if context["pygments_suffix"] output From 58654176de6e1dfaa845cf08d1a096442338a9d7 Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Thu, 31 May 2012 16:06:49 -0400 Subject: [PATCH 20/23] No longer need pygments locally --- Rakefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index a1f4b161..8eb1360d 100644 --- a/Rakefile +++ b/Rakefile @@ -50,10 +50,6 @@ task :default => [:test, :features] require 'rake/testtask' Rake::TestTask.new(:test) do |test| - if `which pygmentize` == '' - puts "You must have Pygments installed to run the tests." - exit 1 - end test.libs << 'lib' << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true @@ -163,4 +159,4 @@ task :gemspec do spec = [head, manifest, tail].join(" # = MANIFEST =\n") File.open(gemspec_file, 'w') { |io| io.write(spec) } puts "Updated #{gemspec_file}" -end \ No newline at end of file +end From 0e9e7fbc85d29ddc8e85960f177b3926de87f7e9 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 23 Apr 2012 18:23:42 -0700 Subject: [PATCH 21/23] Simplify Site#read_layouts. --- lib/jekyll/site.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 8d989b21..799dcc2e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -101,12 +101,12 @@ module Jekyll self.read_directories end - # Read all the files in //_layouts and create a new Layout - # object with each one. + # Read all the files in /_layouts and create a new Layout object + # with each one. # # Returns nothing. - def read_layouts(dir = '') - base = File.join(self.source, dir, "_layouts") + def read_layouts + base = File.join(self.source, "_layouts") return unless File.exists?(base) entries = [] Dir.chdir(base) { entries = filter_entries(Dir['*.*']) } From 47090ffd2a0a4e35c6e2294b6a7a4f4899beec18 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 6 Jun 2012 11:59:37 -0700 Subject: [PATCH 22/23] Fix up a few TomDocs. --- lib/jekyll/site.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 799dcc2e..bd16a257 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -121,7 +121,7 @@ module Jekyll # that will become part of the site according to the rules in # filter_entries. # - # dir - The String relative path of the directory to read. + # dir - The String relative path of the directory to read. Default: ''. # # Returns nothing. def read_directories(dir = '') @@ -257,7 +257,7 @@ module Jekyll end end - # Constructs a Hash of Posts indexed by the specified Post attribute. + # Construct a Hash of Posts indexed by the specified Post attribute. # # post_attr - The String name of the Post attribute. # @@ -307,7 +307,7 @@ module Jekyll # or are excluded in the site configuration, unless they are web server # files such as '.htaccess'. # - # entries - The Array of file/directory entries to filter. + # entries - The Array of String file/directory entries to filter. # # Returns the Array of filtered entries. def filter_entries(entries) From 49a4be44cd117eff99a78047c6d4bdf379d3463d Mon Sep 17 00:00:00 2001 From: Tom Bell Date: Tue, 12 Jun 2012 00:35:21 +0100 Subject: [PATCH 23/23] Update travis-ci configuration file --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39412f0e..416e8f3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,4 @@ -before_script: - - "sudo pip install pygments" rvm: - 1.9.3 - 1.9.2 - 1.8.7 - - rbx-18mode - # - rbx-19mode # liquid seems to fail on 1.9 mode