disable true LSI by default, enable with --lsi

This commit is contained in:
Tom Preston-Werner 2008-12-12 21:03:16 -08:00
parent 2a8345df82
commit b1bf818c6d
4 changed files with 21 additions and 10 deletions

View File

@ -1,6 +1,7 @@
== ==
* Major Features * Major Features
* Code highlighting with Pygments if --pygments is specified * Code highlighting with Pygments if --pygments is specified
* Disable true LSI by default, enable with --lsi
* Minor Enhancements * Minor Enhancements
* Output informative message if RDiscount is not available [github.com/JackDanger] * Output informative message if RDiscount is not available [github.com/JackDanger]
* Bug Fixes * Bug Fixes

View File

@ -25,6 +25,10 @@ opts = OptionParser.new do |opts|
options[:auto] = true options[:auto] = true
end end
opts.on("--lsi", "Use LSI for better related posts") do
Jekyll.lsi = true
end
opts.on("--pygments", "Use pygments to highlight code") do opts.on("--pygments", "Use pygments to highlight code") do
Jekyll.pygments = true Jekyll.pygments = true
end end

View File

@ -34,9 +34,10 @@ module Jekyll
VERSION = '0.1.4' VERSION = '0.1.4'
class << self class << self
attr_accessor :pygments attr_accessor :lsi, :pygments
end end
Jekyll.lsi = false
Jekyll.pygments = false Jekyll.pygments = false
def self.process(source, dest) def self.process(source, dest)

View File

@ -97,6 +97,8 @@ module Jekyll
# Returns [<Post>] # Returns [<Post>]
def related_posts(posts) def related_posts(posts)
return [] unless posts.size > 1 return [] unless posts.size > 1
if Jekyll.lsi
self.class.lsi ||= begin self.class.lsi ||= begin
puts "Running the classifier... this could take a while." puts "Running the classifier... this could take a while."
lsi = Classifier::LSI.new lsi = Classifier::LSI.new
@ -107,6 +109,9 @@ module Jekyll
related = self.class.lsi.find_related(self.content, 11) related = self.class.lsi.find_related(self.content, 11)
related - [self] related - [self]
else
(posts - [self])[0..9]
end
end end
# Add any necessary layouts to this post # Add any necessary layouts to this post