Skip to content
Browse files

disable true LSI by default, enable with --lsi

  • Loading branch information...
1 parent 2a8345d commit b1bf818c6d474aa078766d3a9b988bbbaf03040b @mojombo mojombo committed Dec 12, 2008
Showing with 21 additions and 10 deletions.
  1. +1 −0 History.txt
  2. +4 −0 bin/jekyll
  3. +2 −1 lib/jekyll.rb
  4. +14 −9 lib/jekyll/post.rb
View
1 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
View
4 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
View
3 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)
View
23 lib/jekyll/post.rb
@@ -97,16 +97,21 @@ def id
# Returns [<Post>]
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

0 comments on commit b1bf818

Please sign in to comment.
Something went wrong with that request. Please try again.