From 9fcbe22e5792ca635533d561f4ba928e24846668 Mon Sep 17 00:00:00 2001 From: rmrf Date: Mon, 23 Jan 2017 19:28:44 -0500 Subject: [PATCH] jekyll-scholar: Patch issue 179 --- patches/issue-179.patch | 131 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 patches/issue-179.patch diff --git a/patches/issue-179.patch b/patches/issue-179.patch new file mode 100644 index 0000000..8f3404e --- /dev/null +++ b/patches/issue-179.patch @@ -0,0 +1,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)] -- GitLab