Commit 93257ead authored by Sylvester Keil's avatar Sylvester Keil
Browse files

add support for multiple files in repository

see #59
parent 4868c178
......@@ -379,12 +379,19 @@ Postscript files of your papers, you can use the configuration option
`repository` to indicate this directory. When generating bibliographies,
Jekyll-Scholar will look in that folder to see if it contains a filename
matching each entry's BibTeX key: if it does, the path to that file
will be exposed to the bibliography template.
will be exposed to the bibliography template as the `link` property.
Since version 4.1.0 repositories are not limited to PDF and PS files.
These files are mapped to the `links` property in your bibliography
template. Here is an example of template that utilizes this feature
to link to supporting material in a ZIP archive:
{{ reference }} [<a href="{{}}">Supporting Materials</a>]
### Detail Pages
If your layouts directory contains a layout file for bibliography details
(the 'details_layout' configuration options), Jekyll-Scholar will generate
(the `details_layout` configuration options), Jekyll-Scholar will generate
a details page for each entry in you main bibliography. That is to say, if
your bibliography contains the following entry:
......@@ -25,12 +25,16 @@ Feature: PDF Repository
And I have a file "papers/ruby.ppt":
And I have a "_layouts" directory
And I have a file "_layouts/bibliography.html":
{{ reference }} Link: {{ link }}
{{ reference }} Link: {{ link }} Slides: {{ links.ppt }}
And I have a page "scholar.html":
......@@ -43,6 +47,7 @@ Feature: PDF Repository
And the "_site/papers/ruby.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.ppt" in "_site/scholar.html"
......@@ -151,11 +151,16 @@ module Jekyll
def load_repository
return {} unless repository?
repo = { |h,k| h[k] = {} }
Hash[Dir[File.join(repository_path, '**/*.{pdf,ps}')].map { |path|
[File.basename(path).sub(/\.(pdf|ps)$/, ''), path]
return repo unless repository?
Dir[File.join(repository_path, '**/*')].each do |path|
extname = File.extname(path)
repo[File.basename(path, extname)][extname[1..-1]] = path
def repository_path
......@@ -241,6 +246,7 @@ module Jekyll
'key' => entry.key,
'type' => entry.type.to_s,
'link' => repository_link_for(entry),
'links' => repository_links_for(entry),
'index' => index,
'details' => details_link_for(entry)
......@@ -281,12 +287,20 @@ module Jekyll
def repository_link_for(entry, base = base_url)
url = repository[entry.key]
links = repository[entry.key]
url = links['pdf'] || links['ps']
return unless url
File.join(base, url)
def repository_links_for(entry, base = base_url)
Hash[repository[entry.key].map { |ext, url|
[ext, File.join(base, url)]
def details_link_for(entry, base = base_url)
File.join(base, details_path, details_file_for(entry))
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