Commit 3152df77 authored by Sylvester Keil's avatar Sylvester Keil

improving on details page generator

#1
parent a1cace40
......@@ -2,3 +2,7 @@ source :rubygems
gemspec
gem 'unicode_utils'
group 'development' do
gem 'debugger'
end
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":
"""
---
---
<html>
<head></head>
<body>
{{ page.entry.title }}
</body>
</html>
"""
When I run jekyll
Then the _site directory should exist
And the "_site/bibliography/ruby.html" file should exist
And I should see "<i>The Ruby Programming Language</i>" in "_site/bibliography/ruby.html"
......@@ -3,8 +3,9 @@ require 'test/unit'
require 'jekyll/scholar'
# require 'ruby-debug'
# Debugger.start
require 'debugger'
World do
include Test::Unit::Assertions
......
......@@ -25,7 +25,7 @@ module Jekyll
bibliography references.bib
details_dir ./bibliography
detauls_layout bibtex.html
details_layout bibtex.html
}].freeze
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment