Between Tuesday August 20th, 5:00pm and Thursday August 22nd, 8:00am git.uwaterloo.ca will be down for an upgrade to version 10.8.7.

9fcbe22e by rmrf

jekyll-scholar: Patch issue 179

1 parent 7e43c85e
1 diff --git a/features/repository.feature b/features/repository.feature
2 index 3c4da7c..c88067a 100644
3 --- a/features/repository.feature
4 +++ b/features/repository.feature
5 @@ -98,3 +98,52 @@ Feature: PDF Repository
6 And the "_site/papers/ruby.pdf" file should exist
7 And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
8 And I should see "Slides: /papers/ruby.ppt" in "_site/scholar.html"
9 +
10 + @repository
11 + Scenario: A bibliography with a single entry and a repository with slides pdf
12 + Given I have a scholar configuration with:
13 + | key | value |
14 + | source | ./_bibliography |
15 + | repository | papers |
16 + | bibliography_template | bibliography |
17 + | file_delimit | '.' |
18 +
19 + And I have a "_bibliography" directory
20 + And I have a file "_bibliography/references.bib":
21 + """
22 + @book{ruby,
23 + title = {The Ruby Programming Language},
24 + author = {Flanagan, David and Matsumoto, Yukihiro},
25 + year = {2008},
26 + publisher = {O'Reilly Media}
27 + }
28 + """
29 + And I have a "papers" directory
30 + And I have a file "papers/ruby.pdf":
31 + """
32 + The PDF
33 + """
34 + And I have a file "papers/ruby.slides.ppt":
35 + """
36 + The PPT
37 + """
38 + And I have a "_layouts" directory
39 + And I have a file "_layouts/bibliography.html":
40 + """
41 + ---
42 + ---
43 + {{ reference }} Link: {{ link }} Slides: {{ link_slides }}
44 + """
45 + And I have a page "scholar.html":
46 + """
47 + ---
48 + ---
49 + {% bibliography %}
50 + """
51 + When I run jekyll
52 + Then the _site directory should exist
53 + And the "_site/papers/ruby.pdf" file should exist
54 + And the "_site/papers/ruby.slides.ppt" file should exist
55 + And I should see "The Ruby Programming Language" in "_site/scholar.html"
56 + And I should see "Link: /papers/ruby.pdf" in "_site/scholar.html"
57 + And I should see "Slides: /papers/ruby.slides.ppt" in "_site/scholar.html"
58 diff --git a/lib/jekyll/scholar/defaults.rb b/lib/jekyll/scholar/defaults.rb
59 index 78f77e5..ce28cc6 100644
60 --- a/lib/jekyll/scholar/defaults.rb
61 +++ b/lib/jekyll/scholar/defaults.rb
62 @@ -71,6 +71,9 @@ module Jekyll
63 'type_order' => [],
64
65 'month_names' => nil,
66 + # Delimiter for files in repositories for slides
67 + 'file_delimit' => '_',
68 +
69 }.freeze
70
71 class << self
72 diff --git a/lib/jekyll/scholar/tags/bibliography.rb b/lib/jekyll/scholar/tags/bibliography.rb
73 index 700bbb6..53822cc 100644
74 --- a/lib/jekyll/scholar/tags/bibliography.rb
75 +++ b/lib/jekyll/scholar/tags/bibliography.rb
76 @@ -8,7 +8,7 @@ module Jekyll
77 super
78
79 @config = Scholar.defaults.dup
80 -
81 +
82 optparse(arguments)
83 end
84
85 diff --git a/lib/jekyll/scholar/utilities.rb b/lib/jekyll/scholar/utilities.rb
86 index 1b74235..abd414b 100644
87 --- a/lib/jekyll/scholar/utilities.rb
88 +++ b/lib/jekyll/scholar/utilities.rb
89 @@ -239,6 +239,7 @@ module Jekyll
90 grouper(ungrouped, group_keys, group_order)
91 end
92
93 +
94 def group_keys
95 return @group_keys unless @group_keys.nil?
96
97 @@ -312,7 +313,7 @@ module Jekyll
98 value.to_s
99 end
100 end
101 -
102 +
103 def type_order
104 @type_order ||= config['type_order']
105 end
106 @@ -486,7 +487,8 @@ module Jekyll
107 'key' => entry.key,
108 'type' => entry.type.to_s,
109 'link' => repository_link_for(entry),
110 - 'links' => repository_links_for(entry)
111 + 'links' => repository_links_for(entry),
112 + 'link_slides' => repository_link_slides_for(entry)
113 }
114 end
115
116 @@ -557,6 +559,15 @@ module Jekyll
117 File.join(base, url)
118 end
119
120 + def repository_link_slides_for(entry, base = base_url)
121 + links = repository[entry.key + config['file_delimit'] + "slides"]
122 + url = links['pdf'] || links['ps'] || links['pptx'] || links['ppt']
123 + return unless url
124 +
125 + File.join(base, url)
126 + end
127 +
128 +
129 def repository_links_for(entry, base = base_url)
130 Hash[repository[entry.key].map { |ext, url|
131 [ext, File.join(base, url)]