X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FContentProxy.php;h=fd059325458892c33dcaf576593839e42766d5b6;hb=eb2d613c3ed95d741e987917f976da349ea240eb;hp=219b90d309bc022830e8f7ceec0694458bbfbac2;hpb=45fd7e09d75995bd0b9a731ffd70054b7ae6ee1f;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 219b90d3..fd059325 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -8,6 +8,7 @@ use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Tools\Utils; use Wallabag\CoreBundle\Repository\TagRepository; +use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; /** * This kind of proxy class take care of getting the content from an url @@ -19,6 +20,7 @@ class ContentProxy protected $tagger; protected $logger; protected $tagRepository; + protected $mimeGuesser; public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $logger) { @@ -26,6 +28,7 @@ class ContentProxy $this->tagger = $tagger; $this->logger = $logger; $this->tagRepository = $tagRepository; + $this->mimeGuesser = new MimeTypeExtensionGuesser(); } /** @@ -65,6 +68,8 @@ class ContentProxy $entry->setUrl($content['url'] ?: $url); $entry->setTitle($title); + $entry->setContent($html); + $entry->setHttpStatus(isset($content['status']) ? $content['status'] : ''); $entry->setLanguage($content['language']); $entry->setMimetype($content['content_type']); @@ -75,18 +80,15 @@ class ContentProxy $entry->setDomainName($domainName); } - if (true) { - $this->logger->log('debug', 'Starting to download images'); - $downloadImages = new DownloadImages($html, $url, $this->logger); - $html = $downloadImages->process(); - } - - $entry->setContent($html); - if (isset($content['open_graph']['og_image'])) { $entry->setPreviewPicture($content['open_graph']['og_image']); } + // if content is an image define as a preview too + if (in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) { + $entry->setPreviewPicture($content['url']); + } + try { $this->tagger->tag($entry); } catch (\Exception $e) {