Class: Jekyll::Scholar::BibliographyTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Utilities
Defined in:
lib/jekyll/scholar/tags/bibliography.rb

Instance Attribute Summary

Attributes included from Utilities

#config, #context, #max, #offset, #prefix, #site, #text

Instance Method Summary collapse

Methods included from Utilities

#allow_locale_overrides?, #base_url, #bibliography, #bibliography_list_tag, #bibliography_stale?, #bibliography_tag, #bibliography_template, #bibtex_file, #bibtex_files, #bibtex_filters, #bibtex_options, #bibtex_path, #bibtex_paths, #citation_item_for, #citation_number, #cite, #cite_details, #cited_entries, #cited_keys, #cited_only?, #cited_references, #clear?, #content_tag, #details_link, #details_link_for, #details_path, #entries, #extend_path, #generate_details?, #group, #group?, #group_by, #group_compare, #group_keys, #group_name, #group_order, #group_order=, #group_tags, #group_value, #grouper, #interpolate, #join_strings?, #keys, #labels, #limit_entries?, #link_target_for, #link_to, #liquid_template, #liquidify, #load_repository, #load_style, #locales, #locators, #match_fields, #missing_reference, #month_names, #optparse, #query, #reference_data, #reference_tag, #reference_tagname, #relative, #remove_duplicates?, #render_bibliography, #render_citation, #renderer, #replace_strings?, #repository, #repository?, #repository_file_delimiter, #repository_link_for, #repository_links_for, #repository_path, #scholar_source, #set_context_to, #skip_sort?, #sort, #sort_keys, #sort_order, #split_arguments, #style, #styles, #suppress_author?, #type_aliases, #type_names, #type_order, #update_dependency_tree

Constructor Details

#initialize(tag_name, arguments, tokens) ⇒ BibliographyTag

Returns a new instance of BibliographyTag.



7
8
9
10
11
12
13
# File 'lib/jekyll/scholar/tags/bibliography.rb', line 7

def initialize(tag_name, arguments, tokens)
  super

  @config = Scholar.defaults.dup

  optparse(arguments)
end

Instance Method Details

#group_renderer(groupsOrItems, keys, order, tags) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jekyll/scholar/tags/bibliography.rb', line 35

def group_renderer(groupsOrItems,keys,order,tags)
  if keys.count == 0
    renderer(true)
    render_items(groupsOrItems)
  else
    groupsOrItems
      .sort do |e1,e2|
        if (order.first || group_order.last) =~ /^(desc|reverse)/i
          group_compare(keys.first,e2[0],e1[0])
        else
          group_compare(keys.first,e1[0],e2[0])
        end
      end
      .map do |e|
        bibhead = (tags.first || group_tags.last,
                              group_name(keys.first, e[0]),
                              :class => config['bibliography_class'])
        bibentries = group_renderer(e[1], keys.drop(1), order.drop(1), tags.drop(1))
        bibhead + "\n" + bibentries
      end
      .join("\n")
  end
end

#render(context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jekyll/scholar/tags/bibliography.rb', line 15

def render(context)
  set_context_to context

  # Add bibtex files to dependency tree.
  update_dependency_tree

  items = cited_entries

  if group?
    groups = group(items)
    bibliography = render_groups(groups)
  else
    items = items[offset..max] if limit_entries?
    bibliography = render_items(items)
  end

  bibliography
end

#render_groups(groups) ⇒ Object



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
# File 'lib/jekyll/scholar/tags/bibliography.rb', line 34

def render_groups(groups)
  def group_renderer(groupsOrItems,keys,order,tags)
    if keys.count == 0
      renderer(true)
      render_items(groupsOrItems)
    else
      groupsOrItems
        .sort do |e1,e2|
          if (order.first || group_order.last) =~ /^(desc|reverse)/i
            group_compare(keys.first,e2[0],e1[0])
          else
            group_compare(keys.first,e1[0],e2[0])
          end
        end
        .map do |e|
          bibhead = (tags.first || group_tags.last,
                                group_name(keys.first, e[0]),
                                :class => config['bibliography_class'])
          bibentries = group_renderer(e[1], keys.drop(1), order.drop(1), tags.drop(1))
          bibhead + "\n" + bibentries
        end
        .join("\n")
    end
  end
  group_renderer(groups,group_keys,group_order,group_tags)
end

#render_items(items) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/jekyll/scholar/tags/bibliography.rb', line 61

def render_items(items)
  bibliography = items.compact.each_with_index.map { |entry, index|
    reference = bibliography_tag(entry, index + 1)

    if generate_details?
      reference << link_to(details_link_for(entry),
        config['details_link'], :class => config['details_link_class'])
    end

     config['bibliography_item_tag'], reference, config['bibliography_item_attributes']
  }.join("\n")

   bibliography_list_tag, bibliography,
    { :class => config['bibliography_class'] }.merge(config['bibliography_list_attributes'])

end