Commit a1cace40 authored by Sylvester Keil's avatar Sylvester Keil

added details generator

parent 88df06a2
...@@ -8,17 +8,25 @@ require 'jekyll/scholar/version' ...@@ -8,17 +8,25 @@ require 'jekyll/scholar/version'
require 'jekyll/scholar/converters/bibtex' require 'jekyll/scholar/converters/bibtex'
require 'jekyll/scholar/tags/bibliography' require 'jekyll/scholar/tags/bibliography'
require 'jekyll/scholar/tags/cite' require 'jekyll/scholar/tags/cite'
require 'jekyll/scholar/generators/details'
module Jekyll module Jekyll
class Scholar class Scholar
@defaults = Hash[*%w{ @defaults = Hash[*%w{
style apa style apa
locale en locale en
sort_by none sort_by none
order ascending order ascending
source ./_bibliography source ./_bibliography
bibliography references.bib bibliography references.bib
details_dir ./bibliography
detauls_layout bibtex.html
}].freeze }].freeze
class << self class << self
......
module Jekyll
class Scholar
class Details < Page
attr_reader :config
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
class DetailsGenerator < Generator
safe true
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)
details.render(site.layouts, site.site_payload)
details.write(site.dest)
site.pages << details
end
end
end
private
def bibliography
@bibliography ||= BibTeX.open(extend_path(file), :filter => :latex)
end
def extend_path(name)
if name.nil? || name.empty?
name = config['bibliography']
end
p = File.join(config['source'], name)
p << '.bib' unless File.exists?(p)
p
end
end
end
end
\ No newline at end of file
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