diff --git a/layouts/blogpost.erb b/layouts/blogpost.erb index 0c4253c..fedb926 100644 --- a/layouts/blogpost.erb +++ b/layouts/blogpost.erb @@ -9,7 +9,7 @@ - + @@ -31,7 +31,8 @@ <% end %>
- Geschreven op <%= item[:created_at] %>
+ Geschreven op <%= gitctime %>
+ Laatst aangepast op <%= gitmtime %>
Leestijd: <%= reading_time @item %>
diff --git a/lib/helpers/blog.rb b/lib/helpers/blog.rb index 96db131..55b932b 100644 --- a/lib/helpers/blog.rb +++ b/lib/helpers/blog.rb @@ -25,4 +25,20 @@ module BlogHelper HTML end + + def gitctime + # find file last modification time + filepath=@item[:content_filename] + str=`git log --format=%cd --date=short -- #{filepath} | tail -1` + return Date.parse(str) + end + + def gitmtime + # find file last modification time + filepath=@item[:content_filename] + str=`git log -1 --format=%cd --date=short -- #{filepath}` + return Date.parse(str) + end + + end diff --git a/lib/helpers/preprocess.rb b/lib/helpers/preprocess.rb index 6c787de..dd3f3bb 100644 --- a/lib/helpers/preprocess.rb +++ b/lib/helpers/preprocess.rb @@ -52,12 +52,10 @@ module PreprocessHelper def update_blog_attributes @items.find_all('/blog/**/*.md').each do |i| - raise "#{i.identifier} doesn't have 'created_at'" unless i[:created_at] i.update_attributes( # Tag all posts with article (for Blogging helper) kind: 'article', - academic_year: i.identifier.to_s[/\d-\d/], - created_at: Date.parse(i[:created_at]) + academic_year: i.identifier.to_s[/\d\d-\d\d/], ) end end