From 535d78de7d25045341d0501ac6fbb244a09e5a5c Mon Sep 17 00:00:00 2001 From: Thomas Jack Date: Mon, 8 Jun 2009 19:26:03 -0500 Subject: [PATCH 01/84] change features and tests to make sure categories in urls follow the order specified by directory layout or in yaml --- features/post_data.feature | 14 +++++++------- test/test_post.rb | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/features/post_data.feature b/features/post_data.feature index 87f5d851..9cd9d507 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -82,17 +82,17 @@ Feature: Post data And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" Scenario: Use post.categories variable when categories are in folders - Given I have a movies directory - And I have a movies/scifi directory - And I have a movies/scifi/_posts directory + Given I have a scifi directory + And I have a scifi/movies directory + And I have a scifi/movies/_posts directory And I have a _layouts directory - And I have the following post in "movies/scifi": + And I have the following post in "scifi/movies": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist - And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" + And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html" Scenario: Use post.categories variable when category is in YAML Given I have a _posts directory @@ -110,11 +110,11 @@ Feature: Post data And I have a _layouts directory And I have the following post: | title | date | layout | categories | content | - | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | + | Star Wars | 3/27/2009 | simple | ['scifi', 'movies'] | Luke, I am your father. | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist - And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" + And I should see "Post categories: scifi and movies" in "_site/scifi/movies/2009/03/27/star-wars.html" Scenario: Disable a post from being published Given I have a _posts directory diff --git a/test/test_post.rb b/test/test_post.rb index b6585cc0..491a42a0 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -105,7 +105,7 @@ class TestPost < Test::Unit::TestCase should "process the url correctly" do assert_equal "/:categories/:year/:month/:day/:title.html", @post.template - assert_equal "/beer/food/2008/10/19/foo-bar.html", @post.url + assert_equal "/food/beer/2008/10/19/foo-bar.html", @post.url end end From 0a1e3cd2508c797d7b8d1038636a6e7111e5cd3d Mon Sep 17 00:00:00 2001 From: Thomas Jack Date: Mon, 8 Jun 2009 19:26:29 -0500 Subject: [PATCH 02/84] stop sorting post categories so they show up in order in the url --- lib/jekyll/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index d164fb5e..4e2fc9e5 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -132,7 +132,7 @@ module Jekyll "month" => date.strftime("%m"), "day" => date.strftime("%d"), "title" => CGI.escape(slug), - "categories" => categories.sort.join('/') + "categories" => categories.join('/') }.inject(template) { |result, token| result.gsub(/:#{token.first}/, token.last) }.gsub(/\/\//, "/") From a49326719132242c05e744f59d3c8b4afc1435e2 Mon Sep 17 00:00:00 2001 From: Jeffry Degrande Date: Mon, 29 Jun 2009 08:40:31 -0300 Subject: [PATCH 03/84] bugfix for permalinks --- features/permalinks.feature | 2 ++ lib/jekyll/page.rb | 4 ++-- test/source/sitemap.xml | 23 +++++++++++++++++++++++ test/test_page.rb | 11 +++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/source/sitemap.xml diff --git a/features/permalinks.feature b/features/permalinks.feature index 8e50ee72..050e75c3 100644 --- a/features/permalinks.feature +++ b/features/permalinks.feature @@ -26,11 +26,13 @@ Feature: Fancy permalinks Scenario: Use pretty permalink schema for pages Given I have an "index.html" page that contains "Totally index" And I have an "awesome.html" page that contains "Totally awesome" + And I have an "sitemap.xml" page that contains "Totally uhm, sitemap" And I have a configuration file with "permalink" set to "pretty" When I run jekyll Then the _site directory should exist And I should see "Totally index" in "_site/index.html" And I should see "Totally awesome" in "_site/awesome/index.html" + And I should see "Totally uhm, sitemap" in "_site/sitemap.xml" Scenario: Use custom permalink schema with prefix Given I have a _posts directory diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 537df3d4..20463903 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -57,7 +57,7 @@ module Jekyll def url return permalink if permalink - @url ||= template.gsub(':name', basename) + @url ||= (ext == '.html') ? template.gsub(':name', basename) : "/#{name}" end # Extract information from the page filename @@ -91,7 +91,7 @@ module Jekyll # The url needs to be unescaped in order to preserve the correct filename path = File.join(dest, CGI.unescape(self.url)) - if self.url[/\.html$/].nil? + if self.ext == '.html' && self.url[/\.html$/].nil? FileUtils.mkdir_p(path) path = File.join(path, "index.html") end diff --git a/test/source/sitemap.xml b/test/source/sitemap.xml new file mode 100644 index 00000000..96b38a14 --- /dev/null +++ b/test/source/sitemap.xml @@ -0,0 +1,23 @@ +--- +layout: nil +--- + + + + + http://example.com + {{ site.time | date_to_xmlschema }} + daily + 1.0 + + + {% for post in site.posts %} + + http://example.com/{{ post.url }}/ + {{ site.time }} + monthly + 0.2 + + {% endfor %} + \ No newline at end of file diff --git a/test/test_page.rb b/test/test_page.rb index 1715d916..6fbb003d 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -81,6 +81,17 @@ class TestPage < Test::Unit::TestCase assert File.exists?(File.join(dest_dir, 'contacts', 'index.html')) end + should "write properly with extension different from html" do + page = setup_page("sitemap.xml") + page.site.permalink_style = :pretty + do_render(page) + page.write(dest_dir) + + assert_equal("/sitemap.xml", page.url) + assert_nil(page.url[/\.html$/]) + assert File.directory?(dest_dir) + assert File.exists?(File.join(dest_dir,'sitemap.xml')) + end end end From 4cc0873172db3112839373e73b6f9caea9d562ec Mon Sep 17 00:00:00 2001 From: Patrick Crowley Date: Thu, 22 Oct 2009 21:14:05 -0700 Subject: [PATCH 04/84] updated pygments output to wrap code blocks with tags --- lib/jekyll/tags/highlight.rb | 13 ++++++++++--- test/test_tags.rb | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index eb069c27..067a487f 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -31,11 +31,11 @@ module Jekyll def render_pygments(context, code) if context["content_type"] == "markdown" - return "\n" + Albino.new(code, @lang).to_s(@options) + "\n" + return "\n" + add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + "\n" elsif context["content_type"] == "textile" - return "" + Albino.new(code, @lang).to_s(@options) + "" + return "" + add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + "" else - return Albino.new(code, @lang).to_s(@options) + return add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) end end @@ -49,6 +49,13 @@ module Jekyll HTML end + + def add_code_tags(code, lang) + # Add nested tags to code blocks + code = code.sub(/
/,'
')
+      code = code.sub(/<\/pre>/,"
") + end + end end diff --git a/test/test_tags.rb b/test/test_tags.rb index 0c3caa6d..64119572 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -49,7 +49,7 @@ CONTENT end should "render markdown with pygments line handling" do - assert_match %{
test\n
}, @result + assert_match %{
test\n
}, @result end end @@ -59,7 +59,7 @@ CONTENT end should "render markdown with pygments line handling" do - assert_match %{
Æ\n
}, @result + assert_match %{
Æ\n
}, @result end end From e3bd1c88e9ad6c9d6c89a543ca72c82a289b6bd7 Mon Sep 17 00:00:00 2001 From: Patrick Crowley Date: Fri, 23 Oct 2009 08:03:25 -0700 Subject: [PATCH 05/84] refactored render_pygments to remove duplicate code --- lib/jekyll/tags/highlight.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 067a487f..93d94868 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -30,12 +30,11 @@ module Jekyll end def render_pygments(context, code) + output = add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) if context["content_type"] == "markdown" - return "\n" + add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + "\n" + return "\n" + output + "\n" elsif context["content_type"] == "textile" - return "" + add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + "" - else - return add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) + return "" + output + "" end end From 597c7a7904198d92aa5eacad356019165685c311 Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Tue, 24 Nov 2009 21:40:56 +0100 Subject: [PATCH 06/84] changes to stdout and -err - tests and behaviour By using $stdin adn $stderr instead of STDIN and STDERR it is possible to capture or redirect them using in process ruby code without the need to manage pipes and external processes --- lib/jekyll.rb | 6 +++--- test/test_configuration.rb | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 8a27e161..795c705c 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -67,10 +67,10 @@ module Jekyll begin config = YAML.load_file(config_file) raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash) - STDOUT.puts "Configuration from #{config_file}" + $stdout.puts "Configuration from #{config_file}" rescue => err - STDERR.puts "WARNING: Could not read configuration. Using defaults (and options)." - STDERR.puts "\t" + err.to_s + $stderr.puts "WARNING: Could not read configuration. Using defaults (and options)." + $stderr.puts "\t" + err.to_s config = {} end diff --git a/test/test_configuration.rb b/test/test_configuration.rb index 3b05ed51..c6d5ad6c 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -8,21 +8,21 @@ class TestConfiguration < Test::Unit::TestCase should "fire warning with no _config.yml" do mock(YAML).load_file(@path) { raise "No such file or directory - #{@path}" } - mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).") - mock(STDERR).puts("\tNo such file or directory - #{@path}") + mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).") + mock($stderr).puts("\tNo such file or directory - #{@path}") assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) end should "load configuration as hash" do mock(YAML).load_file(@path) { Hash.new } - mock(STDOUT).puts("Configuration from #{@path}") + mock($stdout).puts("Configuration from #{@path}") assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) end should "fire warning with bad config" do mock(YAML).load_file(@path) { Array.new } - mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).") - mock(STDERR).puts("\tInvalid configuration - #{@path}") + mock($stderr).puts("WARNING: Could not read configuration. Using defaults (and options).") + mock($stderr).puts("\tInvalid configuration - #{@path}") assert_equal Jekyll::DEFAULTS, Jekyll.configuration({}) end end From fab5a715c5c914bd3b939b7a000b410798f2a8a5 Mon Sep 17 00:00:00 2001 From: Jamie Macey Date: Sun, 29 Nov 2009 13:25:00 -0500 Subject: [PATCH 07/84] safely allow loading jekyll customizations from inside a site --- bin/jekyll | 8 ++++++++ features/site_configuration.feature | 18 ++++++++++++++++++ features/step_definitions/jekyll_steps.rb | 6 +++++- lib/jekyll.rb | 1 + lib/jekyll/site.rb | 10 +++++++++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 3e8469e1..7a31b80a 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -62,6 +62,14 @@ opts = OptionParser.new do |opts| 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 puts "Jekyll " + Jekyll.version exit 0 diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 31b8c71e..a2b7d0ca 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -61,3 +61,21 @@ Feature: Site configuration When I run jekyll Then the _site directory should exist 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" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 3bf34736..8efdb8d6 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -25,7 +25,7 @@ EOF end end -Given /^I have an "(.*)" file that contains "(.*)"$/ do |file, text| +Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text| File.open(file, 'w') do |f| f.write(text) f.close @@ -123,6 +123,10 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert_match Regexp.new(text), File.open(file).readlines.join 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 not exist$/ do |file| assert !File.exists?(file) end diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 8a27e161..e728a7ff 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -42,6 +42,7 @@ module Jekyll 'pygments' => false, 'markdown' => 'maruku', 'permalink' => 'date', + 'extensions' => false, 'maruku' => { 'use_tex' => false, diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index be275d88..11aa607b 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -2,7 +2,8 @@ module Jekyll class Site attr_accessor :config, :layouts, :posts, :categories, :exclude, - :source, :dest, :lsi, :pygments, :permalink_style, :tags + :source, :dest, :lsi, :pygments, :permalink_style, :tags, + :extensions # Initialize the site # +config+ is a Hash containing site configurations details @@ -17,6 +18,7 @@ module Jekyll self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym self.exclude = config['exclude'] || [] + self.extensions = config['extensions'] self.reset self.setup @@ -80,6 +82,12 @@ module Jekyll else raise "Invalid Markdown processor: '#{self.config['markdown']}' -- did you mean 'maruku' or 'rdiscount'?" 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 def textile(content) From b1a055f10dc921fd8ec03db703d2fb0608179f4d Mon Sep 17 00:00:00 2001 From: Alex Young Date: Mon, 30 Nov 2009 17:27:57 +0000 Subject: [PATCH 08/84] Call File.expand_path on source so liquid can see _includes in subdirectories --- lib/jekyll/site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index be275d88..f68d75f7 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -11,7 +11,7 @@ module Jekyll def initialize(config) self.config = config.clone - self.source = config['source'] + self.source = File.expand_path(config['source']) self.dest = config['destination'] self.lsi = config['lsi'] self.pygments = config['pygments'] From 39a487cdf08b03262968256498c25ffe60e1d483 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sat, 2 Jan 2010 13:17:58 +0000 Subject: [PATCH 09/84] redcloth set to >= 4.2.1 --- test/helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper.rb b/test/helper.rb index f2fd5afb..8521bdb4 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,5 +1,5 @@ require 'rubygems' -gem 'RedCloth', '= 4.2.1' +gem 'RedCloth', '>= 4.2.1' require File.join(File.dirname(__FILE__), *%w[.. lib jekyll]) From 5ea06f3ad9bcf62d419ebc8bca505e33d58205c3 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Mon, 4 Jan 2010 09:39:54 +0000 Subject: [PATCH 10/84] fixes issue #78, including comprehensive scenarios and tests --- features/pagination.feature | 37 +++---- features/step_definitions/jekyll_steps.rb | 8 +- lib/jekyll/pager.rb | 2 +- lib/jekyll/site.rb | 1 - test/test_generated_site.rb | 4 + test/test_pager.rb | 120 +++++++++++++++++----- 6 files changed, 114 insertions(+), 58 deletions(-) diff --git a/features/pagination.feature b/features/pagination.feature index b52ddcf2..2b1b3467 100644 --- a/features/pagination.feature +++ b/features/pagination.feature @@ -6,35 +6,22 @@ Feature: Site pagination Scenario Outline: Paginate with N posts per page Given I have a configuration file with "paginate" set to "" And I have a _layouts directory - And I have an "index.html" file that contains "Basic Site" + And I have an "index.html" file 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 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/page2 directory should exist - And the _site/page2/index.html file should exist - + Then the _site/page directory should exist + 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 | - | 1 | - | 2 | - - Scenario: Correct liquid paginator replacements - Given I have a configuration file with "paginate" set to "1" - And I have a _layouts directory - And I have an "index.html" file that contains "{{ paginator.page }}" - 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. | - When I run jekyll - Then the _site/index.html file should exist - And I should see "1" in "_site/index.html" - Then the _site/page2 directory should exist - And the _site/page2/index.html file should exist - And I should see "2" in "_site/page2/index.html" - \ No newline at end of file + | num | exist | posts | not_exist | + | 1 | 4 | 1 | 5 | + | 2 | 2 | 2 | 3 | + | 3 | 2 | 1 | 3 | diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 3bf34736..0c173988 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -115,14 +115,14 @@ Then /^the (.*) directory should exist$/ do |dir| assert File.directory?(dir) end -Then /^the (.*) file should exist$/ do |file| - assert File.file?(file) -end - Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert_match Regexp.new(text), File.open(file).readlines.join end +Then /^the "(.*)" file should exist$/ do |file| + assert File.file?(file) +end + Then /^the "(.*)" file should not exist$/ do |file| assert !File.exists?(file) end diff --git a/lib/jekyll/pager.rb b/lib/jekyll/pager.rb index 883579a4..b4e73161 100644 --- a/lib/jekyll/pager.rb +++ b/lib/jekyll/pager.rb @@ -4,7 +4,7 @@ module Jekyll def self.calculate_pages(all_posts, per_page) num_pages = all_posts.size / per_page.to_i - num_pages.abs + 1 if all_posts.size % per_page.to_i != 0 + num_pages = num_pages + 1 if all_posts.size % per_page.to_i != 0 num_pages end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index be275d88..18b6664d 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -252,7 +252,6 @@ module Jekyll def paginate_posts(file, dir) all_posts = self.posts.sort { |a,b| b <=> a } pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i) - pages += 1 (1..pages).each do |num_page| pager = Pager.new(self.config, num_page, all_posts, pages) page = Page.new(self, self.source, dir, file) diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 45b2cc84..fe9878e9 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -13,6 +13,10 @@ class TestGeneratedSite < Test::Unit::TestCase @index = File.read(dest_dir('index.html')) end + should "ensure post count is as expected" do + assert_equal 17, @site.posts.size + end + should "insert site.posts into the index" do assert @index.include?("#{@site.posts.size} Posts") end diff --git a/test/test_pager.rb b/test/test_pager.rb index 34ffc164..ffd1aa97 100644 --- a/test/test_pager.rb +++ b/test/test_pager.rb @@ -1,11 +1,38 @@ require File.dirname(__FILE__) + '/helper' class TestPager < Test::Unit::TestCase - context "pagination enabled" do + + should "calculate number of pages" do + assert_equal(0, Pager.calculate_pages([], '2')) + assert_equal(1, Pager.calculate_pages([1], '2')) + assert_equal(1, Pager.calculate_pages([1,2], '2')) + assert_equal(2, Pager.calculate_pages([1,2,3], '2')) + assert_equal(2, Pager.calculate_pages([1,2,3,4], '2')) + assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2')) + end + + context "pagination disabled" do setup do stub(Jekyll).configuration do Jekyll::DEFAULTS.merge({ - 'source' => source_dir, + 'source' => source_dir, + 'destination' => dest_dir + }) + end + @config = Jekyll.configuration + end + + should "report that pagination is disabled" do + assert !Pager.pagination_enabled?(@config, 'index.html') + end + + end + + context "pagination enabled for 2" do + setup do + stub(Jekyll).configuration do + Jekyll::DEFAULTS.merge({ + 'source' => source_dir, 'destination' => dest_dir, 'paginate' => 2 }) @@ -13,35 +40,74 @@ class TestPager < Test::Unit::TestCase @config = Jekyll.configuration @site = Site.new(@config) - @posts = @site.read_posts('') + @site.process + @posts = @site.posts end - should "calculate number of pages" do - assert_equal(2, Pager.calculate_pages(@posts, @config['paginate'])) - end - - should "create first pager" do - pager = Pager.new(@config, 1, @posts) - assert_equal(@config['paginate'].to_i, pager.posts.size) - assert_equal(2, pager.total_pages) - assert_nil(pager.previous_page) - assert_equal(2, pager.next_page) - end - - should "create second pager" do - pager = Pager.new(@config, 2, @posts) - assert_equal(@posts.size - @config['paginate'].to_i, pager.posts.size) - assert_equal(2, pager.total_pages) - assert_equal(1, pager.previous_page) - assert_nil(pager.next_page) - end - - should "not create third pager" do - assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) } - end - should "report that pagination is enabled" do assert Pager.pagination_enabled?(@config, 'index.html') end + + context "with 4 posts" do + setup do + @posts = @site.posts[1..4] # limit to 4 + end + + should "create first pager" do + pager = Pager.new(@config, 1, @posts) + assert_equal(2, pager.posts.size) + assert_equal(2, pager.total_pages) + assert_nil(pager.previous_page) + assert_equal(2, pager.next_page) + end + + should "create second pager" do + pager = Pager.new(@config, 2, @posts) + assert_equal(2, pager.posts.size) + assert_equal(2, pager.total_pages) + assert_equal(1, pager.previous_page) + assert_nil(pager.next_page) + end + + should "not create third pager" do + assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) } + end + + end + + context "with 5 posts" do + setup do + @posts = @site.posts[1..5] # limit to 5 + end + + should "create first pager" do + pager = Pager.new(@config, 1, @posts) + assert_equal(2, pager.posts.size) + assert_equal(3, pager.total_pages) + assert_nil(pager.previous_page) + assert_equal(2, pager.next_page) + end + + should "create second pager" do + pager = Pager.new(@config, 2, @posts) + assert_equal(2, pager.posts.size) + assert_equal(3, pager.total_pages) + assert_equal(1, pager.previous_page) + assert_equal(3, pager.next_page) + end + + should "create third pager" do + pager = Pager.new(@config, 3, @posts) + assert_equal(1, pager.posts.size) + assert_equal(3, pager.total_pages) + assert_equal(2, pager.previous_page) + assert_nil(pager.next_page) + end + + should "not create fourth pager" do + assert_raise(RuntimeError) { Pager.new(@config, 4, @posts) } + end + + end end end From b5916caf4bc9082574a008a45482c617e19687e1 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Tue, 5 Jan 2010 09:43:17 +0000 Subject: [PATCH 11/84] added scenario to test correct site generation for a site with layouts, pages, posts and files --- features/create_sites.feature | 32 ++++++++++++++++++++++- features/step_definitions/jekyll_steps.rb | 6 ++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/features/create_sites.feature b/features/create_sites.feature index d10f1625..4f5385b0 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -29,7 +29,7 @@ Feature: Create sites Scenario: Basic site with layout and a post Given I have a _layouts directory And I have a _posts directory - And I have the following post: + And I have the following posts: | title | date | layout | content | | Wargames | 3/27/2009 | default | The only winning move is not to play. | And I have a default layout that contains "Post Layout: {{ content }}" @@ -37,6 +37,36 @@ Feature: Create sites Then the _site directory should exist And I should see "Post Layout:

