2016-11-06 17:45:30 +01:00
|
|
|
require 'words_counted'
|
|
|
|
|
|
|
|
module BlogHelper
|
|
|
|
def reading_time(blogpost)
|
|
|
|
human_wpm = 200.0
|
2017-02-09 02:31:56 +01:00
|
|
|
words = WordsCounted.count(blogpost.compiled_content(rep: :text)).token_count
|
2016-11-06 17:45:30 +01:00
|
|
|
|
|
|
|
minutes = (words / human_wpm).ceil
|
|
|
|
|
|
|
|
if minutes == 1
|
|
|
|
"#{minutes} minuut"
|
|
|
|
else
|
|
|
|
"#{minutes} minuten"
|
|
|
|
end
|
|
|
|
end
|
2018-04-09 23:28:35 +02:00
|
|
|
|
2018-04-09 23:43:23 +02:00
|
|
|
def figure(img_url, caption, alt = nil, img_class: nil)
|
2018-04-09 23:28:35 +02:00
|
|
|
alt ||= caption
|
|
|
|
<<~HTML
|
2018-04-10 11:56:30 +02:00
|
|
|
<figure class="image #{img_class}">
|
2018-04-10 11:36:45 +02:00
|
|
|
<a href="#{img_url}">
|
|
|
|
<img src="#{img_url}" alt="#{alt}">
|
|
|
|
</a>
|
|
|
|
<figcaption>#{caption}</figcaption>
|
2018-04-09 23:28:35 +02:00
|
|
|
</figure>
|
|
|
|
HTML
|
|
|
|
end
|
2020-10-12 21:22:10 +02:00
|
|
|
|
2020-10-13 00:37:54 +02:00
|
|
|
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
|
|
|
|
|
2020-10-12 21:22:10 +02:00
|
|
|
def gitmtime
|
2020-10-12 23:47:58 +02:00
|
|
|
# find file last modification time
|
2020-10-12 21:22:10 +02:00
|
|
|
filepath=@item[:content_filename]
|
2020-10-12 23:47:58 +02:00
|
|
|
str=`git log -1 --format=%cd --date=short -- #{filepath}`
|
2020-10-13 00:19:42 +02:00
|
|
|
return Date.parse(str)
|
|
|
|
end
|
2020-10-13 00:37:54 +02:00
|
|
|
|
|
|
|
|
2016-11-06 17:45:30 +01:00
|
|
|
end
|