Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add 20 seconds to reading time per media element
  • Loading branch information
da2x committed Apr 3, 2015
1 parent 4c4a007 commit b73d32f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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
=============
Expand Down
7 changes: 6 additions & 1 deletion nikola/post.py
Expand Up @@ -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
Expand Down

0 comments on commit b73d32f

Please sign in to comment.