From 5a633d5e32b38fa042858498da46bde025a65333 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Tue, 23 Feb 2016 19:04:34 +0100 Subject: [PATCH] Add indicator about average length of read (at 200 wpm) --- source/layouts/post.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/layouts/post.haml b/source/layouts/post.haml index 423b1d3..918b2ed 100644 --- a/source/layouts/post.haml +++ b/source/layouts/post.haml @@ -17,6 +17,10 @@ = current_article.date.strftime(blog_settings.date_format) - if tags? about #{tags} + | + - words = Nokogiri::HTML::DocumentFragment.parse(yield).search('.//text()').map(&:text).join(' ').split.count + = [1, (words / 200.0).round].max # average reading speed as of http://EzineArticles.com/2298503 + min read %section.post-content= yield