class Jekyll::BibSonomyPostList

Public Class Methods

new(tag_name, text, tokens) click to toggle source
Calls superclass method
# File lib/bibsonomy-jekyll.rb, line 27
def initialize(tag_name, text, tokens)
  super
  @input = text
end

Public Instance Methods

render(context) click to toggle source
# File lib/bibsonomy-jekyll.rb, line 32
def render(context)
  # expand liquid variables
  rendered_input = Liquid::Template.parse(@input).render(context)

  # parse parameters
  parts = rendered_input.split(/\s+/)
  grouping = parts.shift
  name = parts.shift
  # the last element is the number of posts
  count = Integer(parts.pop)
  # everything else are the tags
  tags = parts

  # extract config
  site = context.registers[:site]

  # user name and API key for BibSonomy
  bib_config = site.config['bibsonomy']
  csl = BibSonomy::CSL.new(bib_config['user'], bib_config['apikey'])

  # target directory for PDF documents
  csl.pdf_dir = bib_config['document_directory']

  # Altmetric badge type
  csl.altmetric_badge_type = bib_config['altmetric_badge_type']

  # CSL style for rendering
  csl.style = bib_config['style']

  html = csl.render(grouping, name, tags, count)

  # set date to now
  context.registers[:page]["date"] = Time.new

  return html
end