From 606c525099d98add4df1a628c484796681ce953e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 21 Jan 2014 23:50:16 -0500 Subject: [PATCH 1/3] Relative posts should never fail to build, even if @dir or @name is nil Fixes https://github.com/jekyll/jekyll/issues/1963 --- lib/jekyll/page.rb | 5 ++++- lib/jekyll/post.rb | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 469dbb53..5fd70eb2 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -126,7 +126,10 @@ module Jekyll # The path to the page source file, relative to the site source def relative_path - File.join(@dir, @name) + File.join([ + @dir.to_s, + @name.to_s + ].reject {|x| x.nil? || x.empty?}) end # Obtain destination path. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 23e131ee..6dc8e83b 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -133,7 +133,11 @@ module Jekyll # The path to the post source file, relative to the site source def relative_path - File.join(@dir, '_posts', @name) + File.join([ + @dir.to_s, + "_posts", + @name.to_s + ].reject {|x| x.nil? || x.empty?}) end # Compares Post objects. First compares the Post date. If the dates are From baabe7eb7e4bca8b3f2d5154f3862335a5903715 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 30 Jan 2014 22:03:10 -0500 Subject: [PATCH 2/3] DRY up code, props @tamouse --- lib/jekyll/page.rb | 5 +---- lib/jekyll/post.rb | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 5fd70eb2..0e857660 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -126,10 +126,7 @@ module Jekyll # The path to the page source file, relative to the site source def relative_path - File.join([ - @dir.to_s, - @name.to_s - ].reject {|x| x.nil? || x.empty?}) + File.join([@dir, @name].map(&:to_s).reject(&:empty?)) end # Obtain destination path. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 6dc8e83b..825bd497 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -133,11 +133,7 @@ module Jekyll # The path to the post source file, relative to the site source def relative_path - File.join([ - @dir.to_s, - "_posts", - @name.to_s - ].reject {|x| x.nil? || x.empty?}) + File.join([@dir, "_posts", @name].map(&:to_s).reject(&:empty?)) end # Compares Post objects. First compares the Post date. If the dates are From 1176fc6f5767e1321131c6f6ca6b457deda6f166 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 8 Feb 2014 00:38:59 -0500 Subject: [PATCH 3/3] Give File.join the strings from the array --- lib/jekyll/page.rb | 2 +- lib/jekyll/post.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 0e857660..79542d8b 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -126,7 +126,7 @@ module Jekyll # The path to the page source file, relative to the site source def relative_path - File.join([@dir, @name].map(&:to_s).reject(&:empty?)) + File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)) end # Obtain destination path. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 825bd497..16f941a2 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -133,7 +133,7 @@ module Jekyll # The path to the post source file, relative to the site source def relative_path - File.join([@dir, "_posts", @name].map(&:to_s).reject(&:empty?)) + File.join(*[@dir, "_posts", @name].map(&:to_s).reject(&:empty?)) end # Compares Post objects. First compares the Post date. If the dates are