reading time
[pinopress.git] / modules / readingtime
1 #!/bin/sh
2
3 ## module for getting estimated time to read an article
4 ## usage:
5 ##    readingtime [file]
6 ## exports:
7 ##    READING_TIME in minutes
8
9 ## config vars
10 wordsPerMinute=250
11
12 # first clean special symbols and lines with whitespace
13 wordcount=`sed -e 's/[^A-Za-z0-9 ]//g' -e '/^\s*$/d' "$1" | wc -w`
14 export READING_TIME=$(expr $(expr $wordcount + $wordsPerMinute) / $wordsPerMinute)