404de362 by rmrf

Have to push to repo

1 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.ppt":
"""
The PPT
"""
And I have a "_layouts" directory
And I have a file "_layouts/bibliography.html":
"""
---
---
{{ reference }} Link: {{ link }} Slides: {{ link_slides }}
"""
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.ppt" 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.ppt" in "_site/scholar.html"
......
No preview for this file type
......@@ -71,6 +71,9 @@ module Jekyll
'type_order' => [],
'month_names' => nil,
# Delimiter for files in repositories for slides
'file_delimit' => '_',
}.freeze
class << self
......
......@@ -8,7 +8,7 @@ module Jekyll
super
@config = Scholar.defaults.dup
optparse(arguments)
end
......
......@@ -239,6 +239,7 @@ module Jekyll
grouper(ungrouped, group_keys, group_order)
end
def group_keys
return @group_keys unless @group_keys.nil?
......@@ -312,7 +313,7 @@ module Jekyll
value.to_s
end
end
def type_order
@type_order ||= config['type_order']
end
......@@ -486,7 +487,8 @@ module Jekyll
'key' => entry.key,
'type' => entry.type.to_s,
'link' => repository_link_for(entry),
'links' => repository_links_for(entry)
'links' => repository_links_for(entry),
'link_slides' => repository_link_slides_for(entry)
}
end
......@@ -557,6 +559,16 @@ module Jekyll
File.join(base, url)
end
def repository_link_slides_for(entry, base = base_url)
links = repository[entry.key + config['file_delimit'] + "slides"]
url = links['pdf'] || links['ps'] || links['pptx'] || links['ppt']
puts url
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)]
......