1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-04-09 10:15:44 +02:00

Add ThemeRepublic Enhancer

This commit is contained in:
David 2013-09-14 23:07:23 +02:00
parent 96a3156a09
commit 8b380a09ff
3 changed files with 33 additions and 1 deletions
dependencyinjection
tests/unit/utility/articleenhancer
utility/articleenhancer

View File

@ -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();

View File

@ -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
);

View File

@ -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
);
}
}
?>