issue-179.patch 4.15 KB
Newer Older
rmrf's avatar
rmrf committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
diff --git a/features/repository.feature b/features/repository.feature
index 3c4da7c..c88067a 100644
--- a/features/repository.feature
+++ b/features/repository.feature
@@ -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"
diff --git a/lib/jekyll/scholar/defaults.rb b/lib/jekyll/scholar/defaults.rb
index 78f77e5..ce28cc6 100644
--- a/lib/jekyll/scholar/defaults.rb
+++ b/lib/jekyll/scholar/defaults.rb
@@ -71,6 +71,9 @@ module Jekyll
       'type_order' => [],
 
       'month_names' => nil,
+      # Delimiter for files in repositories for slides
+      'file_delimit' => '_',
+      
     }.freeze
 
     class << self
diff --git a/lib/jekyll/scholar/tags/bibliography.rb b/lib/jekyll/scholar/tags/bibliography.rb
index 700bbb6..53822cc 100644
--- a/lib/jekyll/scholar/tags/bibliography.rb
+++ b/lib/jekyll/scholar/tags/bibliography.rb
@@ -8,7 +8,7 @@ module Jekyll
         super
 
         @config = Scholar.defaults.dup
-
+        
         optparse(arguments)
       end
 
diff --git a/lib/jekyll/scholar/utilities.rb b/lib/jekyll/scholar/utilities.rb
index 1b74235..abd414b 100644
--- a/lib/jekyll/scholar/utilities.rb
+++ b/lib/jekyll/scholar/utilities.rb
@@ -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,15 @@ 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']
+        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)]