class JekyllWikiLinks::LinkIndex

Constants

Attributes

index[RW]

Public Class Methods

new(site, doc_manager) click to toggle source
# File lib/jekyll-wikilinks/link_index.rb, line 10
def initialize(site, doc_manager)
  @context ||= JekyllWikiLinks::Context.new(site)
  @doc_manager ||= doc_manager
  @index = {}
  @doc_manager.all.each do |doc|
    @index[doc.url] = LinksInfo.new()
  end
end

Public Instance Methods

populate_attributes(doc, typed_link_blocks) click to toggle source
# File lib/jekyll-wikilinks/link_index.rb, line 30
def populate_attributes(doc, typed_link_blocks)
  typed_link_blocks.each do |tl|
    attr_doc = @doc_manager.get_doc_by_fname(tl.filename)
    @index[doc.url].attributes << {
      'type' => tl.link_type, 
      'doc' => attr_doc,
    }
    @index[attr_doc.url].attributed << {
      'type' => tl.link_type,
      'doc' => doc,
    }
  end
end
process() click to toggle source
# File lib/jekyll-wikilinks/link_index.rb, line 19
def process
  self.populate_links()
  # apply index info to each document
  @doc_manager.all.each do |doc|
    doc.data['attributed'] = @index[doc.url].attributed
    doc.data['backlinks'] = @index[doc.url].backlinks
    doc.data['attributes'] = @index[doc.url].attributes
    doc.data['forelinks'] = @index[doc.url].forelinks
  end
end