Skip to content
Permalink
Browse files

Add 20 seconds to reading time per media element

  • Loading branch information
da2x committed Apr 3, 2015
1 parent 4c4a007 commit b73d32f642a4b2c988576611626c4f70969db96e
Showing with 7 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +6 −1 nikola/post.py
@@ -22,6 +22,7 @@ Bugfixes
* Fix symlinks for moment.js in Windows
* Fix code.css bundling in Windows
* Listings in posts now work in Windows (Issue #1631)
* Add 20 seconds to reading time per embedded media

New in v7.3.1
=============
@@ -600,7 +600,12 @@ def reading_time(self):
text = self.text(strip_html=True)
words_per_minute = 220
words = len(text.split())
self._reading_time = int(ceil(words / words_per_minute)) or 1
markup = lxml.html.fromstring(self.text(strip_html=False))
embeddables = [".//img", ".//picture", ".//video", ".//audio", ".//object", ".//iframe"]
media_time = 0
for embedded in embeddables:
media_time += (len(markup.findall(embedded)) * 0.33) # +20 seconds
self._reading_time = int(ceil((words / words_per_minute) + media_time)) or 1
return self._reading_time

@property

0 comments on commit b73d32f

Please sign in to comment.