no more errors when a blog has no created_at line, parse str as date instead of datetime

This commit is contained in:
Jens Timmerman 2020-10-13 00:19:42 +02:00
parent 804c0b1038
commit 4292cb42a7
2 changed files with 2 additions and 8 deletions

View file

@ -30,10 +30,6 @@ module BlogHelper
# find file last modification time # find file last modification time
filepath=@item[:content_filename] filepath=@item[:content_filename]
str=`git log -1 --format=%cd --date=short -- #{filepath}` str=`git log -1 --format=%cd --date=short -- #{filepath}`
if str == "" return Date.parse(str)
return @item[:created_at]
else
return str
end
end end
end end

View file

@ -52,12 +52,10 @@ module PreprocessHelper
def update_blog_attributes def update_blog_attributes
@items.find_all('/blog/**/*.md').each do |i| @items.find_all('/blog/**/*.md').each do |i|
raise "#{i.identifier} doesn't have 'created_at'" unless i[:created_at]
i.update_attributes( i.update_attributes(
# Tag all posts with article (for Blogging helper) # Tag all posts with article (for Blogging helper)
kind: 'article', kind: 'article',
academic_year: i.identifier.to_s[/\d\d-\d\d/], academic_year: i.identifier.to_s[/\d\d-\d\d/],
created_at: Date.parse(i[:created_at])
) )
end end
end end