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

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="{{links.zip}}">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:
......@@ -437,8 +444,8 @@ configuration option. For example:
query: "@book" #=> includes only books
query: "@article[year>=2003]" #=> includes only articles published 2003 or later
query: "@*[url]" #=> includes all entries with a url field
query: "@*[status!=review]" #=> includes all entries whose status field is not set to 'review'
query: "@book[year <= 1900 && author ^= Poe]" #=> Books published before 1900 where the author matches /Poe/
query: "@*[status!=review]" #=> includes all entries whose status field is not set to 'review'
query: "@book[year <= 1900 && author ^= Poe]" #=> Books published before 1900 where the author matches /Poe/
query: "!@book" #=> includes all entries with a type other than book
Please note that some of these queries require BibTeX-Ruby 2.3.0 or
......
......@@ -25,12 +25,16 @@ Feature: PDF Repository
"""
The PDF
"""
And I have a file "papers/ruby.ppt":
"""
The 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
end
def load_repository
return {} unless repository?
repo = Hash.new { |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
end
repo
end
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
end
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)
end
def repository_links_for(entry, base = base_url)
Hash[repository[entry.key].map { |ext, url|
[ext, File.join(base, url)]
}]
end
def details_link_for(entry, base = base_url)
File.join(base, details_path, details_file_for(entry))
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