summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid <david-dev@live.de>2013-09-14 23:07:23 +0200
committerDavid <david-dev@live.de>2013-09-14 23:07:23 +0200
commit8b380a09ff2e7966c64cfc943d11375274e50209 (patch)
treef7aae5d3c23f8d78a9b37e441cd55494ef7f7faf
parent96a3156a09195f11e83007077b46f147ceb88fda (diff)
Add ThemeRepublic Enhancer
-rw-r--r--dependencyinjection/dicontainer.php10
-rw-r--r--tests/unit/utility/articleenhancer/ArticleEnhancerTest.php3
-rw-r--r--utility/articleenhancer/ThemeRepublicEnhancer.php21
3 files changed, 33 insertions, 1 deletions
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 @@
+<?php
+
+namespace OCA\News\Utility\ArticleEnhancer;
+
+use \OCA\News\Utility\SimplePieFileFactory;
+
+class ThemeRepublicEnhancer extends ArticleEnhancer {
+
+ public function __construct(SimplePieFileFactory $fileFactory, $purifier,
+ $timeout){
+ parent::__construct(
+ $purifier,
+ $fileFactory,
+ array(
+ '/feedproxy.google.com\/~r\/blogspot\/DngUJ/' => "//*[@class='post hentry']"
+ ),
+ $timeout
+ );
+ }
+}
+?> \ No newline at end of file