diff options
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | dependencyinjection/dicontainer.php | 5 | ||||
-rw-r--r-- | utility/feedfetcher.php | 11 |
3 files changed, 15 insertions, 4 deletions
diff --git a/README.rst b/README.rst index 283f8e409..ec41e1ded 100644 --- a/README.rst +++ b/README.rst @@ -31,6 +31,9 @@ How to install the News app - Activate the App Framework App first, then activate the News app in the apps menu +- Adjust the rights so that the webserver can write into the cache directory:: + + sudo chown -R www-data:www-data /var/www/news/cache How to keep up to date ---------------------- diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 4881596cf..e26e57f4d 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -65,6 +65,8 @@ class DIContainer extends BaseContainer { * Configuration values */ $this['autoPurgeCount'] = 1000; + $this['simplePieCacheDirectory'] = __DIR__ . '/../cache/simplepie/'; + $this['simplePieCacheDuration'] = 1000; // seconds /** @@ -147,7 +149,8 @@ class DIContainer extends BaseContainer { }); $this['FeedFetcher'] = $this->share(function($c){ - return new FeedFetcher($c['API']); + return new FeedFetcher($c['API'], $c['simplePieCacheDirectory'], + $c['simplePieCacheDuration']); }); $this['TwitterFetcher'] = $this->share(function($c){ diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index cf4b39b2a..27828336d 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -34,9 +34,13 @@ use \OCA\News\Db\Feed; class FeedFetcher implements IFeedFetcher { private $api; + private $cacheDirectory; + private $cacheDuration; - public function __construct(API $api){ + public function __construct(API $api, $cacheDirectory, $cacheDuration){ $this->api = $api; + $this->cacheDirectory = $cacheDirectory; + $this->cacheDuration = $cacheDuration; } @@ -59,8 +63,9 @@ class FeedFetcher implements IFeedFetcher { $simplePie = new \SimplePie_Core(); $simplePie->set_feed_url( $url ); $simplePie->enable_cache( false ); - // $simplePie->set_cache_location($cacheDirectory) . '/rss/'; - // $simplePie->enable_cache(true); + $simplePie->set_cache_location($this->cacheDirectory); + $simplePie->set_cache_duration($this->cacheDuration); + $simplePie->enable_cache(true); if (!$simplePie->init()) { throw new FetcherException('Could not initialize simple pie'); |