From 6c6dd173c7b8f755d3784ee34368904faa4cd2bf Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Wed, 24 Jul 2013 16:30:24 +0200 Subject: [PATCH] Post + Page: extract real path retrieval into separate method (@parkr) --- lib/jekyll/page.rb | 7 ++++++- lib/jekyll/post.rb | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index fb4a8fb0a..9c728d56a 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -122,7 +122,12 @@ module Jekyll # # Returns the path to the source file def path - self.data.fetch('path', File.join(@dir, @name).sub(/\A\//, '')) + self.data.fetch('path', self.relative_path.sub(/\A\//, '')) + end + + # The path to the page source file, relative to the site source + def relative_path + File.join(@dir, @name) end # Obtain destination path. diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 7777ab576..415a3f66c 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -124,7 +124,12 @@ module Jekyll # # Returns the path to the file relative to the site source def path - self.data.fetch('path', File.join(@dir, '_posts', @name).sub(/\A\//, '')) + self.data.fetch('path', self.relative_path.sub(/\A\//, '')) + end + + # The path to the post source file, relative to the site source + def relative_path + File.join(@dir, '_posts', @name) end # Compares Post objects. First compares the Post date. If the dates are