Fix #179 make repository keys more flexible

parent fd1c3435
......@@ -98,3 +98,52 @@ Feature: PDF Repository
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"
@repository
Scenario: A bibliography with a single entry and a repository with slides pdf
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| repository | papers |
| bibliography_template | bibliography |
| file_delimit | '.' |
And I have a "_bibliography" directory
And I have a file "_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 "papers" directory
And I have a file "papers/ruby.pdf":
"""
The PDF
"""
And I have a file "papers/ruby.slides.pdf":
"""
The Slides PDF
"""
And I have a "_layouts" directory
And I have a file "_layouts/bibliography.html":
"""
---
---
{{ reference }} Link: {{ link }} Slides: {{ links['slides.pdf'] }}
"""
And I have a page "scholar.html":
"""
---
---
{% bibliography %}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/papers/ruby.pdf" file should exist
And the "_site/papers/ruby.slides.pdf" file should exist
And I should see "The Ruby Programming Language" in "_site/scholar.html"
And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
And I should see "Slides: /papers/ruby.slides.pdf" in "_site/scholar.html"
......@@ -27,8 +27,14 @@ module Jekyll
'source' => './_bibliography',
# Name of default references file
'bibliography' => 'references.bib',
# The repository folder with your entries' attachemnts, slides, etc.
'repository' => nil,
# Delimiter for files in repositories;
# this character may not be part of your entry keys!
'repository_file_delimiter' => '.',
'bibtex_options' => { :strip => false, :parse_months => true },
'bibtex_filters' => [ :superscript, :latex ],
'bibtex_skip_fields' => [ :abstract, :month_numeric ],
......@@ -70,7 +76,8 @@ module Jekyll
},
'type_order' => [],
'month_names' => nil,
'month_names' => nil
}.freeze
class << self
......
......@@ -239,6 +239,7 @@ module Jekyll
grouper(ungrouped, group_keys, group_order)
end
def group_keys
return @group_keys unless @group_keys.nil?
......@@ -357,8 +358,9 @@ module Jekyll
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]] = Pathname(path).relative_path_from(Pathname(base))
parts = path.split(repository_file_delimiter, 2)
repo[File.basename(parts[0])][parts[1]] =
Pathname(path).relative_path_from(Pathname(base))
end
repo
......@@ -368,6 +370,10 @@ module Jekyll
config['repository']
end
def repository_file_delimiter
config['repository_file_delimiter']
end
def replace_strings?
config['replace_strings']
end
......
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