Merge pull request #409 from ZeusWPI/gitmetadata
added helper function to get modification time from git
This commit is contained in:
commit
a3e0a5de85
3 changed files with 20 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
<meta name="twitter:label1" value="Author" />
|
||||
<meta name="twitter:data1" value="<%= @item[:author] %>" />
|
||||
<meta name="twitter:label2" value="Created at" />
|
||||
<meta name="twitter:data2" value="<%= @item[:created_at] %>" />
|
||||
<meta name="twitter:data2" value="<%= gitmtime %>" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
|
||||
<!-- Animate.css -->
|
||||
|
@ -31,7 +31,8 @@
|
|||
<% end %>
|
||||
<div class="details animated fadeInRight">
|
||||
<small>
|
||||
Geschreven op <%= item[:created_at] %><br>
|
||||
Geschreven op <%= gitctime %><br>
|
||||
Laatst aangepast op <%= gitmtime %><br>
|
||||
Leestijd: <%= reading_time @item %>
|
||||
</small>
|
||||
</div>
|
||||
|
|
|
@ -25,4 +25,20 @@ module BlogHelper
|
|||
</figure>
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue