Skip to content

Commit

Permalink
Fixed RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Kyryliuk committed Dec 2, 2022
1 parent f39ac81 commit e69a9bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/functions/rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function fetchCacheableRss($url, $xpath = null, Closure $callback = null)
if (!$content) {
return $items;
}

$content = str_replace('xmlns=', 'ns=', $content);
$xml = new SimpleXmlElement($content);

if ($xpath) {
Expand Down
15 changes: 8 additions & 7 deletions manager/views/page/2.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@
// create Feed
foreach ($urls as $section => $url) {
$output = '';
$items = fetchCacheableRss($url, 'channel/item', function(SimpleXMLElement $entry){
$items = fetchCacheableRss($url, '//entry', function(SimpleXMLElement $entry){
$props = [];
foreach ($entry as $prop) {
if (mb_strtolower($prop->getName()) === 'pubdate' && ($time = @strtotime($prop->__toString())) > 0) {
$props['date_timestamp'] = $time;
$props['pubdate'] = $prop->__toString();
if (mb_strtolower($prop->getName()) === 'updated' && ($time = @strtotime($prop->__toString())) > 0) {
$props['updated'] = $prop->__toString();
} elseif (mb_strtolower($prop->getName()) === 'link') {
$props['link'] = $prop->attributes()['href']->__toString();
} else {
$props[$prop->getName()] = $prop->__toString();
}
Expand All @@ -222,11 +223,11 @@
$items = array_slice($items, 0, $itemsNumber);
foreach ($items as $item) {
$href = rel2abs($item['link'], 'https://github.com');
$href = $item['link'];
$title = $item['title'];
$pubdate = $item['pubdate'];
$pubdate = $item['updated'];
$pubdate = EvolutionCMS()->toDateFormat(strtotime($pubdate));
$description = strip_tags($item['description']);
$description = strip_tags($item['content']);
if (strlen($description) > 199) {
$description = substr($description, 0, 200);
$description .= '...<br />Read <a href="' . $href . '" target="_blank">more</a>.';
Expand Down

0 comments on commit e69a9bd

Please sign in to comment.