lib/octopress-ink/helpers/path.rb in octopress-ink-1.0.0.alpha.41 vs lib/octopress-ink/helpers/path.rb in octopress-ink-1.0.0.alpha.42
- old
+ new
@@ -21,13 +21,18 @@
# Returns the full path to a file
#
def self.expand(file, context)
root = context.registers[:site].source
- # If local file, e.g. ./somefile
- if file =~ /^\.\/(.+)/
- local_dir = File.dirname context.registers[:page]['path']
- File.join root, local_dir, $1
+ # If relative path, e.g. ./somefile, ../somefile
+ if file =~ /^\.+\//
+ page = context['page']
+ if local_dir = page['dir']
+ File.expand_path(File.join(local_dir, file))
+ else
+ local_dir = File.dirname page['path']
+ File.expand_path(File.join(root, local_dir, file))
+ end
# If absolute or relative to a user directory, e.g. /Users/Bob/somefile or ~/somefile
elsif file =~ /^[\/~]/
Pathname.new(file).expand_path