Commit fa1f4834 by JoostvanPinxten Committed by Sylvester Keil

Take into account source directory from original configuration for the generated…

Take into account source directory from original configuration for the generated repository links (#152) * Allow the test environment to keep the originally sat 'source' value. * Add a test case and a fix for the ignored source setting in the configuration file. * Prepend the TEST_DIR only when the source configuration is not set to an absolute path (making it absolute in the process) * Fix the definition of the relative repository paths, and fix the test feature to properly use the configured source directory.
parent e84adc64
......@@ -49,5 +49,52 @@ Feature: PDF Repository
And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
And I should see "Slides: /papers/ruby.ppt" in "_site/scholar.html"
@repository
Scenario: A bibliography with a single entry and a repository, with source directory set
Given I have a configuration file with:
| key | value |
| source | src |
And I have a scholar configuration with:
| key | value |
| source | _bibliography |
| repository | papers |
| bibliography_template | bibliography |
And I have a "src" directory
And I have a "src/_bibliography" directory
And I have a file "src/_bibliography/references.bib":
"""
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
And I have a "src/papers" directory
And I have a file "src/papers/ruby.pdf":
"""
The PDF
"""
And I have a file "src/papers/ruby.ppt":
"""
The PPT
"""
And I have a "src/_layouts" directory
And I have a file "src/_layouts/bibliography.html":
"""
---
---
{{ reference }} Link: {{ link }} Slides: {{ links.ppt }}
"""
And I have a page "src/scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And I should see "The Ruby Programming Language" in "_site/scholar.html"
And the "_site/papers/ruby.pdf" file should exist
And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
And I should see "Slides: /papers/ruby.ppt" in "_site/scholar.html"
......@@ -21,13 +21,25 @@ require 'tmpdir'
TEST_DIR = File.join(Dir.tmpdir, 'jekyll')
def run_jekyll(options = {})
def prepend_test_dir(options, key)
if options.key?(key)
if Pathname(options[key]).relative?
options[key] = File.join(TEST_DIR, options[key])
end
else
options[key] ||= TEST_DIR
end
end
options['source'] ||= TEST_DIR
options['destination'] ||= File.join(TEST_DIR, '_site')
def run_jekyll(options = {})
options = Jekyll.configuration(options)
prepend_test_dir(options, 'source')
prepend_test_dir(options, 'destination')
print options['source'] + "\n"
print options['destination'] + "\n"
site = Jekyll::Site.new(options)
site.process
......
......@@ -352,9 +352,13 @@ module Jekyll
return repo unless repository?
Dir[File.join(repository_path, '**/*')].each do |path|
# ensure that the base directory format is literally
# the same as the entries that are in the directory
base = Dir[site.source][0]
Dir[File.join(site.source, repository_path, '**/*')].each do |path|
extname = File.extname(path)
repo[File.basename(path, extname)][extname[1..-1]] = path
repo[File.basename(path, extname)][extname[1..-1]] = Pathname(path).relative_path_from(Pathname(base))
end
repo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment