Skip to content

Commit

Permalink
disable true LSI by default, enable with --lsi
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Dec 13, 2008
1 parent 2a8345d commit b1bf818
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions 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
Expand Down
4 changes: 4 additions & 0 deletions bin/jekyll
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/jekyll.rb
Expand Up @@ -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)
Expand Down
23 changes: 14 additions & 9 deletions lib/jekyll/post.rb
Expand Up @@ -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
Expand Down

0 comments on commit b1bf818

Please sign in to comment.