Skip to content

Commit

Permalink
implement a real related posts feature. up to 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Nov 22, 2008
1 parent 4d42e0d commit c742fb7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion History.txt
@@ -1,4 +1,6 @@
== 0.1.2 /
== 0.1.2 / 2008-11-22
* Major Features
* Add a real "related posts" implementation using Classifier
* Command Line Changes
* Allow cli to be called with 0, 1, or 2 args intuiting dir paths
if they are omitted
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -6,7 +6,7 @@ Hoe.new('jekyll', Jekyll::VERSION) do |p|
# p.rubyforge_name = 'jekyllx' # if different than lowercase project name
p.developer('Tom Preston-Werner', 'tom@mojombo.com')
p.summary = "Jekyll is a simple, blog aware, static site generator."
p.extra_deps = ['RedCloth', 'liquid']
p.extra_deps = ['RedCloth', 'liquid', 'classifier']
end

desc "Open an irb session preloaded with this library"
Expand Down
1 change: 1 addition & 0 deletions bin/jekyll
Expand Up @@ -7,6 +7,7 @@ require 'jekyll'
case ARGV.size
when 0
dest = File.join('.', '_site')
FileUtils.rm_rf(dest)
FileUtils.mkdir_p(dest)
Jekyll.process('.', dest)
when 1
Expand Down
5 changes: 4 additions & 1 deletion jekyll.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = %q{jekyll}
s.version = "0.1.1"
s.version = "0.1.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tom Preston-Werner"]
Expand All @@ -25,15 +25,18 @@ Gem::Specification.new do |s|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<RedCloth>, [">= 0"])
s.add_runtime_dependency(%q<liquid>, [">= 0"])
s.add_runtime_dependency(%q<classifier>, [">= 0"])
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
else
s.add_dependency(%q<RedCloth>, [">= 0"])
s.add_dependency(%q<liquid>, [">= 0"])
s.add_dependency(%q<classifier>, [">= 0"])
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end
else
s.add_dependency(%q<RedCloth>, [">= 0"])
s.add_dependency(%q<liquid>, [">= 0"])
s.add_dependency(%q<classifier>, [">= 0"])
s.add_dependency(%q<hoe>, [">= 1.8.0"])
end
end
3 changes: 2 additions & 1 deletion lib/jekyll.rb
Expand Up @@ -12,6 +12,7 @@
# 3rd party
require 'liquid'
require 'redcloth'
require 'classifier'

# internal requires
require 'jekyll/site'
Expand All @@ -22,7 +23,7 @@
require 'jekyll/filters'

module Jekyll
VERSION = '0.1.1'
VERSION = '0.1.2'

def self.process(source, dest)
Jekyll::Site.new(source, dest).process
Expand Down
5 changes: 5 additions & 0 deletions lib/jekyll/convertible.rb
@@ -1,5 +1,10 @@
module Jekyll
module Convertible
# Return the contents as a string
def to_s
self.content || ''
end

# Read the YAML frontmatter
# +base+ is the String path to the dir containing the file
# +name+ is the String filename of the file
Expand Down
13 changes: 12 additions & 1 deletion lib/jekyll/post.rb
Expand Up @@ -4,6 +4,10 @@ class Post
include Comparable
include Convertible

class << self
attr_accessor :lsi
end

MATCHER = /^(\d+-\d+-\d+)-(.*)(\.[^.]+)$/

# Post name validator. Post filenames must be like:
Expand Down Expand Up @@ -77,7 +81,14 @@ def id
#
# Returns [<Post>]
def related_posts(posts)
related = posts - [self]
self.class.lsi ||= begin
lsi = Classifier::LSI.new
posts.each { |x| lsi.add_item(x) }
lsi
end

related = self.class.lsi.find_related(self.content, 11)
related - [self]
end

# Add any necessary layouts to this post
Expand Down

0 comments on commit c742fb7

Please sign in to comment.