Permalink
Browse files

Remove duplication when aggregating post information

  • Loading branch information...
1 parent 2dd9881 commit 6399ec9b2b07b4f8dbaf3dc72cac200a0185b2a8 @mattr- mattr- committed Mar 6, 2013
Showing with 13 additions and 6 deletions.
  1. +13 −6 lib/jekyll/site.rb
View
@@ -195,9 +195,7 @@ def read_posts(dir)
post = Post.new(self, self.source, dir, f)
if post.published && (self.future || post.date <= self.time)
- self.posts << post
- post.categories.each { |c| self.categories[c] << post }
- post.tags.each { |c| self.tags[c] << post }
+ aggregate_post_info(post)
end
end
end
@@ -217,9 +215,7 @@ def read_drafts(dir)
if Draft.valid?(f)
draft = Draft.new(self, self.source, dir, f)
- self.posts << draft
- draft.categories.each { |c| self.categories[c] << draft }
- draft.tags.each { |c| self.tags[c] << draft }
+ aggregate_post_info(draft)
end
end
end
@@ -403,5 +399,16 @@ def get_entries(dir, subfolder)
return [] unless File.exists?(base)
entries = Dir.chdir(base) { filter_entries(Dir['**/*']) }
end
+
+ # Aggregate post information
+ #
+ # post - The Post object to aggregate information for
+ #
+ # Returns nothing
+ def aggregate_post_info(post)
+ self.posts << post
+ post.categories.each { |c| self.categories[c] << post }
+ post.tags.each { |c| self.tags[c] << post }
+ end
end
end

0 comments on commit 6399ec9

Please sign in to comment.