diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 56910bc..78747e3 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -69,6 +69,10 @@ class Poche $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); $this->tpl->addFilter($filter); + # filter for reading time + $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); + $this->tpl->addFilter($filter); + # Pagination $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); } diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 4a72bae..0eb0d9e 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -224,4 +224,13 @@ class Tools return FALSE; } + + public static function getReadingTime($text) { + $word = str_word_count(strip_tags($text)); + $minutes = floor($word / 200); + $seconds = floor($word % 200 / (200 / 60)); + $time = array('minutes' => $minutes, 'seconds' => $seconds); + + return $minutes; + } } \ No newline at end of file diff --git a/tpl/css/style.css b/tpl/css/style.css index d23c189..de82a82 100644 --- a/tpl/css/style.css +++ b/tpl/css/style.css @@ -241,4 +241,8 @@ a, a:hover, a:visited { footer { clear: both; +} + +.reading-time { + font-size: 13px; } \ No newline at end of file diff --git a/tpl/home.twig b/tpl/home.twig index a6da641..03f9f70 100644 --- a/tpl/home.twig +++ b/tpl/home.twig @@ -19,6 +19,7 @@
{{ entry.content|striptags|slice(0, 300) }}...