From 8b380a09ff2e7966c64cfc943d11375274e50209 Mon Sep 17 00:00:00 2001 From: David Date: Sat, 14 Sep 2013 23:07:23 +0200 Subject: Add ThemeRepublic Enhancer --- dependencyinjection/dicontainer.php | 10 ++++++++++ .../utility/articleenhancer/ArticleEnhancerTest.php | 3 ++- utility/articleenhancer/ThemeRepublicEnhancer.php | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 utility/articleenhancer/ThemeRepublicEnhancer.php diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 71866b502..8312fd5ee 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -62,6 +62,7 @@ use \OCA\News\Utility\SimplePieFileFactory; use \OCA\News\Utility\ArticleEnhancer\Enhancer; use \OCA\News\Utility\ArticleEnhancer\CyanideAndHappinessEnhancer; +use \OCA\News\Utility\ArticleEnhancer\ThemeRepublicEnhancer; use \OCA\News\Middleware\CORSMiddleware; @@ -259,6 +260,7 @@ class DIContainer extends BaseContainer { // register fetchers in order // the most generic enhancer should be the last one $enhancer->registerEnhancer('explosm.net', $c['CyanideAndHappinessEnhancer']); + $enhancer->registerEnhancer('feedproxy.google.com', $c['ThemeRepublicEnhancer']); return $enhancer; }); @@ -275,6 +277,14 @@ class DIContainer extends BaseContainer { ); }); + $this['ThemeRepublicEnhancer'] = $this->share(function($c){ + return new ThemeRepublicEnhancer( + $c['SimplePieFileFactory'], + $c['HTMLPurifier'], + $c['feedFetcherTimeout'] + ); + }); + $this['Fetcher'] = $this->share(function($c){ $fetcher = new Fetcher(); diff --git a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php index bb3c9e53d..a7585d771 100644 --- a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php +++ b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php @@ -58,7 +58,8 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory, array( '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/img', - '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div' + '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div', + '/themerepublic.net/' => '//*[@class=\'post hentry\']' ), $this->timeout ); diff --git a/utility/articleenhancer/ThemeRepublicEnhancer.php b/utility/articleenhancer/ThemeRepublicEnhancer.php new file mode 100644 index 000000000..c13ff6027 --- /dev/null +++ b/utility/articleenhancer/ThemeRepublicEnhancer.php @@ -0,0 +1,21 @@ + "//*[@class='post hentry']" + ), + $timeout + ); + } +} +?> \ No newline at end of file -- cgit v1.2.3