Commit 95b0a4eb authored by Hiren Patel's avatar Hiren Patel

customize cite

parent 29213470
......@@ -3,3 +3,4 @@ require 'jekyll/scholar/extras/extra_utils'
require 'jekyll/scholar/extras/bibliography_hdp'
require 'jekyll/scholar/extras/bibliography_bytype'
require 'jekyll/scholar/extras/details_hdp'
require 'jekyll/scholar/tags/cite_details'
......@@ -60,7 +60,41 @@ module Jekyll
b
end
def details_file_for(entry)
name = entry.key.to_s.dup
name.gsub!(/[:\s]+/, '_')
[name, 'html'].join('.')
end
def details_link_for(entry, base = base_url)
[base, details_path, details_file_for(entry)].join('/')
end
def base_url
@base_url ||= site.config['baseurl'] || site.config['base_url'] || nil
end
def details_path
config['details_dir']
end
def cite(key)
entry = bibliography[key]
if bibliography.key?(key)
citation = CiteProc.process entry.to_citeproc, :style => config['style'],
:locale => config['locale'], :format => 'html', :mode => :citation
link_to "##{entry.key}", citation.join
else
"(missing reference)"
end
end
end
end
end
module Jekyll
class Scholar
class CiteTagDetails < Liquid::Tag
include Scholar::Utilities
include ScholarExtras::Utilities
attr_reader :key, :pages
def initialize(tag_name, arguments, tokens)
super
@config = Scholar.defaults.dup
@key = arguments.strip.split(/\s+/)[0]
end
def render(context)
set_context_to context
cite_details key
end
end
end
end
Liquid::Template.register_tag('cite_details', Jekyll::Scholar::CiteTagDetails)
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