aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/poche/Poche.class.php4
-rw-r--r--inc/poche/Tools.class.php9
-rw-r--r--tpl/css/style.css4
-rw-r--r--tpl/home.twig1
4 files changed, 18 insertions, 0 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 56910bc0..78747e32 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -69,6 +69,10 @@ class Poche
69 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); 69 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
70 $this->tpl->addFilter($filter); 70 $this->tpl->addFilter($filter);
71 71
72 # filter for reading time
73 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
74 $this->tpl->addFilter($filter);
75
72 # Pagination 76 # Pagination
73 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); 77 $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
74 } 78 }
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 4a72bae3..0eb0d9ea 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -224,4 +224,13 @@ class Tools
224 224
225 return FALSE; 225 return FALSE;
226 } 226 }
227
228 public static function getReadingTime($text) {
229 $word = str_word_count(strip_tags($text));
230 $minutes = floor($word / 200);
231 $seconds = floor($word % 200 / (200 / 60));
232 $time = array('minutes' => $minutes, 'seconds' => $seconds);
233
234 return $minutes;
235 }
227} \ No newline at end of file 236} \ No newline at end of file
diff --git a/tpl/css/style.css b/tpl/css/style.css
index d23c1896..de82a822 100644
--- a/tpl/css/style.css
+++ b/tpl/css/style.css
@@ -241,4 +241,8 @@ a, a:hover, a:visited {
241 241
242footer { 242footer {
243 clear: both; 243 clear: both;
244}
245
246.reading-time {
247 font-size: 13px;
244} \ No newline at end of file 248} \ No newline at end of file
diff --git a/tpl/home.twig b/tpl/home.twig
index a6da641f..03f9f70d 100644
--- a/tpl/home.twig
+++ b/tpl/home.twig
@@ -19,6 +19,7 @@
19 <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li> 19 <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
20 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li> 20 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
21 <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li> 21 <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>
22 <li class="reading-time">{{ entry.content| getReadingTime }} min</li>
22 </li> 23 </li>
23 </ul> 24 </ul>
24 <p>{{ entry.content|striptags|slice(0, 300) }}...</p> 25 <p>{{ entry.content|striptags|slice(0, 300) }}...</p>