Permalink
Browse files

Added plugin to set the post date to when it was committed to git... …

…better than file name management
  • Loading branch information...
1 parent 50d2834 commit bc513dd214295698cc1b0b42b887cfc2c7964787 @krobertson krobertson committed Mar 30, 2012
Showing with 30 additions and 0 deletions.
  1. +1 −0 Gemfile
  2. +5 −0 Gemfile.lock
  3. +24 −0 _plugins/post_date_file_modified.rb
View
@@ -4,6 +4,7 @@ gem 'rack-contrib', :require => 'rack/contrib/try_static'
gem 'thin'
group :development do
+ gem 'grit'
gem 'jekyll'
gem 'RedCloth'
gem 'maruku'
View
@@ -8,9 +8,13 @@ GEM
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
daemons (1.1.5)
+ diff-lcs (1.1.3)
directory_watcher (1.4.1)
eventmachine (0.12.10)
fast-stemmer (1.0.0)
+ grit (2.4.1)
+ diff-lcs (~> 1.1)
+ mime-types (~> 1.15)
haml (3.1.4)
interact (0.4.1)
jekyll (0.11.2)
@@ -54,6 +58,7 @@ PLATFORMS
DEPENDENCIES
RedCloth
+ grit
haml
jekyll
maruku
@@ -0,0 +1,24 @@
+module Jekyll
+ class Post
+ def full_path_to_source
+ File.join(@base, @name)
+ end
+ end
+end
+
+module Jekyll
+ class PostDateFileModified < Generator
+
+ safe true
+ priority :high
+
+ def generate(site)
+ require 'grit'
+ repo = Grit::Repo.new(File.join(__FILE__, '..', '..'))
+ site.posts.each do |post|
+ post.date = repo.log('master', post.full_path_to_source, :max_count => 1).first.authored_date
+ end
+ end
+
+ end
+end

0 comments on commit bc513dd

Please sign in to comment.