From 53679811da855acf9bd944a389a48399ca5d5a15 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 10 Aug 2015 20:20:30 +0200 Subject: serverside full text remove enhancers add full text client side implementation fix bugs and tests for full text feed --- fetcher/feedfetcher.php | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'fetcher/feedfetcher.php') diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php index 2d3cdb0ba..3222a8419 100644 --- a/fetcher/feedfetcher.php +++ b/fetcher/feedfetcher.php @@ -13,23 +13,23 @@ namespace OCA\News\Fetcher; -use \PicoFeed\Parser\MalFormedXmlException; -use \PicoFeed\Reader\Reader; -use \PicoFeed\Reader\SubscriptionNotFoundException; -use \PicoFeed\Reader\UnsupportedFeedFormatException; -use \PicoFeed\Client\InvalidCertificateException; -use \PicoFeed\Client\InvalidUrlException; -use \PicoFeed\Client\MaxRedirectException; -use \PicoFeed\Client\MaxSizeException; -use \PicoFeed\Client\TimeoutException; - -use \OCP\IL10N; -use \OCP\AppFramework\Utility\ITimeFactory; - -use \OCA\News\Db\Item; -use \OCA\News\Db\Feed; -use \OCA\News\Utility\PicoFeedFaviconFactory; -use \OCA\News\Utility\PicoFeedReaderFactory; +use PicoFeed\Parser\MalFormedXmlException; +use PicoFeed\Reader\Reader; +use PicoFeed\Reader\SubscriptionNotFoundException; +use PicoFeed\Reader\UnsupportedFeedFormatException; +use PicoFeed\Client\InvalidCertificateException; +use PicoFeed\Client\InvalidUrlException; +use PicoFeed\Client\MaxRedirectException; +use PicoFeed\Client\MaxSizeException; +use PicoFeed\Client\TimeoutException; + +use OCP\IL10N; +use OCP\AppFramework\Utility\ITimeFactory; + +use OCA\News\Db\Item; +use OCA\News\Db\Feed; +use OCA\News\Utility\PicoFeedFaviconFactory; +use OCA\News\Utility\PicoFeedReaderFactory; class FeedFetcher implements IFeedFetcher { @@ -68,12 +68,14 @@ class FeedFetcher implements IFeedFetcher { * @param string $etag an etag from an http header. * If lastModified matches the http header from the feed * no results are fetched + * @param bool fullTextEnabled if true tells the fetcher to enhance the + * articles by fetching custom enhanced content * @throws FetcherException if it fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items */ public function fetch($url, $getFavicon=true, $lastModified=null, - $etag=null) { + $etag=null, $fullTextEnabled=false) { try { $resource = $this->reader->discover($url, $lastModified, $etag); @@ -89,6 +91,10 @@ class FeedFetcher implements IFeedFetcher { $parser = $this->reader->getParser($location, $content, $encoding); + if ($fullTextEnabled) { + $parser->enableContentGrabber(); + } + $parsedFeed = $parser->execute(); $feed = $this->buildFeed( -- cgit v1.2.3