mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-27 11:22:17 -05:00
fix #113 - reading time
This commit is contained in:
parent
3d8bded89e
commit
d91787589b
@ -69,6 +69,10 @@ class Poche
|
|||||||
$filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
|
$filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
|
||||||
$this->tpl->addFilter($filter);
|
$this->tpl->addFilter($filter);
|
||||||
|
|
||||||
|
# filter for reading time
|
||||||
|
$filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
|
||||||
|
$this->tpl->addFilter($filter);
|
||||||
|
|
||||||
# Pagination
|
# Pagination
|
||||||
$this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
|
$this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
|
||||||
}
|
}
|
||||||
|
@ -224,4 +224,13 @@ class Tools
|
|||||||
|
|
||||||
return FALSE;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -241,4 +241,8 @@ a, a:hover, a:visited {
|
|||||||
|
|
||||||
footer {
|
footer {
|
||||||
clear: both;
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reading-time {
|
||||||
|
font-size: 13px;
|
||||||
}
|
}
|
@ -19,6 +19,7 @@
|
|||||||
<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>
|
<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>
|
||||||
<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>
|
<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>
|
||||||
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>
|
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>
|
||||||
|
<li class="reading-time">{{ entry.content| getReadingTime }} min</li>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>{{ entry.content|striptags|slice(0, 300) }}...</p>
|
<p>{{ entry.content|striptags|slice(0, 300) }}...</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user