Commit 66b7a926 authored by rmrf's avatar rmrf
Browse files

Initial commit with the generators specific for jekyll-scholar

parent a7ea87ac
source :rubygems
gemspec
gem 'unicode_utils'
group 'development' do
gem 'debugger'
end
jekyll-scholar-extras
=====================
Extras for jekyll-scholar
\ No newline at end of file
Extras for jekyll-scholar
Hiren D. Patel
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'jekyll/scholar/version'
Gem::Specification.new do |s|
s.name = 'jekyll-scholar-extras'
s.version = Jekyll::ScholarExtras::VERSION.dup
s.platform = Gem::Platform::RUBY
s.authors = ['Hiren D. Patel']
s.email = ''
s.homepage = 'http://github.com/hdpatel/jekyll-scholar-extras'
s.summary = 'Extras for Jekyll extensions for the academic blogger jekyll-scholar.'
s.description = %q{
Extras for jekyll-scholar. Customized bibliography and details generators.
}.gsub(/\s+/, ' ')
s.date = Time.now
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = s.name
s.add_runtime_dependency('jekyll', '~> 0.10')
s.add_runtime_dependency('citeproc-ruby', '~> 0.0.6')
s.add_runtime_dependency('bibtex-ruby', '~> 2.0.5')
s.add_development_dependency('rake', "~> 0.9")
s.add_development_dependency('rdoc', "~> 3.11")
s.add_development_dependency('redgreen', "~> 1.2")
s.add_development_dependency('shoulda', "~> 2.11")
s.add_development_dependency('rr', "~> 1.0")
s.add_development_dependency('cucumber', "1.1")
s.add_development_dependency('RedCloth', "~> 4.2")
s.add_development_dependency('rdiscount', "~> 1.6")
s.add_development_dependency('redcarpet', "~> 1.9")
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = []
s.require_path = 'lib'
end
# vim: syntax=ruby
require 'jekyll/scholar'
require 'jekyll/scholar/extras/bibliography_hdp'
require 'jekyll/scholar/extras/details_hdp'
module Jekyll
class Scholar
class BibliographyHDPTag < Liquid::Tag
include Scholar::Utilities
def initialize(tag_name, arguments, tokens)
super
@config = Scholar.defaults.dup
@bibtex_file = arguments.strip
end
def render(context)
set_context_to context
year_section = ''
references = entries.map do |entry|
reference = ''
ref = ''
ref = CiteProc.process entry.to_citeproc, :style => config['style'],
:locale => config['locale'], :format => 'html'
content_tag :span, ref, :id => entry.key
if entry.field?(:year)
if (year_section != entry[:year])
reference << "<h1>"
reference << entry[:year].to_s
reference << "</h1>"
year_section = entry[:year]
end
end
reference << ref
if generate_details?
reference << "<br />"
reference << link_to(details_link_for(entry), config['details_link'])
end
content_tag :br, reference
end
references.join("\n")
#content_tag :ul, references.join("\n")
#content_tag :li, reference
end
end
end
end
Liquid::Template.register_tag('bibliography_hdp', Jekyll::Scholar::BibliographyHDPTag)
module Jekyll
class Scholar
class Details < Page
include Scholar::Utilities
def initialize(site, base, dir, entry)
@site, @base, @dir = site, base, dir
@config = Scholar.defaults.merge(site.config['scholar'] || {})
@name = details_file_for(entry)
process(@name)
read_yaml(File.join(base, '_layouts'), config['details_layout'])
liquidify(entry)
end
private
def liquidify(entry)
data['entry'] = {}
data['entry']['key'] = entry.key
data['entry']['type'] = entry.type
entry.fields.each do |key, value|
data['entry'][key.to_s] = value.to_s
end
data['entry']['bibtex'] = entry.to_s
# This is to get the CSL style output.
data['entry']['citeproc'] = CiteProc.process entry.to_citeproc, :style => config['style'],
:locale => config['locale'], :format => 'html'
name = entry.key.to_s.dup
name.gsub!(/[:\s]+/, '_')
data['entry']['pdflink'] = '../pdfs/' + name.to_s + '.pdf'
end
end
class DetailsGenerator < Generator
include Scholar::Utilities
safe true
attr_reader :config
def generate(site)
@site, @config = site, Scholar.defaults.merge(site.config['scholar'] || {})
if generate_details?
entries.each do |entry|
details = Details.new(site, site.source, details_path, entry)
details.render(site.layouts, site.site_payload)
details.write(site.dest)
site.pages << details
end
end
end
end
end
end
module Jekyll
class ScholarExtras
VERSION = '0.0.1'.freeze
end
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