The only winning move is not to play.

" in "_site/2009/03/27/wargames.html" + Scenario: Basic site with layouts, pages, posts and files + Given I have a _layouts directory + And I have a page layout that contains "Page Layout: {{ site.posts.size }}" + And I have a post layout that contains "Post Layout: {{ content }}" + And I have an "index.html" page with layout "page" that contains "site index page" + And I have a blog directory + And I have a "blog/index.html" page with layout "page" that contains "category index page" + And I have an "about.html" file that contains "No replacement {{ site.posts.size }}" + And I have an "another_file" file that contains "" + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 3/27/2009 | post | content for entry1. | + | entry2 | 4/27/2009 | post | content for entry2. | + And I have a category/_posts directory + And I have the following posts in "category": + | title | date | layout | content | + | entry3 | 5/27/2009 | post | content for entry3. | + | entry4 | 6/27/2009 | post | content for entry4. | + When I run jekyll + Then the _site directory should exist + And I should see "Page Layout: 4" in "_site/index.html" + And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html" + And I should see "" in "_site/another_file" + And I should see "Page Layout: 4" in "_site/blog/index.html" + And I should see "Post Layout:

content for entry1.

" in "_site/2009/03/27/entry1.html" + And I should see "Post Layout:

content for entry2.

" in "_site/2009/04/27/entry2.html" + And I should see "Post Layout:

content for entry3.

" in "_site/category/2009/05/27/entry3.html" + And I should see "Post Layout:

content for entry4.

