diff --git a/History.txt b/History.txt index 4fabb794..6b40da42 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == * Major Features * Code highlighting with Pygments if --pygments is specified + * Disable true LSI by default, enable with --lsi * Minor Enhancements * Output informative message if RDiscount is not available [github.com/JackDanger] * Bug Fixes diff --git a/bin/jekyll b/bin/jekyll index 3bd7c6ee..6a641f6b 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -25,6 +25,10 @@ opts = OptionParser.new do |opts| options[:auto] = true end + opts.on("--lsi", "Use LSI for better related posts") do + Jekyll.lsi = true + end + opts.on("--pygments", "Use pygments to highlight code") do Jekyll.pygments = true end diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 4712862d..efa6b8cc 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -34,9 +34,10 @@ module Jekyll VERSION = '0.1.4' class << self - attr_accessor :pygments + attr_accessor :lsi, :pygments end + Jekyll.lsi = false Jekyll.pygments = false def self.process(source, dest) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index c227e318..ca2402a8 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -97,16 +97,21 @@ module Jekyll # Returns [] def related_posts(posts) return [] unless posts.size > 1 - self.class.lsi ||= begin - puts "Running the classifier... this could take a while." - lsi = Classifier::LSI.new - posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) } - puts "" - lsi - end + + if Jekyll.lsi + self.class.lsi ||= begin + puts "Running the classifier... this could take a while." + lsi = Classifier::LSI.new + posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) } + puts "" + lsi + end - related = self.class.lsi.find_related(self.content, 11) - related - [self] + related = self.class.lsi.find_related(self.content, 11) + related - [self] + else + (posts - [self])[0..9] + end end # Add any necessary layouts to this post