From 4292cb42a7dbf03d44ddf217995cc0e9d5297b70 Mon Sep 17 00:00:00 2001 From: Jens Timmerman Date: Tue, 13 Oct 2020 00:19:42 +0200 Subject: [PATCH] no more errors when a blog has no created_at line, parse str as date instead of datetime --- lib/helpers/blog.rb | 8 ++------ lib/helpers/preprocess.rb | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/helpers/blog.rb b/lib/helpers/blog.rb index b122e9d..4b8be72 100644 --- a/lib/helpers/blog.rb +++ b/lib/helpers/blog.rb @@ -30,10 +30,6 @@ module BlogHelper # find file last modification time filepath=@item[:content_filename] str=`git log -1 --format=%cd --date=short -- #{filepath}` - if str == "" - return @item[:created_at] - else - return str - end -end + return Date.parse(str) + end end diff --git a/lib/helpers/preprocess.rb b/lib/helpers/preprocess.rb index 07ff4a9..9ecb2bc 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-\d\d/], - created_at: Date.parse(i[:created_at]) ) end end