diff --git a/Gemfile b/Gemfile index b791b55f35038bd32bbf17c60f8aaec47e933f0d..6229bc31b317026799f83787a404a98e223bda3d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,7 @@ source :rubygems gemspec gem 'unicode_utils' + +group 'development' do + gem 'debugger' +end diff --git a/features/details.feature b/features/details.feature new file mode 100644 index 0000000000000000000000000000000000000000..bacb4c2d27e90270bc19f1f26048c4c5d7a4ffc3 --- /dev/null +++ b/features/details.feature @@ -0,0 +1,37 @@ +Feature: BibTeX + As a scholar who likes to blog + I want to publish my BibTeX bibliography on my blog + And I want Jekyll to generate detail pages for all the entries in my bibliography + + @generators + Scenario: A bibliography with a single entry + Given I have a scholar configuration with: + | key | value | + | source | ./_bibliography | + | details_layout | details.html | + 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 "_layouts" directory + And I have a file "_layouts/details.html": + """ + --- + --- + + + + {{ page.entry.title }} + + + """ + When I run jekyll + Then the _site directory should exist + And the "_site/bibliography/ruby.html" file should exist + And I should see "The Ruby Programming Language" in "_site/bibliography/ruby.html" diff --git a/features/support/env.rb b/features/support/env.rb index 5e3a0b585a1a5780574fd083b332031d6c72bf70..06f1fb524920b7f3d92a8731bc05facf1b2a9771 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -3,8 +3,9 @@ require 'test/unit' require 'jekyll/scholar' -# require 'ruby-debug' -# Debugger.start + +require 'debugger' + World do include Test::Unit::Assertions diff --git a/lib/jekyll/scholar.rb b/lib/jekyll/scholar.rb index 5d0739671503f9f72d1427273cd42cc6eb13d872..b7ee6f00b93052ce32660082010dcd8b37b79a76 100644 --- a/lib/jekyll/scholar.rb +++ b/lib/jekyll/scholar.rb @@ -25,7 +25,7 @@ module Jekyll bibliography references.bib details_dir ./bibliography - detauls_layout bibtex.html + details_layout bibtex.html }].freeze diff --git a/lib/jekyll/scholar/generators/details.rb b/lib/jekyll/scholar/generators/details.rb index 7ffdc5e0cc23086fef9b3958511927ed252e16fd..1a4b40ecb99b515e91a6674ce9b94e8246d3b09e 100644 --- a/lib/jekyll/scholar/generators/details.rb +++ b/lib/jekyll/scholar/generators/details.rb @@ -7,14 +7,14 @@ module Jekyll def initialize(site, base, dir, entry) @site, @base, @dir = site, base, dir - + @config = Scholar.defaults.merge(site.config['scholar'] || {}) - + @name = [entry.key, 'html'].join('.') process(@name) read_yaml(File.join(base, '_layouts'), config['details_layout']) - + data['entry'] = entry end end @@ -25,12 +25,11 @@ module Jekyll attr_reader :config def generate(site) - if site.config['scholar'] && site.layouts.key?(site.config['scholar']['details_layout']) - - @config = Scholar.defaults.merge(site.config['scholar'] || {}) - - bibliography['@*'].each do |entry| - details = Detauls.new(site, site.source, config['details_dir'], entry) + @config = Scholar.defaults.merge(site.config['scholar'] || {}) + + if site.layouts.key?(File.basename(config['details_layout'], '.html')) + bibliography.each do |entry| + details = Details.new(site, site.source, config['details_dir'], entry) details.render(site.layouts, site.site_payload) details.write(site.dest) @@ -39,19 +38,15 @@ module Jekyll end end - + private def bibliography - @bibliography ||= BibTeX.open(extend_path(file), :filter => :latex) + @bibliography ||= BibTeX.open(bibliography_path, :filter => :latex) end - def extend_path(name) - if name.nil? || name.empty? - name = config['bibliography'] - end - - p = File.join(config['source'], name) + def bibliography_path + p = File.join(config['source'], config['bibliography']) p << '.bib' unless File.exists?(p) p end