" in "_site/category/2009/06/27/entry4.html" + Scenario: Basic site with include tag Given I have a _includes directory And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 0c173988..9fc91013 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -13,7 +13,7 @@ Given /^I have a blank site in "(.*)"$/ do |path| end # Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it -Given /^I have an "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text| +Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text| File.open(file, 'w') do |f| f.write < Date: Sun, 3 Jan 2010 22:20:20 +0000 Subject: [PATCH 12/84] split process handling into phases to allow pages to have access to full and complete site payload and added some test improvements --- lib/jekyll.rb | 1 + lib/jekyll/site.rb | 105 ++++++++++++++++++++------------------ lib/jekyll/static_file.rb | 28 ++++++++++ test/test_site.rb | 10 +++- 4 files changed, 92 insertions(+), 52 deletions(-) create mode 100644 lib/jekyll/static_file.rb diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 8a27e161..cbf7c446 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -26,6 +26,7 @@ require 'jekyll/filters' require 'jekyll/tags/highlight' require 'jekyll/tags/include' require 'jekyll/albino' +require 'jekyll/static_file' module Jekyll # Default options. Overriden by values in _config.yml or command-line opts. diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 18b6664d..3d47d16e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -1,7 +1,7 @@ module Jekyll class Site - attr_accessor :config, :layouts, :posts, :categories, :exclude, + attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude, :source, :dest, :lsi, :pygments, :permalink_style, :tags # Initialize the site @@ -25,6 +25,8 @@ module Jekyll def reset self.layouts = {} self.posts = [] + self.pages = [] + self.static_files = [] self.categories = Hash.new { |hash, key| hash[key] = [] } self.tags = Hash.new { |hash, key| hash[key] = [] } end @@ -87,21 +89,29 @@ module Jekyll end # Do the actual work of processing the site and generating the - # real deal. + # real deal. Now has 4 phases; reset, read, render, write. This allows + # rendering to have full site payload available. # # Returns nothing def process self.reset - self.read_layouts - self.transform_pages - self.write_posts + self.read + self.render + self.write end - # Read all the files in /_layouts into memory for later use. + def read + self.read_layouts # existing implementation did this at top level only so preserved that + self.read_directories + end + + # Read all the files in //_layouts and create a new Layout + # object with each one. # # Returns nothing - def read_layouts - base = File.join(self.source, "_layouts") + def read_layouts(dir = '') + base = File.join(self.source, dir, "_layouts") + return unless File.exists?(base) entries = [] Dir.chdir(base) { entries = filter_entries(Dir['*.*']) } @@ -109,17 +119,16 @@ module Jekyll name = f.split(".")[0..-2].join(".") self.layouts[name] = Layout.new(self, base, f) end - rescue Errno::ENOENT => e - # ignore missing layout dir end - # Read all the files in /_posts and create a new Post object with each one. + # Read all the files in //_posts and create a new Post + # object with each one. # # Returns nothing def read_posts(dir) base = File.join(self.source, dir, '_posts') - entries = [] - Dir.chdir(base) { entries = filter_entries(Dir['**/*']) } + return unless File.exists?(base) + entries = Dir.chdir(base) { filter_entries(Dir['**/*']) } # first pass processes, but does not yet render post content entries.each do |f| @@ -135,10 +144,11 @@ module Jekyll end self.posts.sort! + end - # second pass renders each post now that full site payload is available - self.posts.each do |post| - post.render(self.layouts, site_payload) + def render + [self.posts, self.pages].flatten.each do |convertible| + convertible.render(self.layouts, site_payload) end self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} } @@ -147,55 +157,50 @@ module Jekyll # ignore missing layout dir end - # Write each post to //// + # Write static files, pages and posts # # Returns nothing - def write_posts + def write self.posts.each do |post| post.write(self.dest) end + self.pages.each do |page| + page.write(self.dest) + end + self.static_files.each do |sf| + sf.write(self.dest) + end end - # Copy all regular files from to / ignoring - # any files/directories that are hidden or backup files (start - # with "." or "#" or end with "~") or contain site content (start with "_") - # unless they are "_posts" directories or web server files such as - # '.htaccess' + # Reads the directories and finds posts, pages and static files that will + # become part of the valid site according to the rules in +filter_entries+. # The +dir+ String is a relative path used to call this method # recursively as it descends through directories # # Returns nothing - def transform_pages(dir = '') + def read_directories(dir = '') base = File.join(self.source, dir) entries = filter_entries(Dir.entries(base)) - directories = entries.select { |e| File.directory?(File.join(base, e)) } - files = entries.reject { |e| File.directory?(File.join(base, e)) || File.symlink?(File.join(base, e)) } - # we need to make sure to process _posts *first* otherwise they - # might not be available yet to other templates as {{ site.posts }} - if directories.include?('_posts') - directories.delete('_posts') - read_posts(dir) - end + self.read_posts(dir) - [directories, files].each do |entries| - entries.each do |f| - if File.directory?(File.join(base, f)) - next if self.dest.sub(/\/$/, '') == File.join(base, f) - transform_pages(File.join(dir, f)) - elsif Pager.pagination_enabled?(self.config, f) + entries.each do |f| + f_abs = File.join(base, f) + f_rel = File.join(dir, f) + if File.directory?(f_abs) + next if self.dest.sub(/\/$/, '') == f_abs + read_directories(f_rel) + elsif !File.symlink?(f_abs) + if Pager.pagination_enabled?(self.config, f) paginate_posts(f, dir) else - first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) } + first3 = File.open(f_abs) { |fd| fd.read(3) } if first3 == "---" # file appears to have a YAML header so process it as a page - page = Page.new(self, self.source, dir, f) - page.render(self.layouts, site_payload) - page.write(self.dest) + pages << Page.new(self, self.source, dir, f) else - # otherwise copy the file without transforming it - FileUtils.mkdir_p(File.join(self.dest, dir)) - FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f)) + # otherwise treat it as a static file + static_files << StaticFile.new(self, self.source, dir, f) end end end @@ -228,19 +233,19 @@ module Jekyll end # Filter out any files/directories that are hidden or backup files (start - # with "." or "#" or end with "~") or contain site content (start with "_") - # unless they are "_posts" directories or web server files such as - # '.htaccess' + # with "." or "#" or end with "~"), or contain site content (start with "_"), + # or are excluded in the site configuration, unless they are web server + # files such as '.htaccess' def filter_entries(entries) entries = entries.reject do |e| - unless ['_posts', '.htaccess'].include?(e) + unless ['.htaccess'].include?(e) ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e) end end end # Paginates the blog's posts. Renders the index.html file into paginated directories, ie: page2, page3... - # and adds more wite-wide data + # and adds more site-wide data # # {"paginator" => { "page" => , # "per_page" => , diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb new file mode 100644 index 00000000..7dfd6b97 --- /dev/null +++ b/lib/jekyll/static_file.rb @@ -0,0 +1,28 @@ +module Jekyll + + class StaticFile + # Initialize a new StaticFile. + # +site+ is the Site + # +base+ is the String path to the + # +dir+ is the String path between and the file + # +name+ is the String filename of the file + # + # Returns + def initialize(site, base, dir, name) + @site = site + @base = base + @dir = dir + @name = name + end + + # Write the static file to the destination directory. + # +dest+ is the String path to the destination dir + # + # Returns nothing + def write(dest) + FileUtils.mkdir_p(File.join(dest, @dir)) + FileUtils.cp(File.join(@base, @dir, @name), File.join(dest, @dir, @name)) + end + end + +end diff --git a/test/test_site.rb b/test/test_site.rb index f2202c8b..b92bc496 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -19,11 +19,17 @@ class TestSite < Test::Unit::TestCase before_posts = @site.posts.length before_layouts = @site.layouts.length before_categories = @site.categories.length + before_tags = @site.tags.length + before_pages = @site.pages.length + before_static_files = @site.static_files.length @site.process assert_equal before_posts, @site.posts.length assert_equal before_layouts, @site.layouts.length assert_equal before_categories, @site.categories.length + assert_equal before_tags, @site.tags.length + assert_equal before_pages, @site.pages.length + assert_equal before_static_files, @site.static_files.length end should "read layouts" do @@ -52,10 +58,10 @@ class TestSite < Test::Unit::TestCase should "filter entries" do ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown# .baz.markdow foo.markdown~] - ent2 = %w[.htaccess _posts bla.bla] + ent2 = %w[.htaccess _posts _pages bla.bla] assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1) - assert_equal ent2, @site.filter_entries(ent2) + assert_equal %w[.htaccess bla.bla], @site.filter_entries(ent2) end should "filter entries with exclude" do From 45e13cf46f7ca70c6b2b7261a8276ea7b963e3ed Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Tue, 5 Jan 2010 21:43:58 +0000 Subject: [PATCH 13/84] updated gemspec for my clone --- Rakefile | 8 ++++---- jekyll.gemspec => krisb-jekyll.gemspec | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) rename jekyll.gemspec => krisb-jekyll.gemspec (93%) diff --git a/Rakefile b/Rakefile index ceea1cea..a700d07c 100644 --- a/Rakefile +++ b/Rakefile @@ -6,13 +6,13 @@ begin gem 'jeweler', '>= 0.11.0' require 'jeweler' Jeweler::Tasks.new do |s| - s.name = "jekyll" + s.name = "krisb-jekyll" s.summary = %Q{Jekyll is a simple, blog aware, static site generator.} - s.email = "tom@mojombo.com" + s.email = "kris@kris.me.uk" s.homepage = "http://github.com/mojombo/jekyll" s.description = "Jekyll is a simple, blog aware, static site generator." - s.authors = ["Tom Preston-Werner"] - s.rubyforge_project = "jekyll" + s.authors = ["Tom Preston-Werner", "Kris Brown"] + s.rubyforge_project = "krisb-jekyll" s.files.exclude 'test/dest' s.test_files.exclude 'test/dest' s.add_dependency('RedCloth', '>= 4.2.1') diff --git a/jekyll.gemspec b/krisb-jekyll.gemspec similarity index 93% rename from jekyll.gemspec rename to krisb-jekyll.gemspec index aaba390e..a88c14c8 100644 --- a/jekyll.gemspec +++ b/krisb-jekyll.gemspec @@ -1,15 +1,18 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{jekyll} + s.name = %q{krisb-jekyll} s.version = "0.5.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Tom Preston-Werner"] - s.date = %q{2009-08-24} + s.authors = ["Tom Preston-Werner", "Kris Brown"] + s.date = %q{2010-01-05} s.default_executable = %q{jekyll} s.description = %q{Jekyll is a simple, blog aware, static site generator.} - s.email = %q{tom@mojombo.com} + s.email = %q{kris@kris.me.uk} s.executables = ["jekyll"] s.extra_rdoc_files = [ "README.textile" @@ -30,7 +33,7 @@ Gem::Specification.new do |s| "features/site_data.feature", "features/step_definitions/jekyll_steps.rb", "features/support/env.rb", - "jekyll.gemspec", + "krisb-jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/converters/csv.rb", @@ -89,7 +92,7 @@ Gem::Specification.new do |s| s.homepage = %q{http://github.com/mojombo/jekyll} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubyforge_project = %q{jekyll} + s.rubyforge_project = %q{krisb-jekyll} s.rubygems_version = %q{1.3.5} s.summary = %q{Jekyll is a simple, blog aware, static site generator.} s.test_files = [ @@ -133,3 +136,4 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0.9.6"]) end end + From d25f41915987f4daad1488077c1b5cb03d2cc78f Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Wed, 6 Jan 2010 08:55:08 +0000 Subject: [PATCH 14/84] updated History.txt with recent changes --- History.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/History.txt b/History.txt index 2cbaa68c..5d94fdc1 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,11 @@ +== edge + * Enhancements + * added support for extensions [issue #100] + * Bug Fixes + * changed tests to require redcloth >= 4.2.1 [issue #92] + * fixed pagination when number of pages is an exact multiple of max per page [issue #78] + * fixed rendering order of site artifacts [issue #71] + == 0.5.4 / 2009-08-23 * Bug Fixes * Do not allow symlinks (security vulnerability) From 5c17d6266d0838b477b07880ac7211e084413c6e Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Wed, 6 Jan 2010 12:59:18 +0000 Subject: [PATCH 15/84] removed usages of site.posts.first in some features where a better alternative is available --- features/embed_filters.feature | 6 +++--- features/post_data.feature | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/features/embed_filters.feature b/features/embed_filters.feature index f71dfb8f..61bd8da0 100644 --- a/features/embed_filters.feature +++ b/features/embed_filters.feature @@ -20,7 +20,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.title | xml_escape }}" + And I have a default layout that contains "{{ page.title | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.content | xml_escape }}" + And I have a default layout that contains "{{ content | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "7" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | tags | content | | Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.tags | array_to_sentence_string }}" + And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html" diff --git a/features/post_data.feature b/features/post_data.feature index 87f5d851..1751f3f4 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -9,7 +9,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post title: {{ site.posts.first.title }}" + And I have a simple layout that contains "Post title: {{ page.title }}" When I run jekyll Then the _site directory should exist And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html" @@ -20,7 +20,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post url: {{ site.posts.first.url }}" + And I have a simple layout that contains "Post url: {{ page.url }}" When I run jekyll Then the _site directory should exist And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post date: {{ site.posts.first.date }}" + And I have a simple layout that contains "Post date: {{ page.date }}" When I run jekyll Then the _site directory should exist And I should see "Post date: Fri Mar 27" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post id: {{ site.posts.first.id }}" + And I have a simple layout that contains "Post id: {{ page.id }}" When I run jekyll Then the _site directory should exist And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html" @@ -53,7 +53,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post content: {{ site.posts.first.content }}" + And I have a simple layout that contains "Post content: {{ content }}" When I run jekyll Then the _site directory should exist And I should see "Post content:

Luke, I am your father.

