Commit fa70c0fd by Thomas Wood

Allow file repository delimiter to appear in the repository path.

Patch includes testcase for this behaviour. And a testcase for using a different delimiter. Closes #179
parent edb9933f
...@@ -433,12 +433,12 @@ to link to supporting material in a ZIP archive: ...@@ -433,12 +433,12 @@ to link to supporting material in a ZIP archive:
{{ reference }} [<a href="{{links.zip}}">Supporting Materials</a>] {{ reference }} [<a href="{{links.zip}}">Supporting Materials</a>]
Jekyll-Scholar matches files which begin with a BibTeX key and are immediately Since version 5.9.0, Jekyll-Scholar matches files which begin with a BibTeX key
followed by a delimiter (default: "."). All text proceeding the delimiter is and are immediately followed by a delimiter (default: "."). All text proceeding
treated as the file extension. For example, if two files named `key.pdf` and the delimiter is treated as the file extension. For example, if two files named
`key.slides.pdf` are found, `{{links.pdf}}` and `{{links['slides.pdf']}}` will `key.pdf` and `key.slides.pdf` are found, `{{links.pdf}}` and
both be populated. You can use the configuration option `{{links['slides.pdf']}}` will both be populated. You can use the configuration
`repository_file_delimiter` to change the default delimiter. option `repository_file_delimiter` to change the default delimiter.
### Detail Pages ### Detail Pages
......
...@@ -106,7 +106,6 @@ Feature: PDF Repository ...@@ -106,7 +106,6 @@ Feature: PDF Repository
| source | ./_bibliography | | source | ./_bibliography |
| repository | papers | | repository | papers |
| bibliography_template | bibliography | | bibliography_template | bibliography |
| file_delimit | '.' |
And I have a "_bibliography" directory And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib": And I have a file "_bibliography/references.bib":
...@@ -147,3 +146,103 @@ Feature: PDF Repository ...@@ -147,3 +146,103 @@ Feature: PDF Repository
And I should see "The Ruby Programming Language" in "_site/scholar.html" 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 "Link: /papers/ruby.pdf" in "_site/scholar.html"
And I should see "Slides: /papers/ruby.slides.pdf" in "_site/scholar.html" And I should see "Slides: /papers/ruby.slides.pdf" in "_site/scholar.html"
@repository
Scenario: A bibliography with a single entry and a repository with slides pdf
using a custom delimiter
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| repository | papers |
| bibliography_template | bibliography |
| repository_file_delimiter | ':' |
And I have a "_bibliography" directory
And I have a file "_bibliography/references.bib":
"""
@book{ruby.ref,
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.ref:pdf":
"""
The PDF
"""
And I have a file "papers/ruby.ref: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.ref:pdf" file should exist
And the "_site/papers/ruby.ref:slides.pdf" file should exist
And I should see "The Ruby Programming Language" in "_site/scholar.html"
And I should see "Link: /papers/ruby.ref:pdf" in "_site/scholar.html"
And I should see "Slides: /papers/ruby.ref:slides.pdf" in "_site/scholar.html"
@repository
Scenario: A bibliography with a single entry and a repository with a directory
named using the delimiter with slides pdf
Given I have a scholar configuration with:
| key | value |
| source | ./_bibliography |
| repository | papers.dir |
| bibliography_template | bibliography |
| repository_file_delimiter | '.' |
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.dir" directory
And I have a file "papers.dir/ruby.pdf":
"""
The PDF
"""
And I have a file "papers.dir/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.dir/ruby.pdf" file should exist
And the "_site/papers.dir/ruby.slides.pdf" file should exist
And I should see "The Ruby Programming Language" in "_site/scholar.html"
And I should see "Link: /papers.dir/ruby.pdf" in "_site/scholar.html"
And I should see "Slides: /papers.dir/ruby.slides.pdf" in "_site/scholar.html"
...@@ -353,8 +353,8 @@ module Jekyll ...@@ -353,8 +353,8 @@ module Jekyll
base = Dir[site.source][0] base = Dir[site.source][0]
Dir[File.join(site.source, repository_path, '**/*')].each do |path| Dir[File.join(site.source, repository_path, '**/*')].each do |path|
parts = path.split(repository_file_delimiter, 2) parts = File.basename(path).split(repository_file_delimiter, 2)
repo[File.basename(parts[0])][parts[1]] = repo[parts[0]][parts[1]] =
Pathname(path).relative_path_from(Pathname(base)) Pathname(path).relative_path_from(Pathname(base))
end 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