diff options
-rw-r--r-- | dependencyinjection/dicontainer.php | 17 | ||||
-rw-r--r-- | utility/articleenhancer/escapistcomicenhancer.php | 49 |
2 files changed, 66 insertions, 0 deletions
diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 78e35a313..94806b2f7 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -67,6 +67,7 @@ use OCA\News\Utility\ArticleEnhancer\CADEnhancer; use OCA\News\Utility\ArticleEnhancer\PennyArcadeEnhancer; use OCA\News\Utility\ArticleEnhancer\TwoGAGEnhancer; use OCA\News\Utility\ArticleEnhancer\LeastICouldDoEnhancer; +use OCA\News\Utility\ArticleEnhancer\EscapistComicEnhancer; use \OCA\News\Middleware\CORSMiddleware; @@ -269,6 +270,14 @@ class DIContainer extends BaseContainer { $enhancer->registerEnhancer('penny-arcade.com', $c['PennyArcadeEnhancer']); $enhancer->registerEnhancer('twogag.com', $c['TwoGAGEnhancer']); $enhancer->registerEnhancer('leasticoulddo.com', $c['LeastICouldDoEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/critical-miss', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/critical-miss', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/namegame', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/stolen-pixels', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/bumhugparade', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/escapistradiotheater', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/paused', $c['EscapistComicEnhancer']); + $enhancer->registerEnhancer('escapistmagazine.com/articles/view/comics/fraughtwithperil', $c['EscapistComicEnhancer']); return $enhancer; }); @@ -325,6 +334,14 @@ class DIContainer extends BaseContainer { ); }); + $this['EscapistComicEnhancer'] = $this->share(function($c){ + return new EscapistComicEnhancer( + $c['SimplePieFileFactory'], + $c['HTMLPurifier'], + $c['feedFetcherTimeout'] + ); + }); + $this['Fetcher'] = $this->share(function($c){ $fetcher = new Fetcher(); diff --git a/utility/articleenhancer/escapistcomicenhancer.php b/utility/articleenhancer/escapistcomicenhancer.php new file mode 100644 index 000000000..a2238ed29 --- /dev/null +++ b/utility/articleenhancer/escapistcomicenhancer.php @@ -0,0 +1,49 @@ +<?php + +/** + * ownCloud - News + * + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino cosenal@gmail.com + * @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\News\Utility\ArticleEnhancer; + +use \OCA\News\Utility\SimplePieFileFactory; + + +class EscapistComicEnhancer extends ArticleEnhancer { + + + public function __construct(SimplePieFileFactory $fileFactory, $purifier, + $timeout) { + parent::__construct( + $purifier, + $fileFactory, + array( + '/escapistmagazine.com\/articles\/view\/comics\/critical-miss/' => '//*[@class=\'body\']/span/img', + '/escapistmagazine.com\/articles\/view\/comics\/namegame/' => '//*[@class=\'body\']/span/p/img[@height != "120"]', + '/escapistmagazine.com\/articles\/view\/comics\/(stolen-pixels|bumhugparade|escapistradiotheater)/' => '//*[@class=\'body\']/span/p[2]/img', + '/escapistmagazine.com\/articles\/view\/comics\/paused/' => '//*[@class=\'body\']/span/p[2]/img | //*[@class=\'body\']/span/div/img', + '/escapistmagazine.com\/articles\/view\/comics\/fraughtwithperil/' => '//*[@class=\'body\']', + ), + $timeout + ); + } +} |