Reading time improves
This commit is contained in:
parent
8807414d1b
commit
ea7f24b53a
|
@ -65,8 +65,7 @@ function table($status, $icon='arrow-circle-o-down') {
|
||||||
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
|
|
||||||
foreach ($page->children() as $childKey) {
|
foreach ($page->children() as $child) {
|
||||||
$child = buildPage($childKey);
|
|
||||||
if ($child->published()) {
|
if ($child->published()) {
|
||||||
echo '<tr>
|
echo '<tr>
|
||||||
<td class="child-title">
|
<td class="child-title">
|
||||||
|
|
|
@ -487,13 +487,19 @@ class Page {
|
||||||
|
|
||||||
// Returns the amount of minutes takes to read the page
|
// Returns the amount of minutes takes to read the page
|
||||||
public function readingTime() {
|
public function readingTime() {
|
||||||
|
global $Language;
|
||||||
|
|
||||||
$words = $this->content(true);
|
$words = $this->content(true);
|
||||||
$words = strip_tags($words);
|
$words = strip_tags($words);
|
||||||
$words = str_word_count($words);
|
$words = str_word_count($words);
|
||||||
$average = $words / 200;
|
$average = $words / 200;
|
||||||
$minutes = round($average);
|
$minutes = round($average);
|
||||||
|
|
||||||
return $minutes;
|
if ($minutes>0) {
|
||||||
|
return $minutes.' '.$Language->get('minutes');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '~1 '.$Language->get('minute');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns relative time (e.g. "1 minute ago")
|
// Returns relative time (e.g. "1 minute ago")
|
||||||
|
|
|
@ -280,5 +280,8 @@
|
||||||
"plugins-position": "Plugin position",
|
"plugins-position": "Plugin position",
|
||||||
"plugins-position-changed": "Plugin position changed",
|
"plugins-position-changed": "Plugin position changed",
|
||||||
"drag-and-drop-to-set-the-position-of-the-plugin": "Drag and Drop to set the position of the plugins",
|
"drag-and-drop-to-set-the-position-of-the-plugin": "Drag and Drop to set the position of the plugins",
|
||||||
"change-the-position-of-the-plugins": "Change the position of the plugins"
|
"change-the-position-of-the-plugins": "Change the position of the plugins",
|
||||||
|
"reading-time": "Reading time",
|
||||||
|
"minutes": "minutes",
|
||||||
|
"minute": "minute"
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- Creation date -->
|
<!-- Creation date -->
|
||||||
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?></h6>
|
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() . $Language->get('minutes') ?></h6>
|
||||||
|
|
||||||
<!-- Breaked content -->
|
<!-- Breaked content -->
|
||||||
<?php echo $page->contentBreak(); ?>
|
<?php echo $page->contentBreak(); ?>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<?php if (!$page->static()): ?>
|
<?php if (!$page->static()): ?>
|
||||||
<!-- Creation date -->
|
<!-- Creation date -->
|
||||||
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?></h6>
|
<h6 class="card-subtitle mb-2 text-muted"><?php echo $page->date(); ?> - <?php echo $Language->get('Reading time') . ': ' . $page->readingTime() ?></h6>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<!-- Full content -->
|
<!-- Full content -->
|
||||||
|
|
Loading…
Reference in New Issue