Class: Jekyll::BibSonomyPostList
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::BibSonomyPostList
- Defined in:
- lib/bibsonomy-jekyll.rb
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ BibSonomyPostList
constructor
A new instance of BibSonomyPostList.
- #override_config(config, parts) ⇒ Object
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, text, tokens) ⇒ BibSonomyPostList
Returns a new instance of BibSonomyPostList.
27 28 29 30 |
# File 'lib/bibsonomy-jekyll.rb', line 27 def initialize(tag_name, text, tokens) super @input = text end |
Instance Method Details
#override_config(config, parts) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/bibsonomy-jekyll.rb', line 75 def override_config(config, parts) # parameters starting with : can override configuration options # only at the beginning → the first string without : stops loop while parts[0].start_with?(':') config[parts.shift[1..]] = parts.shift end end |
#render(context) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bibsonomy-jekyll.rb', line 32 def render(context) # expand liquid variables rendered_input = Liquid::Template.parse(@input).render(context) bib_config = context.registers[:site].config['bibsonomy'].clone #bib_config = site.config['bibsonomy'] # parse parameters parts = rendered_input.split(/\s+/) # parameters starting with : can override configuration options override_config(bib_config, parts) grouping = parts.shift name = parts.shift # the last element is the number of posts count = Integer(parts.pop) # everything else are the tags = parts # extract config site = context.registers[:site] # user name and API key for 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'] csl.year_headings = bib_config['year_headings'].to_s.downcase == "true" html = csl.render(grouping, name, , count) # set date to now context.registers[:page]["date"] = Time.new return html end |