Parent

Files

Jekyll::RelatedPosts

Attributes

lsi[RW]
post[R]
site[R]

Public Class Methods

new(post) click to toggle source
# File lib/jekyll/related_posts.rb, line 10
def initialize(post)
  @post = post
  @site = post.site
  require 'classifier' if site.lsi
end

Public Instance Methods

build() click to toggle source
# File lib/jekyll/related_posts.rb, line 16
def build
  return [] unless self.site.posts.size > 1

  if self.site.lsi
    build_index
    lsi_related_posts
  else
    most_recent_posts
  end
end
build_index() click to toggle source
# File lib/jekyll/related_posts.rb, line 28
def build_index
  self.class.lsi ||= begin
    lsi = Classifier::LSI.new(:auto_rebuild => false)
    display("Populating LSI...")

    self.site.posts.each do |x|
      lsi.add_item(x)
    end

    display("Rebuilding index...")
    lsi.build_index
    display("")
    lsi
  end
end
display(output) click to toggle source
# File lib/jekyll/related_posts.rb, line 52
def display(output)
  $stdout.print("\n")
  $stdout.print(Jekyll.logger.formatted_topic(output))
  $stdout.flush
end
most_recent_posts() click to toggle source
# File lib/jekyll/related_posts.rb, line 48
def most_recent_posts
  (self.site.posts - [self.post])[0..9]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.