" in "_site/2009/03/27/star-wars.html" @@ -65,7 +65,7 @@ Feature: Post data And I have the following post in "movies": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" + And I have a simple layout that contains "Post category: {{ page.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -76,7 +76,7 @@ Feature: Post data And I have the following post: | title | date | layout | tag | content | | Star Wars | 5/18/2009 | simple | twist | Luke, I am your father. | - And I have a simple layout that contains "Post tags: {{ site.posts.first.tags }}" + And I have a simple layout that contains "Post tags: {{ page.tags }}" When I run jekyll Then the _site directory should exist And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" @@ -89,7 +89,7 @@ Feature: Post data And I have the following post in "movies/scifi": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -100,7 +100,7 @@ Feature: Post data And I have the following post: | title | date | layout | category | content | | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" + And I have a simple layout that contains "Post category: {{ page.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -111,7 +111,7 @@ Feature: Post data And I have the following post: | title | date | layout | categories | content | | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -133,7 +133,7 @@ Feature: Post data And I have the following post: | title | date | layout | author | content | | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. | - And I have a simple layout that contains "Post author: {{ site.posts.first.author }}" + And I have a simple layout that contains "Post author: {{ page.author }}" When I run jekyll Then the _site directory should exist And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html" From 7806a0d6bb241c578978bbd84a52e61e19ad5933 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Wed, 6 Jan 2010 15:19:39 +0000 Subject: [PATCH 16/84] separated up the attrs required by convertible and made tags and categories always non-nil as empty front matter entries could cause them to be nil --- lib/jekyll/convertible.rb | 4 ++++ lib/jekyll/post.rb | 13 +++++-------- test/test_post.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index f0348ab5..23783691 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -3,6 +3,10 @@ # # Requires # self.site -> Jekyll::Site +# self.content= +# self.data= +# self.ext= +# self.output= module Jekyll module Convertible # Return the contents as a string diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 914cfd59..55d4d1e3 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -18,12 +18,9 @@ module Jekyll name =~ MATCHER end - attr_accessor :site, :date, :slug, :ext, :published, :data, :content, :output, :tags - attr_writer :categories - - def categories - @categories ||= [] - end + attr_accessor :site + attr_accessor :data, :content, :output, :ext + attr_accessor :date, :slug, :published, :tags, :categories # Initialize this Post instance. # +site+ is the Site @@ -51,9 +48,8 @@ module Jekyll self.tags = [self.data["tag"]] elsif self.data.has_key?("tags") self.tags = self.data['tags'] - else - self.tags = [] end + self.tags ||= [] if self.categories.empty? if self.data.has_key?('category') @@ -68,6 +64,7 @@ module Jekyll end end end + self.categories ||= [] end # Spaceship is based on Post#date, slug diff --git a/test/test_post.rb b/test/test_post.rb index 649e2f46..78b86730 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -36,6 +36,7 @@ class TestPost < Test::Unit::TestCase end should "keep date, title, and markup type" do + @post.categories = [] @post.process(@fake_file) assert_equal Time.parse("2008-10-19"), @post.date @@ -202,6 +203,13 @@ class TestPost < Test::Unit::TestCase end context "initializing posts" do + + should "ensure suitable defaults for attributes" do + post = setup_post("2009-06-22-no-yaml.textile") + assert_equal [], post.tags + assert_equal [], post.categories + end + should "publish when published yaml is no specified" do post = setup_post("2008-02-02-published.textile") assert_equal true, post.published From 5a37e0d96ed2a5ba6ca25d60a5f3d23a26267b11 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 16:11:47 -0800 Subject: [PATCH 17/84] update history --- History.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/History.txt b/History.txt index 2cbaa68c..82180ba8 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,12 @@ +== + * Bug Fixes + * Fix pagination % 0 bug (#78) + * Ensure all posts are processed first (#71) + +== NOTE + * After this point I will no longer be giving credit in the history; + that is what the commit log is for. + == 0.5.4 / 2009-08-23 * Bug Fixes * Do not allow symlinks (security vulnerability) From c569f5e641df72bdeb2517ca9e111268e1d4eb7e Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 16:12:09 -0800 Subject: [PATCH 18/84] Version bump to 0.5.5 --- VERSION.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 66ebe587..06446329 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,5 @@ --- -:patch: 4 +:patch: 5 :major: 0 :minor: 5 +:build: From 59ee8a68693d80a1a9461b59095328f60374c318 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 16:12:44 -0800 Subject: [PATCH 19/84] Regenerated gemspec for version 0.5.5 --- jekyll.gemspec | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index aaba390e..ba291d56 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -1,12 +1,15 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{jekyll} - s.version = "0.5.4" + s.version = "0.5.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tom Preston-Werner"] - s.date = %q{2009-08-24} + s.date = %q{2010-01-08} s.default_executable = %q{jekyll} s.description = %q{Jekyll is a simple, blog aware, static site generator.} s.email = %q{tom@mojombo.com} @@ -47,6 +50,7 @@ Gem::Specification.new do |s| "lib/jekyll/pager.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", + "lib/jekyll/static_file.rb", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "test/helper.rb", @@ -133,3 +137,4 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0.9.6"]) end end + From 52b82af6e2fd7e25154d5b977bde6f50482e200f Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 17:21:26 -0800 Subject: [PATCH 20/84] update history --- History.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.txt b/History.txt index 82180ba8..3895619b 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,8 @@ == + * Bug Fixes + * Require redcloth >= 4.2.1 in tests (#92) + +== 0.5.5 * Bug Fixes * Fix pagination % 0 bug (#78) * Ensure all posts are processed first (#71) From c89d8dd0f39f421e135e07e86efad8861facacc9 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 17:26:48 -0800 Subject: [PATCH 21/84] allow .mkd as a markdown extension --- History.txt | 2 ++ lib/jekyll/convertible.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 3895619b..5e415d54 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,8 @@ == * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) + * Minor Enhancements + * Allow .mkd as markdown extension == 0.5.5 * Bug Fixes diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index f0348ab5..3e733d72 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -49,7 +49,7 @@ module Jekyll case self.ext[1..-1] when /textile/i return 'textile' - when /markdown/i, /mkdn/i, /md/i + when /markdown/i, /mkdn/i, /md/i, /mkd/i return 'markdown' end return 'unknown' From 4c1021d597eeebc6930bbbfe654458c7f74fce77 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 18:04:36 -0800 Subject: [PATCH 22/84] don't prematurely terminate front matter on mid-line triple dashes. fixes #93 --- History.txt | 1 + lib/jekyll/convertible.rb | 2 +- .../_posts/2010-01-08-triple-dash.markdown | 5 +++++ test/test_generated_site.rb | 2 +- test/test_post.rb | 16 ++++++++++++++-- 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/source/_posts/2010-01-08-triple-dash.markdown diff --git a/History.txt b/History.txt index 5e415d54..c1aaa7a0 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) + * Don't break on triple dashes in yaml frontmatter (#93) * Minor Enhancements * Allow .mkd as markdown extension diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 3e733d72..fd63f57a 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -18,7 +18,7 @@ module Jekyll def read_yaml(base, name) self.content = File.read(File.join(base, name)) - if self.content =~ /^(---\s*\n.*?\n?)(---.*?\n)/m + if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m self.content = self.content[($1.size + $2.size)..-1] self.data = YAML.load($1) diff --git a/test/source/_posts/2010-01-08-triple-dash.markdown b/test/source/_posts/2010-01-08-triple-dash.markdown new file mode 100644 index 00000000..cbb79e7a --- /dev/null +++ b/test/source/_posts/2010-01-08-triple-dash.markdown @@ -0,0 +1,5 @@ +--- +title: Foo --- Bar +--- + +Triple the fun! \ No newline at end of file diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index fe9878e9..357dd4db 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 17, @site.posts.size + assert_equal 18, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index 649e2f46..b4b4502d 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -77,7 +77,19 @@ class TestPost < Test::Unit::TestCase @post.read_yaml(@source, @real_file) assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data) - assert_equal "\r\nThis is the content", @post.content + assert_equal "This is the content", @post.content + end + end + + context "with embedded triple dash" do + setup do + @real_file = "2010-01-08-triple-dash.markdown" + end + should "consume the embedded dashes" do + @post.read_yaml(@source, @real_file) + + assert_equal({"title" => "Foo --- Bar"}, @post.data) + assert_equal "Triple the fun!", @post.content end end @@ -163,7 +175,7 @@ class TestPost < Test::Unit::TestCase @post.read_yaml(@source, @real_file) assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data) - assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content + assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content end should "transform textile" do From d020d4f2bf34b8ace0d0e4b6409d031196648152 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 18:09:36 -0800 Subject: [PATCH 23/84] update history --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index c1aaa7a0..a9ab47ec 100644 --- a/History.txt +++ b/History.txt @@ -4,6 +4,7 @@ * Don't break on triple dashes in yaml frontmatter (#93) * Minor Enhancements * Allow .mkd as markdown extension + * Use $stdout/err instead of constants (#99) == 0.5.5 * Bug Fixes From 60fed241cd17b679e654a18e731e20908491d2f0 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 18:14:31 -0800 Subject: [PATCH 24/84] better deps in readme. fixes #87. fixes #88 --- README.textile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.textile b/README.textile index d5165711..f32432f6 100644 --- a/README.textile +++ b/README.textile @@ -20,14 +20,21 @@ h2. Diving In * Customize the "Permalinks":http://wiki.github.com/mojombo/jekyll/permalinks your posts are generated with * Use the built-in "Liquid Extensions":http://wiki.github.com/mojombo/jekyll/liquid-extensions to make your life easier -h2. Dependencies +h2. Runtime Dependencies -* RedCloth: Textile support -* Liquid: Templating system -* Classifier: Generating related posts -* Maruku: Default markdown engine -* Directory Watcher: Auto-regeneration of sites -* Open4: Talking to pygments for syntax highlighting +* RedCloth: Textile support (Ruby) +* Liquid: Templating system (Ruby) +* Classifier: Generating related posts (Ruby) +* Maruku: Default markdown engine (Ruby) +* Directory Watcher: Auto-regeneration of sites (Ruby) +* Open4: Talking to pygments for syntax highlighting (Ruby) +* Pygments: Syntax highlighting (Python) + +h2. Developer Dependencies + +* Shoulda: Test framework (Ruby) +* RR: Mocking (Ruby) +* RedGreen: Nicer test output (Ruby) h2. License From add546f61e5b441d028151a7617213fb52f52b4b Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 18:27:05 -0800 Subject: [PATCH 25/84] update history --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index a9ab47ec..d01f63b4 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,7 @@ * Minor Enhancements * Allow .mkd as markdown extension * Use $stdout/err instead of constants (#99) + * Properly wrap code blocks (#91) == 0.5.5 * Bug Fixes From 602a252364e09dcc000e4b796814df4ea64f0727 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 18:59:35 -0800 Subject: [PATCH 26/84] add javascript mime type for webrick. fixes #98 --- History.txt | 1 + bin/jekyll | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index d01f63b4..29a6a2dd 100644 --- a/History.txt +++ b/History.txt @@ -6,6 +6,7 @@ * Allow .mkd as markdown extension * Use $stdout/err instead of constants (#99) * Properly wrap code blocks (#91) + * Add javascript mime type for webrick (#98) == 0.5.5 * Bug Fixes diff --git a/bin/jekyll b/bin/jekyll index 3e8469e1..6e03d48b 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -137,9 +137,13 @@ if options['server'] FileUtils.mkdir_p(destination) + mime_types = WEBrick::HTTPUtils::DefaultMimeTypes + mime_types.store 'js', 'application/javascript' + s = HTTPServer.new( :Port => options['server_port'], - :DocumentRoot => destination + :DocumentRoot => destination, + :MimeTypes => mime_types ) t = Thread.new { s.start From 98f3767af397ed06ec6fb1bb0b4f4a204f21b149 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 19:23:10 -0800 Subject: [PATCH 27/84] Version bump to 0.5.6 --- History.txt | 4 ++-- VERSION.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/History.txt b/History.txt index 29a6a2dd..8e5220f5 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,4 @@ -== +== 0.5.6 / 2010-01-08 * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) * Don't break on triple dashes in yaml frontmatter (#93) @@ -8,7 +8,7 @@ * Properly wrap code blocks (#91) * Add javascript mime type for webrick (#98) -== 0.5.5 +== 0.5.5 / 2010-01-08 * Bug Fixes * Fix pagination % 0 bug (#78) * Ensure all posts are processed first (#71) diff --git a/VERSION.yml b/VERSION.yml index 06446329..a4ed05e5 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- -:patch: 5 -:major: 0 :minor: 5 +:patch: 6 :build: +:major: 0 From c92eb564d2c0603c722cf292f16628954dabcf7e Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 8 Jan 2010 19:23:35 -0800 Subject: [PATCH 28/84] Regenerated gemspec for version 0.5.6 --- jekyll.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index ba291d56..9bac5718 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{jekyll} - s.version = "0.5.5" + s.version = "0.5.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tom Preston-Werner"] @@ -71,6 +71,7 @@ Gem::Specification.new do |s| "test/source/_posts/2009-05-18-tags.textile", "test/source/_posts/2009-06-22-empty-yaml.textile", "test/source/_posts/2009-06-22-no-yaml.textile", + "test/source/_posts/2010-01-08-triple-dash.markdown", "test/source/about.html", "test/source/category/_posts/2008-9-23-categories.textile", "test/source/contacts.html", From 6b74454a07cf1a3d8ac4d76bbafc50ceb47d13cb Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sat, 9 Jan 2010 18:55:07 +0000 Subject: [PATCH 29/84] resetting to upstream --- History.txt | 4 ---- Rakefile | 8 ++++---- bin/jekyll | 8 -------- features/embed_filters.feature | 6 +++--- features/post_data.feature | 22 +++++++++++----------- features/site_configuration.feature | 18 ------------------ features/step_definitions/jekyll_steps.rb | 4 ---- jekyll.gemspec | 6 +++--- lib/jekyll.rb | 1 - lib/jekyll/convertible.rb | 4 ---- lib/jekyll/post.rb | 13 ++++++++----- lib/jekyll/site.rb | 10 +--------- test/test_post.rb | 8 -------- 13 files changed, 30 insertions(+), 82 deletions(-) diff --git a/History.txt b/History.txt index f71f8582..8e5220f5 100644 --- a/History.txt +++ b/History.txt @@ -1,7 +1,3 @@ -== Edge - * Enhancements - * added support for extensions [issue #100] - == 0.5.6 / 2010-01-08 * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) diff --git a/Rakefile b/Rakefile index a700d07c..ceea1cea 100644 --- a/Rakefile +++ b/Rakefile @@ -6,13 +6,13 @@ begin gem 'jeweler', '>= 0.11.0' require 'jeweler' Jeweler::Tasks.new do |s| - s.name = "krisb-jekyll" + s.name = "jekyll" s.summary = %Q{Jekyll is a simple, blog aware, static site generator.} - s.email = "kris@kris.me.uk" + s.email = "tom@mojombo.com" s.homepage = "http://github.com/mojombo/jekyll" s.description = "Jekyll is a simple, blog aware, static site generator." - s.authors = ["Tom Preston-Werner", "Kris Brown"] - s.rubyforge_project = "krisb-jekyll" + s.authors = ["Tom Preston-Werner"] + s.rubyforge_project = "jekyll" s.files.exclude 'test/dest' s.test_files.exclude 'test/dest' s.add_dependency('RedCloth', '>= 4.2.1') diff --git a/bin/jekyll b/bin/jekyll index 76a6eb96..6e03d48b 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -62,14 +62,6 @@ opts = OptionParser.new do |opts| 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 puts "Jekyll " + Jekyll.version exit 0 diff --git a/features/embed_filters.feature b/features/embed_filters.feature index 61bd8da0..f71dfb8f 100644 --- a/features/embed_filters.feature +++ b/features/embed_filters.feature @@ -20,7 +20,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ page.title | xml_escape }}" + And I have a default layout that contains "{{ site.posts.first.title | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ content | xml_escape }}" + And I have a default layout that contains "{{ site.posts.first.content | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "7" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | tags | content | | Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}" + And I have a default layout that contains "{{ site.posts.first.tags | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html" diff --git a/features/post_data.feature b/features/post_data.feature index 1751f3f4..87f5d851 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -9,7 +9,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post title: {{ page.title }}" + And I have a simple layout that contains "Post title: {{ site.posts.first.title }}" When I run jekyll Then the _site directory should exist And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html" @@ -20,7 +20,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post url: {{ page.url }}" + And I have a simple layout that contains "Post url: {{ site.posts.first.url }}" When I run jekyll Then the _site directory should exist And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post date: {{ page.date }}" + And I have a simple layout that contains "Post date: {{ site.posts.first.date }}" When I run jekyll Then the _site directory should exist And I should see "Post date: Fri Mar 27" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post id: {{ page.id }}" + And I have a simple layout that contains "Post id: {{ site.posts.first.id }}" When I run jekyll Then the _site directory should exist And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html" @@ -53,7 +53,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post content: {{ content }}" + And I have a simple layout that contains "Post content: {{ site.posts.first.content }}" When I run jekyll Then the _site directory should exist And I should see "Post content:

Luke, I am your father.

" in "_site/2009/03/27/star-wars.html" @@ -65,7 +65,7 @@ Feature: Post data And I have the following post in "movies": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ page.categories }}" + And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -76,7 +76,7 @@ Feature: Post data And I have the following post: | title | date | layout | tag | content | | Star Wars | 5/18/2009 | simple | twist | Luke, I am your father. | - And I have a simple layout that contains "Post tags: {{ page.tags }}" + And I have a simple layout that contains "Post tags: {{ site.posts.first.tags }}" When I run jekyll Then the _site directory should exist And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" @@ -89,7 +89,7 @@ Feature: Post data And I have the following post in "movies/scifi": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -100,7 +100,7 @@ Feature: Post data And I have the following post: | title | date | layout | category | content | | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ page.categories }}" + And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -111,7 +111,7 @@ Feature: Post data And I have the following post: | title | date | layout | categories | content | | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -133,7 +133,7 @@ Feature: Post data And I have the following post: | title | date | layout | author | content | | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. | - And I have a simple layout that contains "Post author: {{ page.author }}" + And I have a simple layout that contains "Post author: {{ site.posts.first.author }}" When I run jekyll Then the _site directory should exist And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html" diff --git a/features/site_configuration.feature b/features/site_configuration.feature index a2b7d0ca..31b8c71e 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -61,21 +61,3 @@ Feature: Site configuration When I run jekyll Then the _site directory should exist 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" diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index f8dfec71..9fc91013 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -119,10 +119,6 @@ Then /^I should see "(.*)" in "(.*)"$/ do |text, file| assert_match Regexp.new(text), File.open(file).readlines.join 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| assert File.file?(file) end diff --git a/jekyll.gemspec b/jekyll.gemspec index 180cbd53..9bac5718 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.date = %q{2010-01-08} s.default_executable = %q{jekyll} s.description = %q{Jekyll is a simple, blog aware, static site generator.} - s.email = %q{kris@kris.me.uk} + s.email = %q{tom@mojombo.com} s.executables = ["jekyll"] s.extra_rdoc_files = [ "README.textile" @@ -33,7 +33,7 @@ Gem::Specification.new do |s| "features/site_data.feature", "features/step_definitions/jekyll_steps.rb", "features/support/env.rb", - "krisb-jekyll.gemspec", + "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/converters/csv.rb", @@ -94,7 +94,7 @@ Gem::Specification.new do |s| s.homepage = %q{http://github.com/mojombo/jekyll} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubyforge_project = %q{krisb-jekyll} + s.rubyforge_project = %q{jekyll} s.rubygems_version = %q{1.3.5} s.summary = %q{Jekyll is a simple, blog aware, static site generator.} s.test_files = [ diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 8f94ecc8..0e631b51 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -43,7 +43,6 @@ module Jekyll 'pygments' => false, 'markdown' => 'maruku', 'permalink' => 'date', - 'extensions' => false, 'maruku' => { 'use_tex' => false, diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index f3da5579..fd63f57a 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -3,10 +3,6 @@ # # Requires # self.site -> Jekyll::Site -# self.content= -# self.data= -# self.ext= -# self.output= module Jekyll module Convertible # Return the contents as a string diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 55d4d1e3..914cfd59 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -18,9 +18,12 @@ module Jekyll name =~ MATCHER end - attr_accessor :site - attr_accessor :data, :content, :output, :ext - attr_accessor :date, :slug, :published, :tags, :categories + attr_accessor :site, :date, :slug, :ext, :published, :data, :content, :output, :tags + attr_writer :categories + + def categories + @categories ||= [] + end # Initialize this Post instance. # +site+ is the Site @@ -48,8 +51,9 @@ module Jekyll self.tags = [self.data["tag"]] elsif self.data.has_key?("tags") self.tags = self.data['tags'] + else + self.tags = [] end - self.tags ||= [] if self.categories.empty? if self.data.has_key?('category') @@ -64,7 +68,6 @@ module Jekyll end end end - self.categories ||= [] end # Spaceship is based on Post#date, slug diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 64d989f1..3d47d16e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -2,8 +2,7 @@ module Jekyll class Site attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude, - :source, :dest, :lsi, :pygments, :permalink_style, :tags, - :extensions + :source, :dest, :lsi, :pygments, :permalink_style, :tags # Initialize the site # +config+ is a Hash containing site configurations details @@ -18,7 +17,6 @@ module Jekyll self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym self.exclude = config['exclude'] || [] - self.extensions = config['extensions'] self.reset self.setup @@ -84,12 +82,6 @@ module Jekyll else raise "Invalid Markdown processor: '#{self.config['markdown']}' -- did you mean 'maruku' or 'rdiscount'?" 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 def textile(content) diff --git a/test/test_post.rb b/test/test_post.rb index 36a3f287..b4b4502d 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -36,7 +36,6 @@ class TestPost < Test::Unit::TestCase end should "keep date, title, and markup type" do - @post.categories = [] @post.process(@fake_file) assert_equal Time.parse("2008-10-19"), @post.date @@ -215,13 +214,6 @@ class TestPost < Test::Unit::TestCase end context "initializing posts" do - - should "ensure suitable defaults for attributes" do - post = setup_post("2009-06-22-no-yaml.textile") - assert_equal [], post.tags - assert_equal [], post.categories - end - should "publish when published yaml is no specified" do post = setup_post("2008-02-02-published.textile") assert_equal true, post.published From 45bf0e8a33d540a5e80e00a71eb30edf95636839 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 10:30:18 +0000 Subject: [PATCH 30/84] removed usages of site.ports.first in some features where a better alternative is available --- features/embed_filters.feature | 6 +++--- features/post_data.feature | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/features/embed_filters.feature b/features/embed_filters.feature index f71dfb8f..61bd8da0 100644 --- a/features/embed_filters.feature +++ b/features/embed_filters.feature @@ -20,7 +20,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star & Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.title | xml_escape }}" + And I have a default layout that contains "{{ page.title | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "Star & Wars" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | default | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.content | xml_escape }}" + And I have a default layout that contains "{{ content | xml_escape }}" When I run jekyll Then the _site directory should exist And I should see "7" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Embed filters And I have the following post: | title | date | layout | tags | content | | Star Wars | 3/27/2009 | default | [scifi, movies, force] | These aren't the droids you're looking for. | - And I have a default layout that contains "{{ site.posts.first.tags | array_to_sentence_string }}" + And I have a default layout that contains "{{ page.tags | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html" diff --git a/features/post_data.feature b/features/post_data.feature index 87f5d851..1751f3f4 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -9,7 +9,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post title: {{ site.posts.first.title }}" + And I have a simple layout that contains "Post title: {{ page.title }}" When I run jekyll Then the _site directory should exist And I should see "Post title: Star Wars" in "_site/2009/03/27/star-wars.html" @@ -20,7 +20,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post url: {{ site.posts.first.url }}" + And I have a simple layout that contains "Post url: {{ page.url }}" When I run jekyll Then the _site directory should exist And I should see "Post url: /2009/03/27/star-wars.html" in "_site/2009/03/27/star-wars.html" @@ -31,7 +31,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post date: {{ site.posts.first.date }}" + And I have a simple layout that contains "Post date: {{ page.date }}" When I run jekyll Then the _site directory should exist And I should see "Post date: Fri Mar 27" in "_site/2009/03/27/star-wars.html" @@ -42,7 +42,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post id: {{ site.posts.first.id }}" + And I have a simple layout that contains "Post id: {{ page.id }}" When I run jekyll Then the _site directory should exist And I should see "Post id: /2009/03/27/star-wars" in "_site/2009/03/27/star-wars.html" @@ -53,7 +53,7 @@ Feature: Post data And I have the following post: | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post content: {{ site.posts.first.content }}" + And I have a simple layout that contains "Post content: {{ content }}" When I run jekyll Then the _site directory should exist And I should see "Post content:

Luke, I am your father.

" in "_site/2009/03/27/star-wars.html" @@ -65,7 +65,7 @@ Feature: Post data And I have the following post in "movies": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" + And I have a simple layout that contains "Post category: {{ page.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -76,7 +76,7 @@ Feature: Post data And I have the following post: | title | date | layout | tag | content | | Star Wars | 5/18/2009 | simple | twist | Luke, I am your father. | - And I have a simple layout that contains "Post tags: {{ site.posts.first.tags }}" + And I have a simple layout that contains "Post tags: {{ page.tags }}" When I run jekyll Then the _site directory should exist And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" @@ -89,7 +89,7 @@ Feature: Post data And I have the following post in "movies/scifi": | title | date | layout | content | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -100,7 +100,7 @@ Feature: Post data And I have the following post: | title | date | layout | category | content | | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. | - And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" + And I have a simple layout that contains "Post category: {{ page.categories }}" When I run jekyll Then the _site directory should exist And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" @@ -111,7 +111,7 @@ Feature: Post data And I have the following post: | title | date | layout | categories | content | | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | - And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" + And I have a simple layout that contains "Post categories: {{ page.categories | array_to_sentence_string }}" When I run jekyll Then the _site directory should exist And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" @@ -133,7 +133,7 @@ Feature: Post data And I have the following post: | title | date | layout | author | content | | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. | - And I have a simple layout that contains "Post author: {{ site.posts.first.author }}" + And I have a simple layout that contains "Post author: {{ page.author }}" When I run jekyll Then the _site directory should exist And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html" From e0e4a47af1d4bfc3a6b4cd85ffe47e48a9756aaa Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 16:09:24 +0000 Subject: [PATCH 31/84] added pluralized_array method to Hash and tests --- lib/jekyll/core_ext.rb | 22 ++++++++++++++ test/test_core_ext.rb | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 test/test_core_ext.rb diff --git a/lib/jekyll/core_ext.rb b/lib/jekyll/core_ext.rb index ead448a4..fc40cb38 100644 --- a/lib/jekyll/core_ext.rb +++ b/lib/jekyll/core_ext.rb @@ -19,6 +19,28 @@ class Hash target end + + # Read array from the supplied hash favouring the singular key + # and then the plural key, and handling any nil entries. + # +hash+ the hash to read from + # +singular_key+ the singular key + # +plural_key+ the singular key + # + # Returns an array + def pluralized_array(singular_key, plural_key) + hash = self + if hash.has_key?(singular_key) + array = [hash[singular_key]] if hash[singular_key] + elsif hash.has_key?(plural_key) + case hash[plural_key] + when String + array = hash[plural_key].split + when Array + array = hash[plural_key].compact + end + end + array || [] + end end # Thanks, ActiveSupport! diff --git a/test/test_core_ext.rb b/test/test_core_ext.rb new file mode 100644 index 00000000..85aca649 --- /dev/null +++ b/test/test_core_ext.rb @@ -0,0 +1,66 @@ +require File.dirname(__FILE__) + '/helper' + +class TestCoreExt < Test::Unit::TestCase + context "hash" do + + context "pluralized_array" do + + should "return empty array with no values" do + data = {} + assert_equal [], data.pluralized_array('tag', 'tags') + end + + should "return empty array with no matching values" do + data = { 'foo' => 'bar' } + assert_equal [], data.pluralized_array('tag', 'tags') + end + + should "return empty array with matching nil singular" do + data = { 'foo' => 'bar', 'tag' => nil, 'tags' => ['dog', 'cat'] } + assert_equal [], data.pluralized_array('tag', 'tags') + end + + should "return single value array with matching singular" do + data = { 'foo' => 'bar', 'tag' => 'dog', 'tags' => ['dog', 'cat'] } + assert_equal ['dog'], data.pluralized_array('tag', 'tags') + end + + should "return single value array with matching singular with spaces" do + data = { 'foo' => 'bar', 'tag' => 'dog cat', 'tags' => ['dog', 'cat'] } + assert_equal ['dog cat'], data.pluralized_array('tag', 'tags') + end + + should "return empty array with matching nil plural" do + data = { 'foo' => 'bar', 'tags' => nil } + assert_equal [], data.pluralized_array('tag', 'tags') + end + + should "return empty array with matching empty array" do + data = { 'foo' => 'bar', 'tags' => [] } + assert_equal [], data.pluralized_array('tag', 'tags') + end + + should "return single value array with matching plural with single string value" do + data = { 'foo' => 'bar', 'tags' => 'dog' } + assert_equal ['dog'], data.pluralized_array('tag', 'tags') + end + + should "return multiple value array with matching plural with single string value with spaces" do + data = { 'foo' => 'bar', 'tags' => 'dog cat' } + assert_equal ['dog', 'cat'], data.pluralized_array('tag', 'tags') + end + + should "return single value array with matching plural with single value array" do + data = { 'foo' => 'bar', 'tags' => ['dog'] } + assert_equal ['dog'], data.pluralized_array('tag', 'tags') + end + + should "return multiple value array with matching plural with multiple value array" do + data = { 'foo' => 'bar', 'tags' => ['dog', 'cat'] } + assert_equal ['dog', 'cat'], data.pluralized_array('tag', 'tags') + end + + end + + end +end From 2292e4268cc9043979764b3d154b359383f9d66b Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 16:12:41 +0000 Subject: [PATCH 32/84] added tests for handling of tags and catergories, see #73 and #84 --- .../2009-01-27-empty-categories.textile | 7 +++++++ .../_posts/2009-01-27-empty-category.textile | 7 +++++++ .../_posts/2009-05-18-empty-tag.textile | 6 ++++++ .../_posts/2009-05-18-empty-tags.textile | 6 ++++++ test/test_generated_site.rb | 2 +- test/test_post.rb | 20 +++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/2009-01-27-empty-categories.textile create mode 100644 test/source/_posts/2009-01-27-empty-category.textile create mode 100644 test/source/_posts/2009-05-18-empty-tag.textile create mode 100644 test/source/_posts/2009-05-18-empty-tags.textile diff --git a/test/source/_posts/2009-01-27-empty-categories.textile b/test/source/_posts/2009-01-27-empty-categories.textile new file mode 100644 index 00000000..6e784cc1 --- /dev/null +++ b/test/source/_posts/2009-01-27-empty-categories.textile @@ -0,0 +1,7 @@ +--- +layout: default +title: Category in YAML +categories: +--- + +Best *post* ever diff --git a/test/source/_posts/2009-01-27-empty-category.textile b/test/source/_posts/2009-01-27-empty-category.textile new file mode 100644 index 00000000..7e8b1b35 --- /dev/null +++ b/test/source/_posts/2009-01-27-empty-category.textile @@ -0,0 +1,7 @@ +--- +layout: default +title: Category in YAML +category: +--- + +Best *post* ever diff --git a/test/source/_posts/2009-05-18-empty-tag.textile b/test/source/_posts/2009-05-18-empty-tag.textile new file mode 100644 index 00000000..1f103f64 --- /dev/null +++ b/test/source/_posts/2009-05-18-empty-tag.textile @@ -0,0 +1,6 @@ +--- +title: A Tag +tag: +--- + +Whoa. diff --git a/test/source/_posts/2009-05-18-empty-tags.textile b/test/source/_posts/2009-05-18-empty-tags.textile new file mode 100644 index 00000000..5339d15d --- /dev/null +++ b/test/source/_posts/2009-05-18-empty-tags.textile @@ -0,0 +1,6 @@ +--- +title: Some Tags +tags: +--- + +Awesome! diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 357dd4db..47f25d6d 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 18, @site.posts.size + assert_equal 22, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index b4b4502d..6c8aeba5 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -236,6 +236,16 @@ class TestPost < Test::Unit::TestCase assert post.categories.include?('baz') end + should "recognize empty category in yaml" do + post = setup_post("2009-01-27-empty-category.textile") + assert_equal [], post.categories + end + + should "recognize empty categories in yaml" do + post = setup_post("2009-01-27-empty-categories.textile") + assert_equal [], post.categories + end + should "recognize tag in yaml" do post = setup_post("2009-05-18-tag.textile") assert post.tags.include?('code') @@ -248,6 +258,16 @@ class TestPost < Test::Unit::TestCase assert post.tags.include?('pizza') end + should "recognize empty tag in yaml" do + post = setup_post("2009-05-18-empty-tag.textile") + assert_equal [], post.tags + end + + should "recognize empty tags in yaml" do + post = setup_post("2009-05-18-empty-tags.textile") + assert_equal [], post.tags + end + should "allow no yaml" do post = setup_post("2009-06-22-no-yaml.textile") assert_equal "No YAML.", post.content From 93c029d62eb22658dcf16516172c421648f72a5f Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 16:14:25 +0000 Subject: [PATCH 33/84] fixed #73 and #84 --- lib/jekyll/post.rb | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 914cfd59..a86f31a2 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -47,26 +47,10 @@ module Jekyll self.published = true end - if self.data.has_key?("tag") - self.tags = [self.data["tag"]] - elsif self.data.has_key?("tags") - self.tags = self.data['tags'] - else - self.tags = [] - end + self.tags = self.data.pluralized_array("tag", "tags") if self.categories.empty? - if self.data.has_key?('category') - self.categories << self.data['category'] - elsif self.data.has_key?('categories') - # Look for categories in the YAML-header, either specified as - # an array or a string. - if self.data['categories'].kind_of? String - self.categories = self.data['categories'].split - else - self.categories = self.data['categories'] - end - end + self.categories = self.data.pluralized_array('category', 'categories') end end From ce228ac1c4b5764dd5d3e107e48ef8da94e01e13 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 16:24:56 +0000 Subject: [PATCH 34/84] removed accessor method and fixed tests --- lib/jekyll/convertible.rb | 4 ++++ lib/jekyll/post.rb | 9 +++------ test/test_post.rb | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index fd63f57a..f3da5579 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -3,6 +3,10 @@ # # Requires # self.site -> Jekyll::Site +# self.content= +# self.data= +# self.ext= +# self.output= module Jekyll module Convertible # Return the contents as a string diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index a86f31a2..1d9c70ed 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -18,12 +18,9 @@ module Jekyll name =~ MATCHER end - attr_accessor :site, :date, :slug, :ext, :published, :data, :content, :output, :tags - attr_writer :categories - - def categories - @categories ||= [] - end + attr_accessor :site + attr_accessor :data, :content, :output, :ext + attr_accessor :date, :slug, :published, :tags, :categories # Initialize this Post instance. # +site+ is the Site diff --git a/test/test_post.rb b/test/test_post.rb index 6c8aeba5..7b654b05 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -36,6 +36,7 @@ class TestPost < Test::Unit::TestCase end should "keep date, title, and markup type" do + @post.categories = [] @post.process(@fake_file) assert_equal Time.parse("2008-10-19"), @post.date From 21c92d3eb21b703d6ec6aeb98968d268f740ee0f Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 21:51:48 +0000 Subject: [PATCH 35/84] updated history --- History.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.txt b/History.txt index 8e5220f5..168636fd 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,7 @@ +== Edge + * Test Enhancement + * cucumber features no longer use site.ports.first where a better alternative is available + == 0.5.6 / 2010-01-08 * Bug Fixes * Require redcloth >= 4.2.1 in tests (#92) From 2aac9f37168d86d227e7bd1252c50f8630759b24 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 21:54:42 +0000 Subject: [PATCH 36/84] updated history --- History.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/History.txt b/History.txt index 168636fd..4f5f9b94 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,7 @@ == Edge + * Bug Fixes + * Categories isn't always an array (#73) + * Empty tags causes error in read_posts (#84) * Test Enhancement * cucumber features no longer use site.ports.first where a better alternative is available From a1550b3378386ef89ad8cd2118ab99237579db04 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 21:21:54 +0000 Subject: [PATCH 37/84] allow date to be specified in the front matter and override the value from the file name, fixes #62 and #38 --- lib/jekyll/post.rb | 7 +++++++ test/source/_posts/2010-01-09-date-override.textile | 5 +++++ test/source/_posts/2010-01-09-time-override.textile | 5 +++++ test/test_generated_site.rb | 2 +- test/test_post.rb | 10 ++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/2010-01-09-date-override.textile create mode 100644 test/source/_posts/2010-01-09-time-override.textile diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 914cfd59..c58f46e6 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -41,6 +41,13 @@ module Jekyll self.process(name) self.read_yaml(@base, name) + #If we've added a date and time to the yaml, use that instead of the filename date + #Means we'll sort correctly. + if self.data.has_key?('date') + # ensure Time via to_s and reparse + self.date = Time.parse(self.data["date"].to_s) + end + if self.data.has_key?('published') && self.data['published'] == false self.published = false else diff --git a/test/source/_posts/2010-01-09-date-override.textile b/test/source/_posts/2010-01-09-date-override.textile new file mode 100644 index 00000000..efe8af4a --- /dev/null +++ b/test/source/_posts/2010-01-09-date-override.textile @@ -0,0 +1,5 @@ +--- +date: 2010-01-10 +--- + +Post with a front matter date diff --git a/test/source/_posts/2010-01-09-time-override.textile b/test/source/_posts/2010-01-09-time-override.textile new file mode 100644 index 00000000..7f80065a --- /dev/null +++ b/test/source/_posts/2010-01-09-time-override.textile @@ -0,0 +1,5 @@ +--- +date: 2010-01-10 13:07:09 +--- + +Post with a front matter time diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 357dd4db..46e0a75d 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 18, @site.posts.size + assert_equal 20, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index b4b4502d..5cc11eaa 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -224,6 +224,16 @@ class TestPost < Test::Unit::TestCase assert_equal false, post.published end + should "recognize date in yaml" do + post = setup_post("2010-01-09-date-override.textile") + assert_equal "/2010/01/10/date-override.html", post.url + end + + should "recognize time in yaml" do + post = setup_post("2010-01-09-time-override.textile") + assert_equal "/2010/01/10/time-override.html", post.url + end + should "recognize category in yaml" do post = setup_post("2009-01-27-category.textile") assert post.categories.include?('foo') From 58b4ffd93595720fa63cec45b349631e90d3b4db Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 22:00:18 +0000 Subject: [PATCH 38/84] updated history --- History.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/History.txt b/History.txt index 4f5f9b94..50a53414 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,6 @@ == Edge + * Minor Enhancements + * Allow overriding of post date in the front matter (#62, #38) * Bug Fixes * Categories isn't always an array (#73) * Empty tags causes error in read_posts (#84) From a076ce070284702b108fd1e128b0de3011df948c Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 11 Jan 2010 22:04:39 -0800 Subject: [PATCH 39/84] add markdown feature test --- features/markdown.feature | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 features/markdown.feature diff --git a/features/markdown.feature b/features/markdown.feature new file mode 100644 index 00000000..ddb472f6 --- /dev/null +++ b/features/markdown.feature @@ -0,0 +1,30 @@ +Feature: Markdown + As a hacker who likes to blog + I want to be able to make a static site + In order to share my awesome ideas with the interwebs + + Scenario: Markdown in list on index + Given I have a configuration file with "paginate" set to "5" + And I have an "index.html" page that contains "Index - {% for post in site.posts %} {{ post.content }} {% endfor %}" + And I have a _posts directory + And I have the following post: + | title | date | content | type | + | Hackers | 3/27/2009 | # My Title | markdown | + When I run jekyll + Then the _site directory should exist + And I should see "Index" in "_site/index.html" + And I should see "

My Title

" in "_site/2009/03/27/hackers.html" + And I should see "

My Title

" in "_site/index.html" + + Scenario: Markdown in pagination on index + Given I have a configuration file with "paginate" set to "5" + And I have an "index.html" page that contains "Index - {% for post in paginator.posts %} {{ post.content }} {% endfor %}" + And I have a _posts directory + And I have the following post: + | title | date | content | type | + | Hackers | 3/27/2009 | # My Title | markdown | + When I run jekyll + Then the _site directory should exist + And I should see "Index" in "_site/index.html" + And I should see "

My Title

" in "_site/index.html" + \ No newline at end of file From b68149c7bc861cb758c6b0f8b211261705cc2452 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 12 Jan 2010 14:43:28 -0800 Subject: [PATCH 40/84] fix pagination to adhere to read/render/write paradigm --- History.txt | 1 + features/markdown.feature | 4 +-- features/pagination.feature | 2 +- lib/jekyll/page.rb | 6 ++++- lib/jekyll/site.rb | 50 ++++++++++++++++++++++--------------- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/History.txt b/History.txt index 50a53414..d776a639 100644 --- a/History.txt +++ b/History.txt @@ -4,6 +4,7 @@ * Bug Fixes * Categories isn't always an array (#73) * Empty tags causes error in read_posts (#84) + * Fix pagination to adhere to read/render/write paradigm * Test Enhancement * cucumber features no longer use site.ports.first where a better alternative is available diff --git a/features/markdown.feature b/features/markdown.feature index ddb472f6..859e6f7e 100644 --- a/features/markdown.feature +++ b/features/markdown.feature @@ -14,7 +14,7 @@ Feature: Markdown Then the _site directory should exist And I should see "Index" in "_site/index.html" And I should see "

My Title

" in "_site/2009/03/27/hackers.html" - And I should see "

My Title

" in "_site/index.html" + And I should see "

My Title

" in "_site/index.html" Scenario: Markdown in pagination on index Given I have a configuration file with "paginate" set to "5" @@ -26,5 +26,5 @@ Feature: Markdown When I run jekyll Then the _site directory should exist And I should see "Index" in "_site/index.html" - And I should see "

My Title

" in "_site/index.html" + And I should see "

My Title

" in "_site/index.html" \ No newline at end of file diff --git a/features/pagination.feature b/features/pagination.feature index 2b1b3467..90b10578 100644 --- a/features/pagination.feature +++ b/features/pagination.feature @@ -6,7 +6,7 @@ Feature: Site pagination Scenario Outline: Paginate with N posts per page Given I have a configuration file with "paginate" set to "" And I have a _layouts directory - And I have an "index.html" file that contains "{{ paginator.posts.size }}" + 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 | diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 20463903..62a757dc 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -4,7 +4,7 @@ module Jekyll include Convertible attr_accessor :site - attr_accessor :name, :ext, :basename + attr_accessor :name, :ext, :basename, :dir attr_accessor :data, :content, :output # Initialize a new Page. @@ -101,6 +101,10 @@ module Jekyll end end + def inspect + "#" + end + private def index? diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 3d47d16e..2a7294f8 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -147,8 +147,16 @@ module Jekyll end def render - [self.posts, self.pages].flatten.each do |convertible| - convertible.render(self.layouts, site_payload) + self.posts.each do |post| + post.render(self.layouts, site_payload) + end + + self.pages.dup.each do |page| + if Pager.pagination_enabled?(self.config, page.name) + paginate(page) + else + page.render(self.layouts, site_payload) + end end self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} } @@ -191,17 +199,13 @@ module Jekyll next if self.dest.sub(/\/$/, '') == f_abs read_directories(f_rel) elsif !File.symlink?(f_abs) - if Pager.pagination_enabled?(self.config, f) - paginate_posts(f, dir) + first3 = File.open(f_abs) { |fd| fd.read(3) } + if first3 == "---" + # file appears to have a YAML header so process it as a page + pages << Page.new(self, self.source, dir, f) else - first3 = File.open(f_abs) { |fd| fd.read(3) } - if first3 == "---" - # file appears to have a YAML header so process it as a page - pages << Page.new(self, self.source, dir, f) - else - # otherwise treat it as a static file - static_files << StaticFile.new(self, self.source, dir, f) - end + # otherwise treat it as a static file + static_files << StaticFile.new(self, self.source, dir, f) end end end @@ -244,8 +248,10 @@ module Jekyll end end - # Paginates the blog's posts. Renders the index.html file into paginated directories, ie: page2, page3... - # and adds more site-wide data + # Paginates the blog's posts. Renders the index.html file into paginated + # directories, ie: page2/index.html, page3/index.html, etc and adds more + # site-wide data. + # +page+ is the index.html Page that requires pagination # # {"paginator" => { "page" => , # "per_page" => , @@ -254,15 +260,19 @@ module Jekyll # "total_pages" => , # "previous_page" => , # "next_page" => }} - def paginate_posts(file, dir) - all_posts = self.posts.sort { |a,b| b <=> a } + def paginate(page) + all_posts = site_payload['site']['posts'] pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i) (1..pages).each do |num_page| pager = Pager.new(self.config, num_page, all_posts, pages) - page = Page.new(self, self.source, dir, file) - page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash})) - suffix = "page#{num_page}" if num_page > 1 - page.write(self.dest, suffix) + if num_page > 1 + newpage = Page.new(self, self.source, page.dir, page.name) + newpage.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash})) + newpage.dir = File.join(page.dir, "page#{num_page}") + self.pages << newpage + else + page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash})) + end end end end From 6dcfe1283a775fcf4a27c3a395e05714c2aa9c4a Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 12 Jan 2010 15:00:56 -0800 Subject: [PATCH 41/84] Version bump to 0.5.7 --- History.txt | 2 +- VERSION.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/History.txt b/History.txt index d776a639..07e3efee 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,4 @@ -== Edge +== 0.5.7 / 2010-01-12 * Minor Enhancements * Allow overriding of post date in the front matter (#62, #38) * Bug Fixes diff --git a/VERSION.yml b/VERSION.yml index a4ed05e5..5d5cc428 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :minor: 5 -:patch: 6 +:patch: 7 :build: :major: 0 From fff313a62dc6712654e4da6c668caa3c873b54a1 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 12 Jan 2010 15:09:16 -0800 Subject: [PATCH 42/84] Regenerated gemspec for version 0.5.7 --- jekyll.gemspec | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 9bac5718..b4d6b0c4 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{jekyll} - s.version = "0.5.6" + s.version = "0.5.7" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Tom Preston-Werner"] - s.date = %q{2010-01-08} + s.date = %q{2010-01-12} s.default_executable = %q{jekyll} s.description = %q{Jekyll is a simple, blog aware, static site generator.} s.email = %q{tom@mojombo.com} @@ -26,6 +26,7 @@ Gem::Specification.new do |s| "bin/jekyll", "features/create_sites.feature", "features/embed_filters.feature", + "features/markdown.feature", "features/pagination.feature", "features/permalinks.feature", "features/post_data.feature", @@ -66,12 +67,18 @@ Gem::Specification.new do |s| "test/source/_posts/2009-01-27-array-categories.textile", "test/source/_posts/2009-01-27-categories.textile", "test/source/_posts/2009-01-27-category.textile", + "test/source/_posts/2009-01-27-empty-categories.textile", + "test/source/_posts/2009-01-27-empty-category.textile", "test/source/_posts/2009-03-12-hash-#1.markdown", + "test/source/_posts/2009-05-18-empty-tag.textile", + "test/source/_posts/2009-05-18-empty-tags.textile", "test/source/_posts/2009-05-18-tag.textile", "test/source/_posts/2009-05-18-tags.textile", "test/source/_posts/2009-06-22-empty-yaml.textile", "test/source/_posts/2009-06-22-no-yaml.textile", "test/source/_posts/2010-01-08-triple-dash.markdown", + "test/source/_posts/2010-01-09-date-override.textile", + "test/source/_posts/2010-01-09-time-override.textile", "test/source/about.html", "test/source/category/_posts/2008-9-23-categories.textile", "test/source/contacts.html", @@ -83,6 +90,7 @@ Gem::Specification.new do |s| "test/source/z_category/_posts/2008-9-23-categories.textile", "test/suite.rb", "test/test_configuration.rb", + "test/test_core_ext.rb", "test/test_filters.rb", "test/test_generated_site.rb", "test/test_page.rb", @@ -101,6 +109,7 @@ Gem::Specification.new do |s| "test/helper.rb", "test/suite.rb", "test/test_configuration.rb", + "test/test_core_ext.rb", "test/test_filters.rb", "test/test_generated_site.rb", "test/test_page.rb", From 2b2e027b34a60cbb438dd048a4a532858cd5bbe6 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 13 Jan 2010 21:30:45 -0800 Subject: [PATCH 43/84] Render highlighted code for non markdown/textile pages. Fixes #116 --- History.txt | 4 ++++ lib/jekyll/tags/highlight.rb | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/History.txt b/History.txt index 07e3efee..8c821b9b 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,7 @@ +== Edge + * Bug Fixes + * Render highlighted code for non markdown/textile pages (#116) + == 0.5.7 / 2010-01-12 * Minor Enhancements * Allow overriding of post date in the front matter (#62, #38) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 93d94868..1fa9982c 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -31,10 +31,10 @@ module Jekyll def render_pygments(context, code) output = add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) - if context["content_type"] == "markdown" - return "\n" + output + "\n" - elsif context["content_type"] == "textile" - return "" + output + "" + case context["content_type"] + when "markdown" then "\n" + output + "\n" + when "textile" then "" + output + "" + else output end end From d88354e2dff644248c94617b8a20d12c7cb78bb3 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 13 Jan 2010 22:02:24 -0800 Subject: [PATCH 44/84] cuke feature for subdir include --- History.txt | 1 + features/create_sites.feature | 9 +++++++++ features/step_definitions/jekyll_steps.rb | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 8c821b9b..d28726a9 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == Edge * Bug Fixes * Render highlighted code for non markdown/textile pages (#116) + * Expand source to full path so includes work anywhere (#101) == 0.5.7 / 2010-01-12 * Minor Enhancements diff --git a/features/create_sites.feature b/features/create_sites.feature index 4f5385b0..f09b5a66 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -74,3 +74,12 @@ Feature: Create sites When I run jekyll Then the _site directory should exist And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html" + + Scenario: Basic site with subdir include tag + Given I have a _includes directory + And I have an "_includes/about.textile" file that contains "Generated by Jekyll" + And I have an info directory + And I have an "info/index.html" page that contains "Basic Site with subdir include tag: {% include about.textile %}" + When I run jekyll + Then the _site directory should exist + And I should see "Basic Site with subdir include tag: Generated by Jekyll" in "_site/info/index.html" \ No newline at end of file diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 9fc91013..38a87c37 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -39,7 +39,7 @@ Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text| end end -Given /^I have a (.*) directory$/ do |dir| +Given /^I have an? (.*) directory$/ do |dir| FileUtils.mkdir_p(dir) end From 0756d1f765a7cc7815fad5975a61393234fc0762 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 13 Jan 2010 22:17:46 -0800 Subject: [PATCH 45/84] add cuke feature for nested includes --- features/create_sites.feature | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/features/create_sites.feature b/features/create_sites.feature index f09b5a66..6ae7a08a 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -82,4 +82,13 @@ Feature: Create sites And I have an "info/index.html" page that contains "Basic Site with subdir include tag: {% include about.textile %}" When I run jekyll Then the _site directory should exist - And I should see "Basic Site with subdir include tag: Generated by Jekyll" in "_site/info/index.html" \ No newline at end of file + And I should see "Basic Site with subdir include tag: Generated by Jekyll" in "_site/info/index.html" + + Scenario: Basic site with nested include tag + Given I have a _includes directory + And I have an "_includes/about.textile" file that contains "Generated by {% include jekyll.textile %}" + And I have an "_includes/jekyll.textile" file that contains "Jekyll" + And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}" + When I run jekyll + Then the _site directory should exist + And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html" \ No newline at end of file From ba77a024d6eeb12c5e3113ab37fa8ef9e8489794 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 13 Jan 2010 22:33:38 -0800 Subject: [PATCH 46/84] fix highlighting on ruby 1.9. fixes #65 --- History.txt | 1 + lib/jekyll/tags/highlight.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/History.txt b/History.txt index d28726a9..c97cd08f 100644 --- a/History.txt +++ b/History.txt @@ -2,6 +2,7 @@ * Bug Fixes * Render highlighted code for non markdown/textile pages (#116) * Expand source to full path so includes work anywhere (#101) + * Fix highlighting on Ruby 1.9 (#65) == 0.5.7 / 2010-01-12 * Minor Enhancements diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 1fa9982c..046cf290 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -23,9 +23,9 @@ module Jekyll def render(context) if context.registers[:site].pygments - render_pygments(context, super.to_s) + render_pygments(context, super.join) else - render_codehighlighter(context, super.to_s) + render_codehighlighter(context, super.join) end end From 5fec20dfa8b03d378d8592920049528fa0a0a429 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 13 Jan 2010 22:46:58 -0800 Subject: [PATCH 47/84] update history for #64 fix --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index c97cd08f..b315c56c 100644 --- a/History.txt +++ b/History.txt @@ -3,6 +3,7 @@ * Render highlighted code for non markdown/textile pages (#116) * Expand source to full path so includes work anywhere (#101) * Fix highlighting on Ruby 1.9 (#65) + * Fix extension munging when pretty permalinks are enabled (#64) == 0.5.7 / 2010-01-12 * Minor Enhancements From 58354e269efe36cc8f8d2a3c26fba33ae9bdaff7 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sat, 16 Jan 2010 14:48:21 +0000 Subject: [PATCH 48/84] added tests to show how date and tags can end up having the wrong value when rendered --- .../_posts/2010-01-09-date-override.textile | 2 + .../_posts/2010-01-09-time-override.textile | 2 + .../2010-01-09-timezone-override.textile | 7 ++++ .../_posts/2010-01-16-override-data.textile | 4 ++ test/test_generated_site.rb | 2 +- test/test_post.rb | 40 +++++++++++++++++++ 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/2010-01-09-timezone-override.textile create mode 100644 test/source/_posts/2010-01-16-override-data.textile diff --git a/test/source/_posts/2010-01-09-date-override.textile b/test/source/_posts/2010-01-09-date-override.textile index efe8af4a..45b3834a 100644 --- a/test/source/_posts/2010-01-09-date-override.textile +++ b/test/source/_posts/2010-01-09-date-override.textile @@ -3,3 +3,5 @@ date: 2010-01-10 --- Post with a front matter date + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-09-time-override.textile b/test/source/_posts/2010-01-09-time-override.textile index 7f80065a..e462c418 100644 --- a/test/source/_posts/2010-01-09-time-override.textile +++ b/test/source/_posts/2010-01-09-time-override.textile @@ -3,3 +3,5 @@ date: 2010-01-10 13:07:09 --- Post with a front matter time + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-09-timezone-override.textile b/test/source/_posts/2010-01-09-timezone-override.textile new file mode 100644 index 00000000..3dc0e4fa --- /dev/null +++ b/test/source/_posts/2010-01-09-timezone-override.textile @@ -0,0 +1,7 @@ +--- +date: 2010-01-10 13:07:09 +00:00 +--- + +Post with a front matter time with timezone + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-16-override-data.textile b/test/source/_posts/2010-01-16-override-data.textile new file mode 100644 index 00000000..5b1a95c4 --- /dev/null +++ b/test/source/_posts/2010-01-16-override-data.textile @@ -0,0 +1,4 @@ +--- +date: 2010-01-10 13:07:09 +tags: A string +--- diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index a276e572..bfb86daa 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 24, @site.posts.size + assert_equal 26, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index f57f530d..7c602c67 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -227,12 +227,37 @@ class TestPost < Test::Unit::TestCase should "recognize date in yaml" do post = setup_post("2010-01-09-date-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class assert_equal "/2010/01/10/date-override.html", post.url + assert_equal "

Post with a front matter date

\n

10 Jan 2010

", post.output end should "recognize time in yaml" do post = setup_post("2010-01-09-time-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class assert_equal "/2010/01/10/time-override.html", post.url + assert_equal "

Post with a front matter time

\n

10 Jan 2010

", post.output + end + + should "recognize time with timezone in yaml" do + post = setup_post("2010-01-09-timezone-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class + assert_equal "/2010/01/10/timezone-override.html", post.url + assert_equal "

Post with a front matter time with timezone

\n

10 Jan 2010

", post.output + end + + should "to_liquid prioritizes post attributes over data" do + post = setup_post("2010-01-16-override-data.textile") + assert_equal Array, post.tags.class + assert_equal Array, post.to_liquid["tags"].class + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class end should "recognize category in yaml" do @@ -333,6 +358,21 @@ class TestPost < Test::Unit::TestCase assert_equal "<<<
\n

Tom Preston-Werner github.com/mojombo

\n\n

This is cool

>>>", post.output end + + should "render date specified in front matter properly" do + post = setup_post("2010-01-09-date-override.textile") + do_render(post) + + assert_equal "

Post with a front matter date

\n

10 Jan 2010

", post.output + end + + should "render time specified in front matter properly" do + post = setup_post("2010-01-09-time-override.textile") + do_render(post) + + assert_equal "

Post with a front matter time

\n

10 Jan 2010

", post.output + end + end end From ef6aa6b5c47a505b3e9b2d18a632c90f9eca6d15 Mon Sep 17 00:00:00 2001 From: Sebastian Staudt Date: Mon, 4 May 2009 23:53:40 +0200 Subject: [PATCH 49/84] Added passing of all options to Pygments, not just "linenos" --- lib/jekyll/tags/highlight.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 046cf290..35e27f91 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -4,15 +4,28 @@ module Jekyll include Liquid::StandardFilters # we need a language, but the linenos argument is optional. - SYNTAX = /(\w+)\s?(:?linenos)?\s?/ + SYNTAX = /(\w+)\s?([\w\s=]+)*/ def initialize(tag_name, markup, tokens) super if markup =~ SYNTAX @lang = $1 if defined? $2 + tmp_options = {} + $2.split.each do |opt| + key, value = opt.split('=') + if value.nil? + if key == 'linenos' + value = 'inline' + else + value = true + end + end + tmp_options[key] = value + end + tmp_options = tmp_options.to_a.collect { |opt| opt.join('=') } # additional options to pass to Albino. - @options = { 'O' => 'linenos=inline' } + @options = { 'O' => tmp_options.join(',') } else @options = {} end From 98fa570c86a40ac7ef1a5d83437b0dc264396405 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sun, 10 Jan 2010 22:28:04 +0000 Subject: [PATCH 50/84] added support for consistent site.time in payload, generating the site at a specific time and limiting future posts squish --- bin/jekyll | 12 +++++++ features/site_configuration.feature | 42 ++++++++++++++++++++++- features/step_definitions/jekyll_steps.rb | 13 +++++-- lib/jekyll.rb | 1 + lib/jekyll/site.rb | 9 +++-- test/test_site.rb | 2 ++ 6 files changed, 73 insertions(+), 6 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 6e03d48b..7ffd9d5d 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -48,6 +48,18 @@ opts = OptionParser.new do |opts| options['markdown'] = 'rdiscount' end + opts.on("--time [TIME]", "Time to generate the site for") do |time| + options['time'] = Time.parse(time) + end + + opts.on("--future", "Render future dated posts") do + options['future'] = true + end + + opts.on("--no-future", "Do not render future dated posts") do + options['future'] = false + end + opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style| options['permalink'] = style unless style.nil? end diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 31b8c71e..6f1c600e 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -33,7 +33,7 @@ Feature: Site configuration And I have an "README" file that contains "I want to be excluded" And I have an "index.html" file that contains "I want to be included" And I have a configuration file with "exclude" set to: - | Value | + | value | | README | | Rakefile | When I run jekyll @@ -61,3 +61,43 @@ Feature: Site configuration When I run jekyll Then the _site directory should exist And I should see "puts 'Hello world!'" in "_site/index.html" + + Scenario: Set time and no future dated posts + Given I have a _layouts directory + And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}" + And I have a post layout 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 | false | + 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: 1 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 the "_site/2020/01/31/entry2.html" file should not exist + + Scenario: Set time and future dated posts allowed + Given I have a _layouts directory + And I have a page layout that contains "Page Layout: {{ site.posts.size }} on {{ site.time | date: "%Y-%m-%d" }}" + And I have a post layout 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 | + 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 38a87c37..71b71d38 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -81,7 +81,16 @@ end Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value| File.open('_config.yml', 'w') do |f| - f.write("#{key}: #{value}") + f.write("#{key}: #{value}\n") + f.close + end +end + +Given /^I have a configuration file with:$/ do |table| + File.open('_config.yml', 'w') do |f| + table.hashes.each do |row| + f.write("#{row["key"]}: #{row["value"]}\n") + end f.close end end @@ -90,7 +99,7 @@ Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table| File.open('_config.yml', 'w') do |f| f.write("#{key}:\n") table.hashes.each do |row| - f.write("- #{row["Value"]}\n") + f.write("- #{row["value"]}\n") end f.close end diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 0e631b51..05c539ff 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -39,6 +39,7 @@ module Jekyll 'source' => '.', 'destination' => File.join('.', '_site'), + 'future' => true, 'lsi' => false, 'pygments' => false, 'markdown' => 'maruku', diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 59a6acd8..286d02dc 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -2,7 +2,8 @@ module Jekyll class Site attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude, - :source, :dest, :lsi, :pygments, :permalink_style, :tags + :source, :dest, :lsi, :pygments, :permalink_style, :tags, :time, + :future # Initialize the site # +config+ is a Hash containing site configurations details @@ -17,12 +18,14 @@ module Jekyll self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym self.exclude = config['exclude'] || [] + self.future = config['future'] self.reset self.setup end def reset + self.time = Time.parse(self.config['time'].to_s) || Time.now self.layouts = {} self.posts = [] self.pages = [] @@ -135,7 +138,7 @@ module Jekyll if Post.valid?(f) post = Post.new(self, self.source, dir, f) - if post.published + if post.published && (self.future || post.date <= self.time) self.posts << post post.categories.each { |c| self.categories[c] << post } post.tags.each { |c| self.tags[c] << post } @@ -230,7 +233,7 @@ module Jekyll # "categories" => []} def site_payload {"site" => self.config.merge({ - "time" => Time.now, + "time" => self.time, "posts" => self.posts.sort { |a,b| b <=> a }, "categories" => post_attr_hash('categories'), "tags" => post_attr_hash('tags')})} diff --git a/test/test_site.rb b/test/test_site.rb index b92bc496..705d0d09 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -22,6 +22,7 @@ class TestSite < Test::Unit::TestCase before_tags = @site.tags.length before_pages = @site.pages.length before_static_files = @site.static_files.length + before_time = @site.time @site.process assert_equal before_posts, @site.posts.length @@ -30,6 +31,7 @@ class TestSite < Test::Unit::TestCase assert_equal before_tags, @site.tags.length assert_equal before_pages, @site.pages.length assert_equal before_static_files, @site.static_files.length + assert before_time <= @site.time end should "read layouts" do From 657b2e4be33cc7dba548b7af58182f49e80d29f7 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Fri, 26 Feb 2010 21:00:04 +0000 Subject: [PATCH 51/84] updated history for change --- History.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.txt b/History.txt index 19c0f5a9..3be84a1e 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,8 @@ == Edge + * Minor Enhancements + * Inclusion/exclusion of future dated posts (#59) + * Generation for a specific time (#59) + * site.time allocated on render not per site_payload invocation (#59) * Bug Fixes * Render highlighted code for non markdown/textile pages (#116) * Expand source to full path so includes work anywhere (#101) From e4a2319bf3e9b9bf7c7775263424e76426911897 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Sat, 16 Jan 2010 14:48:21 +0000 Subject: [PATCH 52/84] added tests to show how date and tags can end up having the wrong value when rendered --- .../_posts/2010-01-09-date-override.textile | 2 + .../_posts/2010-01-09-time-override.textile | 2 + .../2010-01-09-timezone-override.textile | 7 ++++ .../_posts/2010-01-16-override-data.textile | 4 ++ test/test_generated_site.rb | 2 +- test/test_post.rb | 40 +++++++++++++++++++ 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 test/source/_posts/2010-01-09-timezone-override.textile create mode 100644 test/source/_posts/2010-01-16-override-data.textile diff --git a/test/source/_posts/2010-01-09-date-override.textile b/test/source/_posts/2010-01-09-date-override.textile index efe8af4a..45b3834a 100644 --- a/test/source/_posts/2010-01-09-date-override.textile +++ b/test/source/_posts/2010-01-09-date-override.textile @@ -3,3 +3,5 @@ date: 2010-01-10 --- Post with a front matter date + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-09-time-override.textile b/test/source/_posts/2010-01-09-time-override.textile index 7f80065a..e462c418 100644 --- a/test/source/_posts/2010-01-09-time-override.textile +++ b/test/source/_posts/2010-01-09-time-override.textile @@ -3,3 +3,5 @@ date: 2010-01-10 13:07:09 --- Post with a front matter time + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-09-timezone-override.textile b/test/source/_posts/2010-01-09-timezone-override.textile new file mode 100644 index 00000000..3dc0e4fa --- /dev/null +++ b/test/source/_posts/2010-01-09-timezone-override.textile @@ -0,0 +1,7 @@ +--- +date: 2010-01-10 13:07:09 +00:00 +--- + +Post with a front matter time with timezone + +{{ page.date | date_to_string }} diff --git a/test/source/_posts/2010-01-16-override-data.textile b/test/source/_posts/2010-01-16-override-data.textile new file mode 100644 index 00000000..5b1a95c4 --- /dev/null +++ b/test/source/_posts/2010-01-16-override-data.textile @@ -0,0 +1,4 @@ +--- +date: 2010-01-10 13:07:09 +tags: A string +--- diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index a276e572..bfb86daa 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 24, @site.posts.size + assert_equal 26, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_post.rb b/test/test_post.rb index f57f530d..7c602c67 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -227,12 +227,37 @@ class TestPost < Test::Unit::TestCase should "recognize date in yaml" do post = setup_post("2010-01-09-date-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class assert_equal "/2010/01/10/date-override.html", post.url + assert_equal "

Post with a front matter date

\n

10 Jan 2010

", post.output end should "recognize time in yaml" do post = setup_post("2010-01-09-time-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class assert_equal "/2010/01/10/time-override.html", post.url + assert_equal "

Post with a front matter time

\n

10 Jan 2010

", post.output + end + + should "recognize time with timezone in yaml" do + post = setup_post("2010-01-09-timezone-override.textile") + do_render(post) + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class + assert_equal "/2010/01/10/timezone-override.html", post.url + assert_equal "

Post with a front matter time with timezone

\n

10 Jan 2010

", post.output + end + + should "to_liquid prioritizes post attributes over data" do + post = setup_post("2010-01-16-override-data.textile") + assert_equal Array, post.tags.class + assert_equal Array, post.to_liquid["tags"].class + assert_equal Time, post.date.class + assert_equal Time, post.to_liquid["date"].class end should "recognize category in yaml" do @@ -333,6 +358,21 @@ class TestPost < Test::Unit::TestCase assert_equal "<<<
\n

Tom Preston-Werner github.com/mojombo

\n\n

This is cool

>>>", post.output end + + should "render date specified in front matter properly" do + post = setup_post("2010-01-09-date-override.textile") + do_render(post) + + assert_equal "

Post with a front matter date

\n

10 Jan 2010

", post.output + end + + should "render time specified in front matter properly" do + post = setup_post("2010-01-09-time-override.textile") + do_render(post) + + assert_equal "

Post with a front matter time

\n

10 Jan 2010

", post.output + end + end end From cfd6ebc7478ac2836ba59d34988f4ddd05cc611b Mon Sep 17 00:00:00 2001 From: lazyeye Date: Thu, 14 Jan 2010 01:10:26 -0800 Subject: [PATCH 53/84] pass time object to liquid when time is specified in front matter --- lib/jekyll/post.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 1e7238b4..3acfca32 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -201,7 +201,8 @@ module Jekyll # # Returns def to_liquid - { "title" => self.data["title"] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '), + self.data.deep_merge({ + "title" => self.data["title"] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '), "url" => self.url, "date" => self.date, "id" => self.id, @@ -209,7 +210,7 @@ module Jekyll "next" => self.next, "previous" => self.previous, "tags" => self.tags, - "content" => self.content }.deep_merge(self.data) + "content" => self.content }) end def inspect From 355b20265e048f9448ee0d1f99ed8b936d5b40b4 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Fri, 26 Feb 2010 21:33:56 +0000 Subject: [PATCH 54/84] removed whitespace from lazyeye's commit --- lib/jekyll/post.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 3acfca32..5ba5f16c 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -201,7 +201,7 @@ module Jekyll # # Returns def to_liquid - self.data.deep_merge({ + self.data.deep_merge({ "title" => self.data["title"] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '), "url" => self.url, "date" => self.date, From 4fd2b54a7de9f8c2fd7c120c2590fda7039b093c Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Fri, 26 Feb 2010 21:40:37 +0000 Subject: [PATCH 55/84] updated history --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index 3be84a1e..b9ab515f 100644 --- a/History.txt +++ b/History.txt @@ -9,6 +9,7 @@ * Fix highlighting on Ruby 1.9 (#65) * Fix extension munging when pretty permalinks are enabled (#64) * Stop sorting categories (#33) + * Preserve generated attributes over front matter (#119) == 0.5.7 / 2010-01-12 * Minor Enhancements From cd946a587b2e595615606b7dd46fb6f10802e8e0 Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Fri, 26 Feb 2010 22:07:26 +0000 Subject: [PATCH 56/84] removed tabs and made into a better example for sitemap times --- test/source/sitemap.xml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/source/sitemap.xml b/test/source/sitemap.xml index 96b38a14..8d9f0fcd 100644 --- a/test/source/sitemap.xml +++ b/test/source/sitemap.xml @@ -3,21 +3,21 @@ layout: nil --- - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + - http://example.com - {{ site.time | date_to_xmlschema }} - daily - 1.0 - - - {% for post in site.posts %} - - http://example.com/{{ post.url }}/ - {{ site.time }} - monthly - 0.2 - - {% endfor %} - \ No newline at end of file + http://example.com + {{ site.time | date: "%Y-%m-%d" }} + daily + 1.0 + + + {% for post in site.posts %} + + http://example.com/{{ post.url }}/ + {{ post.date | date: "%Y-%m-%d" }} + monthly + 0.2 + + {% endfor %} + From 5a807aa12e52e9fd33a30c86e308dcf842b3ee4d Mon Sep 17 00:00:00 2001 From: Kris Brown Date: Fri, 26 Feb 2010 22:08:16 +0000 Subject: [PATCH 57/84] pages now present in the site payload and can be used through the site.pages variable --- History.txt | 1 + features/create_sites.feature | 20 ++++++++++---------- lib/jekyll/page.rb | 11 ++++++++++- lib/jekyll/post.rb | 6 ++---- lib/jekyll/site.rb | 2 ++ 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/History.txt b/History.txt index b9ab515f..c8691f7a 100644 --- a/History.txt +++ b/History.txt @@ -3,6 +3,7 @@ * Inclusion/exclusion of future dated posts (#59) * Generation for a specific time (#59) * site.time allocated on render not per site_payload invocation (#59) + * pages now present in the site payload and can be used through the site.pages variable * Bug Fixes * Render highlighted code for non markdown/textile pages (#116) * Expand source to full path so includes work anywhere (#101) diff --git a/features/create_sites.feature b/features/create_sites.feature index 6ae7a08a..8517e28d 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -39,11 +39,11 @@ Feature: Create sites Scenario: Basic site with layouts, pages, posts and files Given I have a _layouts directory - And I have a page layout that contains "Page Layout: {{ site.posts.size }}" - And I have a post layout that contains "Post Layout: {{ content }}" - And I have an "index.html" page with layout "page" that contains "site index page" + And I have a page layout that contains "Page {{ page.title }}: {{ content }}" + And I have a post layout that contains "Post {{ page.title }}: {{ content }}" + And I have an "index.html" page with layout "page" that contains "Site contains {{ site.pages.size }} pages and {{ site.posts.size }} posts" And I have a blog directory - And I have a "blog/index.html" page with layout "page" that contains "category index page" + And I have a "blog/index.html" page with layout "page" that contains "blog category index page" And I have an "about.html" file that contains "No replacement {{ site.posts.size }}" And I have an "another_file" file that contains "" And I have a _posts directory @@ -58,14 +58,14 @@ Feature: Create sites | entry4 | 6/27/2009 | post | content for entry4. | When I run jekyll Then the _site directory should exist - And I should see "Page Layout: 4" in "_site/index.html" + And I should see "Page : Site contains 2 pages and 4 posts" in "_site/index.html" And I should see "No replacement \{\{ site.posts.size \}\}" in "_site/about.html" And I should see "" in "_site/another_file" - And I should see "Page Layout: 4" in "_site/blog/index.html" - And I should see "Post Layout:

content for entry1.

" in "_site/2009/03/27/entry1.html" - And I should see "Post Layout:

content for entry2.

" in "_site/2009/04/27/entry2.html" - And I should see "Post Layout:

content for entry3.

" in "_site/category/2009/05/27/entry3.html" - And I should see "Post Layout:

content for entry4.

" in "_site/category/2009/06/27/entry4.html" + And I should see "Page : blog category index page" in "_site/blog/index.html" + And I should see "Post entry1:

content for entry1.

" in "_site/2009/03/27/entry1.html" + And I should see "Post entry2:

content for entry2.

" in "_site/2009/04/27/entry2.html" + And I should see "Post entry3:

content for entry3.

" in "_site/category/2009/05/27/entry3.html" + And I should see "Post entry4:

content for entry4.

" in "_site/category/2009/06/27/entry4.html" Scenario: Basic site with include tag Given I have a _includes directory diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 62a757dc..acb806f2 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -75,10 +75,19 @@ module Jekyll # # Returns nothing def render(layouts, site_payload) - payload = {"page" => self.data}.deep_merge(site_payload) + payload = { + "page" => self.to_liquid + }.deep_merge(site_payload) + do_layout(payload, layouts) end + def to_liquid + self.data.deep_merge({ + "url" => self.url, + "content" => self.content }) + end + # Write the generated page file to the destination directory. # +dest_prefix+ is the String path to the destination dir # +dest_suffix+ is a suffix path to the destination dir diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 5ba5f16c..cfec6c2e 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -167,12 +167,10 @@ module Jekyll # Returns nothing def render(layouts, site_payload) # construct payload - payload = - { + payload = { "site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) }, "page" => self.to_liquid - } - payload = payload.deep_merge(site_payload) + }.deep_merge(site_payload) do_layout(payload, layouts) end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 286d02dc..2e3d9c98 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -230,11 +230,13 @@ module Jekyll # # Returns {"site" => {"time" =>