summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2014-03-05 14:21:59 +0100
committerrautenberg <rautenberg@in-silico.ch>2014-03-05 14:21:59 +0100
commiteaf2e770e425e4965389fa10b9a1e00f4655d1be (patch)
tree3575dd04c0cdeff207cb63eb8250609c0c0fd76d
parent28318382bb00b49e6a9af0980ecbb987c930c3a8 (diff)
set markdown:rdiscount for maruku, update _plugins/related_posts.rb
-rw-r--r--_config.yml2
-rw-r--r--_plugins/related_posts.rb54
-rw-r--r--_posts/2014-02-26-foo.md8
3 files changed, 26 insertions, 38 deletions
diff --git a/_config.yml b/_config.yml
index 553e6b7..165fdb3 100644
--- a/_config.yml
+++ b/_config.yml
@@ -28,6 +28,8 @@ author :
#
production_url : http://opentox.github.com
+markdown: rdiscount
+
# All Jekyll-Bootstrap specific configurations are namespaced into this hash
#
JB :
diff --git a/_plugins/related_posts.rb b/_plugins/related_posts.rb
index 7e07c66..449cb73 100644
--- a/_plugins/related_posts.rb
+++ b/_plugins/related_posts.rb
@@ -1,42 +1,40 @@
require 'jekyll/post'
-module RelatedPosts
-
- # Used to remove #related_posts so that it can be overridden
- def self.included(klass)
- klass.class_eval do
- remove_method :related_posts
+module Jekyll
+ module RelatedPostsByCategory
+ # Used to remove #related_posts so that it can be overridden
+ def self.included(klass)
+ klass.class_eval do
+ remove_method :related_posts
+ end
end
- end
- # Calculate related posts.
- #
- # Returns [<Post>]
- def related_posts(posts)
- return [] unless posts.size > 1
- highest_freq = Jekyll::Post.tag_freq(posts).values.max
- related_scores = Hash.new(0)
- posts.each do |post|
- post.tags.each do |tag|
- if self.tags.include?(tag) && post != self
- cat_freq = Jekyll::Post.tag_freq(posts)[tag]
- related_scores[post] += (1+highest_freq-cat_freq)
+ # Calculate related posts.
+ # Returns [<Post>]
+ def related_posts(posts)
+ return [] unless posts.size > 1
+ highest_freq = tag_freq(posts).values.max
+ related_scores = Hash.new(0)
+
+ posts.each do |post|
+ post.categories.each do |tag|
+ if self.categories.include?(tag) && post != self
+ cat_freq = tag_freq(posts)[tag]
+ related_scores[post] += (1+highest_freq-cat_freq)
+ end
end
end
- end
- Jekyll::Post.sort_related_posts(related_scores)
- end
+ sort_related_posts(related_scores)
+ end
- module ClassMethods
# Calculate the frequency of each tag.
- #
# Returns {tag => freq, tag => freq, ...}
def tag_freq(posts)
return @tag_freq if @tag_freq
@tag_freq = Hash.new(0)
posts.each do |post|
- post.tags.each {|tag| @tag_freq[tag] += 1}
+ post.categories.each {|tag| @tag_freq[tag] += 1}
end
@tag_freq
end
@@ -56,11 +54,7 @@ module RelatedPosts
end
end
-end
-
-module Jekyll
class Post
- include RelatedPosts
- extend RelatedPosts::ClassMethods
+ include RelatedPostsByCategory
end
end
diff --git a/_posts/2014-02-26-foo.md b/_posts/2014-02-26-foo.md
deleted file mode 100644
index f26b6d4..0000000
--- a/_posts/2014-02-26-foo.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-layout: post
-title: "foo"
-description: ""
-category:
-tags: []
----
-{% include JB/setup %}