зеркало из https://github.com/nextcloud/news.git
prefer web favicon over feed favicon, fix #101
This commit is contained in:
Родитель
95ead2f0da
Коммит
cd2488ee42
|
@ -213,7 +213,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
|
|||
}
|
||||
|
||||
|
||||
private function createFeed($hasFavicon=false, $hasWebFavicon=false) {
|
||||
private function createFeed($hasFeedFavicon=false, $hasWebFavicon=false) {
|
||||
$this->expectCore('get_title', $this->feedTitle);
|
||||
$this->expectCore('get_link', $this->feedLink);
|
||||
|
||||
|
@ -224,14 +224,6 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
|
|||
$feed->setUrlHash(md5($this->url));
|
||||
$feed->setAdded($this->time);
|
||||
|
||||
if($hasFavicon) {
|
||||
$this->expectCore('get_image_url', $this->feedImage);
|
||||
$feed->setFaviconLink($this->feedImage);
|
||||
} else {
|
||||
$feed->setFaviconLink(null);
|
||||
$this->expectCore('get_image_url', null);
|
||||
}
|
||||
|
||||
if($hasWebFavicon) {
|
||||
$this->faviconFetcher->expects($this->once())
|
||||
->method('fetch')
|
||||
|
@ -240,6 +232,15 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility {
|
|||
$feed->setFaviconLink($this->webFavicon);
|
||||
}
|
||||
|
||||
if($hasFeedFavicon) {
|
||||
$this->expectCore('get_image_url', $this->feedImage);
|
||||
$feed->setFaviconLink($this->feedImage);
|
||||
} elseif(!$hasWebFavicon) {
|
||||
$feed->setFaviconLink(null);
|
||||
$this->expectCore('get_image_url', null);
|
||||
}
|
||||
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,16 +159,15 @@ class FeedFetcher implements IFeedFetcher {
|
|||
$feed->setUrlHash(md5($url));
|
||||
$feed->setAdded($this->time->getTime());
|
||||
|
||||
// get the favicon from the feed or the webpage
|
||||
$favicon = $simplePieFeed->get_image_url();
|
||||
// use the favicon from the page first since most feeds use a weird image
|
||||
$favicon = $this->faviconFetcher->fetch($feed->getLink());
|
||||
|
||||
if ($favicon) {
|
||||
$feed->setFaviconLink($favicon);
|
||||
} else {
|
||||
$webFavicon = $this->faviconFetcher->fetch($feed->getLink());
|
||||
$feed->setFaviconLink($webFavicon);
|
||||
if (!$favicon) {
|
||||
$favicon = $simplePieFeed->get_image_url();
|
||||
}
|
||||
|
||||
$feed->setFaviconLink($favicon);
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче