oreolek
/
news-script
Archived
1
0
Fork 0

take 50 first words as short description (Itch)

This commit is contained in:
Alexander Yakovlev 2019-04-19 14:41:38 +07:00
parent 5904318c2b
commit b6199572e7
Signed by: oreolek
GPG Key ID: 1CDC4B7820C93BD3
1 changed files with 8 additions and 3 deletions

View File

@ -102,7 +102,7 @@ class Itch extends Source {
}
});
$date = $this->dom->filter('td abbr');
if ($date) {
if ($date->count() > 0) {
$date = $date->first()->attr('title');
$date = str_replace('@', '', $date);
$game->date = new \DateTime($date);
@ -112,8 +112,13 @@ class Itch extends Source {
$game->description = trim($desc->first()->html());
} catch (\Throwable $e) {
}
// $converter = new Pandoc();
// $game->description = $converter->convert($game->description, 'html', 'mediawiki');
if (empty($game->short_description)) {
$converter = new Pandoc();
$description = $converter->convert($game->description, 'html', 'mediawiki');
$description = explode(' ',$description);
// 50 first words
$game->short_description = implode(' ', array_slice($description, 0, 50));
}
return $game;
}
}