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:
parent
96a3156a09
commit
8b380a09ff
dependencyinjection
tests/unit/utility/articleenhancer
utility/articleenhancer
@ -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();
|
||||
|
@ -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
|
||||
);
|
||||
|
21
utility/articleenhancer/ThemeRepublicEnhancer.php
Normal file
21
utility/articleenhancer/ThemeRepublicEnhancer.php
Normal 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
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user