From 2fbcaef62b839a0e32c903589e0507e58c081567 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Wed, 21 Jan 2015 16:05:49 +0100 Subject: [PATCH] improve source path expansion fix #53 --- lib/jekyll/scholar/utilities.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/scholar/utilities.rb b/lib/jekyll/scholar/utilities.rb index 9f236d5..2d93e72 100644 --- a/lib/jekyll/scholar/utilities.rb +++ b/lib/jekyll/scholar/utilities.rb @@ -208,12 +208,22 @@ module Jekyll name = config['bibliography'] end - # return as is if it is an absolute path + # Return as is if it is an absolute path + # Improve by using Pathname from stdlib? return name if name.start_with?('/') && File.exists?(name) - p = File.join(config['source'], name) - p << '.bib' unless File.exists?(p) - p + name = File.join scholar_source, name + name << '.bib' if File.extname(name).empty? && !File.exists?(name) + name + end + + def scholar_source + source = config['source'] + + # Improve by using Pathname from stdlib? + return source if source.start_with?('/') && File.exists?(source) + + File.join site.source, source end def reference_tag(entry, index = nil) -- GitLab