X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;ds=sidebyside;f=modules%2Freadingtime;fp=modules%2Freadingtime;h=79833145d950ac83394656523efcb1a6254a479c;hb=1f9da3846f8e78cac52ea5a4c3840dfc391dca53;hp=0000000000000000000000000000000000000000;hpb=394bc43d24de087865fa4eed1920411c1a6d7ebd;p=pinopress.git diff --git a/modules/readingtime b/modules/readingtime new file mode 100755 index 0000000..7983314 --- /dev/null +++ b/modules/readingtime @@ -0,0 +1,14 @@ +#!/bin/sh + +## module for getting estimated time to read an article +## usage: +## readingtime [file] +## exports: +## READING_TIME in minutes + +## config vars +wordsPerMinute=250 + +# first clean special symbols and lines with whitespace +wordcount=`sed -e 's/[^A-Za-z0-9 ]//g' -e '/^\s*$/d' "$1" | wc -w` +export READING_TIME=$(expr $(expr $wordcount + $wordsPerMinute) / $wordsPerMinute)