From 894eadbbda6c968d92cc2230a12bbf7a97d84bc7 Mon Sep 17 00:00:00 2001 From: teromene Date: Tue, 3 Nov 2015 22:28:44 +0000 Subject: [PATCH 1/5] =?UTF-8?q?Premier=20lot=20de=20bridges=20utilisant=20?= =?UTF-8?q?le=20premier=20syst=C3=A8me.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: teromene --- bridges/ABCTabsBridge.php | 32 ++++++++++--------------- bridges/AcrimedBridge.php | 9 +------ bridges/BastaBridge.php | 23 +++++++++--------- bridges/BlaguesDeMerdeBridge.php | 18 +++++++------- bridges/CADBridge.php | 22 ++++++++--------- bridges/CoinDeskBridge.php | 20 ++++++++-------- bridges/CollegeDeFranceBridge.php | 21 ++++++++-------- bridges/CommonDreamsBridge.php | 22 ++++++++--------- bridges/CopieDoubleBridge.php | 19 ++++++++------- bridges/CourrierInternationalBridge.php | 19 ++++++++------- bridges/DansTonChatBridge.php | 21 ++++++++-------- bridges/DemoBridge.php | 11 --------- bridges/DeveloppezDotComBridge.php | 20 ++++++++-------- bridges/DilbertBridge.php | 19 ++++++++------- bridges/FSBridge.php | 18 ++++++-------- bridges/FootitoBridge.php | 18 +++++++------- bridges/FrandroidBridge.php | 19 +++++++-------- bridges/GizmodoFRBridge.php | 20 ++++++++-------- bridges/GuruMedBridge.php | 17 ++++++------- bridges/KoreusBridge.php | 20 ++++++++-------- bridges/LeJournalDuGeekBridge.php | 20 ++++++++-------- bridges/LeMondeInformatiqueBridge.php | 21 ++++++++-------- bridges/LeMotDuJourBridge.php | 17 +++++++------ bridges/Les400Culs.php | 17 ++++++++----- bridges/LesJoiesDuCodeBridge.php | 18 +++++++------- 25 files changed, 233 insertions(+), 248 deletions(-) diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index f0973b6a..ac0772de 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -1,19 +1,18 @@ maintainer = "kranack"; + $this->name = "ABC Tabs Bridge"; + $this->uri = "http://www.abc-tabs.com/"; + $this->description = "Returns 22 newest tabs"; + $this->update = "2014-07-23"; + + } + public function collectData(array $param){ $html = ''; $html = file_get_html('http://www.abc-tabs.com/tablatures/nouveautes.html') or $this->returnError('No results for this query.', 404); @@ -30,13 +29,6 @@ class ABCTabsBridge extends BridgeAbstract{ $this->items[] = $item; } } - public function getName(){ - return 'ABC Tabs Bridge'; - } - - public function getURI(){ - return 'http://www.abc-tabs.com/'; - } public function getCacheDuration(){ return 3600; // 1 hour diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index d50a0d66..ae573f86 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -1,13 +1,6 @@ maintainer = "qwertygc"; diff --git a/bridges/BastaBridge.php b/bridges/BastaBridge.php index 976240fe..0b84ff39 100644 --- a/bridges/BastaBridge.php +++ b/bridges/BastaBridge.php @@ -1,16 +1,17 @@ maintainer = "qwertygc"; + $this->name = "Bastamag Bridge"; + $this->uri = "http://www.bastamag.net/"; + $this->description = "Returns the newest articles."; + $this->update = "2014-05-25"; + + } + + public function collectData(array $param){ diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index c7caed6f..2ba230f9 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -1,14 +1,16 @@ maintainer = "superbaillot.net"; + $this->name = "Blagues De Merde"; + $this->uri = "http://www.blaguesdemerde.fr/"; + $this->description = "Blagues De Merde"; + $this->update = "16/10/2013"; + + } + public function collectData(array $param){ $html = file_get_html('http://www.blaguesdemerde.fr/') or $this->returnError('Could not request BDM.', 404); diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index 8238eaf9..28ef697e 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -1,16 +1,16 @@ maintainer = "nyutag"; + $this->name = "CAD Bridge"; + $this->uri = "http://www.cad-comic.com/"; + $this->description = "Returns the newest articles."; + $this->update = "2015-04-03"; + + } + public function collectData(array $param){ function CADUrl($string) { diff --git a/bridges/CoinDeskBridge.php b/bridges/CoinDeskBridge.php index 6dc5a090..79c30ebd 100644 --- a/bridges/CoinDeskBridge.php +++ b/bridges/CoinDeskBridge.php @@ -1,16 +1,16 @@ maintainer = "mitsukarenai"; + $this->name = "CoinDesk"; + $this->uri = "http://www.coindesk.com/"; + $this->description = "Returns the 5 newest posts from CoinDesk (full text)"; + $this->update = "2014-05-30"; + + } + public function collectData(array $param){ function CoinDeskStripCDATA($string) { diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index 6526eaea..e9e0dbc0 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -1,15 +1,16 @@ maintainer = "pit-fgfjiudghdf"; + $this->name = "CollegeDeFrance"; + $this->uri = "http://www.college-de-france.fr/"; + $this->description = "Returns the 10 newest posts from CollegeDeFrance"; + $this->update = "2014-05-26"; + + } + public function collectData(array $param){ $find = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'novembre', 'décembre'); $replace = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php index 07247e56..2a30f37e 100644 --- a/bridges/CommonDreamsBridge.php +++ b/bridges/CommonDreamsBridge.php @@ -1,16 +1,16 @@ maintainer = "nyutag"; + $this->name = "CommonDreams Bridge"; + $this->uri = "http://www.commondreams.org/"; + $this->description = "Returns the newest articles."; + $this->update = "2015-04-03"; + + } + public function collectData(array $param){ function CommonDreamsUrl($string) { diff --git a/bridges/CopieDoubleBridge.php b/bridges/CopieDoubleBridge.php index c163bf6b..12b3a8a9 100644 --- a/bridges/CopieDoubleBridge.php +++ b/bridges/CopieDoubleBridge.php @@ -1,14 +1,17 @@ maintainer = "superbaillot.net"; + $this->name = "CopieDouble"; + $this->uri = "http://www.copie-double.com/"; + $this->description = "CopieDouble"; + $this->update = "12/12/2013"; + + } + + public function collectData(array $param){ $html = file_get_html('http://www.copie-double.com/') or $this->returnError('Could not request CopieDouble.', 404); $table = $html->find('table table', 2); diff --git a/bridges/CourrierInternationalBridge.php b/bridges/CourrierInternationalBridge.php index 2ad5899d..a7ff8b03 100644 --- a/bridges/CourrierInternationalBridge.php +++ b/bridges/CourrierInternationalBridge.php @@ -1,15 +1,16 @@ maintainer = "teromene"; + $this->name = "CourrierInternational"; + $this->uri = "http://CourrierInternational.fr/"; + $this->description = "Courrier International bridge"; + $this->update = "01/09/2015"; + + } + public function collectData(array $param){ function fetchArticle($link) { diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index 7e2e69e0..95a1cf5a 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -1,17 +1,16 @@ maintainer = "Astalaseven"; + $this->name = "DansTonChat Bridge"; + $this->uri = "http://danstonchat.com/latest.html"; + $this->description = "Returns latest quotes from DansTonChat."; + $this->update = "2014-05-25"; + + } + public function collectData(array $param){ $html = ''; $link = 'http://danstonchat.com/latest.html'; diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index df38be6b..7c87675c 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -1,15 +1,4 @@ maintainer = "polopollo"; + $this->name = "Developpez.com Actus (FR)"; + $this->uri = "http://www.developpez.com/"; + $this->description = "Returns the 15 newest posts from DeveloppezDotCom (full text)."; + $this->update = "2014-07-14"; + + } + public function collectData(array $param){ function DeveloppezDotComStripCDATA($string) { diff --git a/bridges/DilbertBridge.php b/bridges/DilbertBridge.php index d56986c2..30cbb1c6 100644 --- a/bridges/DilbertBridge.php +++ b/bridges/DilbertBridge.php @@ -1,15 +1,16 @@ maintainer = "kranack"; + $this->name = "Dilbert Daily Strip"; + $this->uri = "http://dilbert.com/strips/"; + $this->description = "The Unofficial Dilbert Daily Comic Strip"; + $this->update = "30/01/2015"; + + } + public function collectData(array $param){ $html = file_get_html('http://dilbert.com/strips/') or $this->returnError('Could not request Dilbert.', 404); diff --git a/bridges/FSBridge.php b/bridges/FSBridge.php index bc550133..11334d52 100644 --- a/bridges/FSBridge.php +++ b/bridges/FSBridge.php @@ -1,19 +1,15 @@ maintainer = "qwertygc"; + $this->name = "Futurasciences"; + $this->uri = "http://www.futura-sciences.com"; + $this->description = "Returns the 5 newest posts from FS (full text)"; + $this->update = "03/11/2015"; - + } public function collectData(array $param){ diff --git a/bridges/FootitoBridge.php b/bridges/FootitoBridge.php index 2731d5c7..467f0429 100644 --- a/bridges/FootitoBridge.php +++ b/bridges/FootitoBridge.php @@ -1,14 +1,16 @@ maintainer = "superbaillot.net"; + $this->name = "Footito"; + $this->uri = "http://www.footito.fr/"; + $this->description = "Footito"; + $this->update = "21/11/2013"; + + } + public function collectData(array $param){ $html = file_get_html('http://www.footito.fr/') or $this->returnError('Could not request Footito.', 404); diff --git a/bridges/FrandroidBridge.php b/bridges/FrandroidBridge.php index 7ee6c9c9..80aac5db 100644 --- a/bridges/FrandroidBridge.php +++ b/bridges/FrandroidBridge.php @@ -1,16 +1,15 @@ maintainer = "Daiyousei"; + $this->name = "Frandroid"; + $this->uri = "http://www.frandroid.com/"; + $this->description = "Returns the RSS feed from Frandroid (full text articles)"; + $this->update = "2015-03-05"; + + } public function collectData(array $param) { diff --git a/bridges/GizmodoFRBridge.php b/bridges/GizmodoFRBridge.php index b2e8a21e..bb19fc3d 100644 --- a/bridges/GizmodoFRBridge.php +++ b/bridges/GizmodoFRBridge.php @@ -1,16 +1,16 @@ maintainer = "polopollo"; + $this->name = "GizmodoFR"; + $this->uri = "http://www.gizmodo.fr/"; + $this->description = "Returns the 15 newest posts from GizmodoFR (full text)."; + $this->update = "2014-07-14"; + + } + public function collectData(array $param){ function GizmodoFRExtractContent($url) { diff --git a/bridges/GuruMedBridge.php b/bridges/GuruMedBridge.php index 032148bd..de836cb3 100644 --- a/bridges/GuruMedBridge.php +++ b/bridges/GuruMedBridge.php @@ -1,18 +1,15 @@ maintainer = "qwertygc"; + $this->name = "GuruMed"; + $this->uri = "http://www.gurumed.org"; + $this->description = "Returns the 5 newest posts from Gurumed (full text)"; + $this->update = "03/10/2015"; - + } public function collectData(array $param){ diff --git a/bridges/KoreusBridge.php b/bridges/KoreusBridge.php index 8ae90e8a..af99bf20 100644 --- a/bridges/KoreusBridge.php +++ b/bridges/KoreusBridge.php @@ -1,16 +1,16 @@ maintainer = "pit-fgfjiudghdf"; + $this->name = "Koreus"; + $this->uri = "http://www.koreus.com/"; + $this->description = "Returns the 5 newest posts from Koreus (full text)"; + $this->update = "2014-05-26"; + + } + public function collectData(array $param){ function KoreusStripCDATA($string) { diff --git a/bridges/LeJournalDuGeekBridge.php b/bridges/LeJournalDuGeekBridge.php index 07559012..5ed3b5e5 100644 --- a/bridges/LeJournalDuGeekBridge.php +++ b/bridges/LeJournalDuGeekBridge.php @@ -1,16 +1,16 @@ maintainer = "polopollo"; + $this->name = "journaldugeek.com (FR)"; + $this->uri = "http://www.journaldugeek.com/"; + $this->description = "Returns the 5 newest posts from LeJournalDuGeek (full text)."; + $this->update = "2014-07-14"; + + } + public function collectData(array $param){ function LeJournalDuGeekStripCDATA($string) { diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php index f007fb01..a0c16b2b 100644 --- a/bridges/LeMondeInformatiqueBridge.php +++ b/bridges/LeMondeInformatiqueBridge.php @@ -1,17 +1,16 @@ maintainer = "ORelio"; + $this->name = "Le Monde Informatique"; + $this->uri = "http://www.lemondeinformatique.fr/"; + $this->description = "Returns the newest articles."; + $this->update = "2015-09-08"; + + } + public function collectData(array $param) { function StripCDATA($string) { diff --git a/bridges/LeMotDuJourBridge.php b/bridges/LeMotDuJourBridge.php index 9149449b..8ea8ee61 100644 --- a/bridges/LeMotDuJourBridge.php +++ b/bridges/LeMotDuJourBridge.php @@ -1,12 +1,15 @@ maintainer = "qwertygc"; + $this->name = "LeMotDuJour Bridge"; + $this->uri = "http://www.lemotdujour.com/"; + $this->description = "Returns the newest articles."; + $this->update = "2014-05-25"; + + } public function collectData(array $param){ diff --git a/bridges/Les400Culs.php b/bridges/Les400Culs.php index f01e3646..dcb17ae8 100644 --- a/bridges/Les400Culs.php +++ b/bridges/Les400Culs.php @@ -1,10 +1,4 @@ maintainer = "unknown"; + $this->name = "Les 400 Culs"; + $this->uri = "http://sexes.blogs.liberation.fr"; + $this->description = "La planète sexe vue par Agnès Girard via rss-bridge"; + $this->update = "20/02/2014"; + + } + + public function collectData(array $param){ $param['url'] = RSS; parent::collectData($param); diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php index d9cc0028..2dd1c44b 100644 --- a/bridges/LesJoiesDuCodeBridge.php +++ b/bridges/LesJoiesDuCodeBridge.php @@ -1,14 +1,16 @@ maintainer = "superbaillot.net"; + $this->name = "Les Joies Du Code"; + $this->uri = "http://lesjoiesducode.fr/"; + $this->description = "LesJoiesDuCode"; + $this->update = "04/02/2015"; + + } + public function collectData(array $param){ $html = file_get_html('http://lesjoiesducode.fr/') or $this->returnError('Could not request LesJoiesDuCode.', 404); From a5a959dceda562435599f0023be33d3eb5acd8eb Mon Sep 17 00:00:00 2001 From: teromene Date: Tue, 3 Nov 2015 23:05:10 +0000 Subject: [PATCH 2/5] =?UTF-8?q?Correction=20de=20quelques=20bugs=20dans=20?= =?UTF-8?q?les=20bridges,=20qui=20apparaissent=20=C3=A0=20cause=20du=20fai?= =?UTF-8?q?t=20qu'ils=20sont=20tous=20instanci=C3=A9s=20lors=20du=20charge?= =?UTF-8?q?ment=20de=20tout=20les=20bridges.=20R=C3=A9-ajout=20et=20r?= =?UTF-8?q?=C3=A9-utilisation=20de=20getName=20et=20getURI,=20qui=20permet?= =?UTF-8?q?tent=20d'avoir=20des=20=C3=A9lements=20dynamiques.=20Changement?= =?UTF-8?q?=20en=20public=20de=20certaines=20valeurs.=20Changement=20du=20?= =?UTF-8?q?nom=20de=20certaines=20constantes,=20d=C3=A9ja=20utilis=C3=A9s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: teromene --- bridges/ABCTabsBridge.php | 12 ++++++++++++ bridges/AcrimedBridge.php | 11 +++++++++++ bridges/DemoBridge.php | 12 ++++++++++++ bridges/GiphyBridge.php | 2 +- bridges/Les400Culs.php | 4 ++-- bridges/RssExpander.php | 8 ++++---- bridges/SoundcloudBridge.php | 2 +- bridges/TheOatMealBridge.php | 4 ++-- bridges/WhydBridge.php | 2 +- bridges/WordPressBridge.php | 2 +- bridges/WorldOfTanks.php | 4 ++-- index.php | 8 ++++++-- lib/Bridge.php | 21 ++++++++++++++++++++- 13 files changed, 75 insertions(+), 17 deletions(-) diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index ac0772de..7481f3a1 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -30,6 +30,18 @@ class ABCTabsBridge extends BridgeAbstract{ } } + public function getName() { + + return "ABC Tabs Bridge"; + + } + + public function getURI() { + + return "http://www.abc-tabs.com/"; + + } + public function getCacheDuration(){ return 3600; // 1 hour } diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index ae573f86..d0f5abfc 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -39,6 +39,17 @@ class AcrimedBridge extends BridgeAbstract{ } + public function getName() { + + return "Acrimed Bridge"; + + } + + public function getURI() { + + return "http://www.acrimed.org/"; + + } public function getCacheDuration(){ return 3600*2; // 2 hours diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 7c87675c..24cd3891 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -55,6 +55,18 @@ class DemoBridge extends BridgeAbstract{ } + public function getName() { + + return "DemoBridge"; + + } + + public function getURI() { + + return "http://github.com/sebsauvage/rss-bridge"; + + } + public function getCacheDuration(){ return 3600; // 1 hour } diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index b0a4f899..f3c0d99b 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -12,7 +12,7 @@ * @use2(n="max number of returned items") */ -define(GIPHY_LIMIT, 10); +define('GIPHY_LIMIT', 10); class GiphyBridge extends BridgeAbstract{ diff --git a/bridges/Les400Culs.php b/bridges/Les400Culs.php index dcb17ae8..4694f406 100644 --- a/bridges/Les400Culs.php +++ b/bridges/Les400Culs.php @@ -1,7 +1,7 @@ returnError('There is no $param[\'url\'] for this RSS expander', 404); @@ -65,4 +65,4 @@ abstract class RssExpander extends HttpCachingBridgeAbstract{ public function getDescription() { return $this->description; } -} \ No newline at end of file +} diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 05c807bc..7bcc6d0a 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -14,7 +14,7 @@ class SoundCloudBridge extends BridgeAbstract{ private $request; - private $name; + public $name; const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875'; public function collectData(array $param){ diff --git a/bridges/TheOatMealBridge.php b/bridges/TheOatMealBridge.php index 84b6954b..7342ec2b 100644 --- a/bridges/TheOatMealBridge.php +++ b/bridges/TheOatMealBridge.php @@ -10,11 +10,11 @@ */ require_once 'bridges/RssExpander.php'; define("THE_OATMEAL", "http://theoatmeal.com/"); -define("RSS", "http://feeds.feedburner.com/oatmealfeed"); +define("THE_OATMEAL_RSS", "http://feeds.feedburner.com/oatmealfeed"); class TheOatmealBridge extends RssExpander{ public function collectData(array $param){ - $param['url'] = RSS; + $param['url'] = THE_OATMEAL_RSS; parent::collectData($param); } diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 9bac7a05..060a7b62 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -14,7 +14,7 @@ class WhydBridge extends BridgeAbstract{ private $request; - private $name; + public $name; public function collectData(array $param){ $html = ''; diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index a2eee25b..2a182df3 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -14,7 +14,7 @@ class WordPressBridge extends BridgeAbstract { private $url; - private $name; + public $name; public function collectData(array $param) { $this->processParams($param); diff --git a/bridges/WorldOfTanks.php b/bridges/WorldOfTanks.php index ccc80bf5..f4de4773 100644 --- a/bridges/WorldOfTanks.php +++ b/bridges/WorldOfTanks.php @@ -10,8 +10,8 @@ define('WORLD_OF_TANKS', 'http://worldoftanks.eu/'); define('NEWS', '/news/'); class WorldOfTanks extends HttpCachingBridgeAbstract{ private $lang = "fr"; - private $uri = WORLD_OF_TANKS; - private $name = 'World of tanks news'; + public $uri = WORLD_OF_TANKS; + public $name = 'World of tanks news'; public function collectData(array $param){ if (!empty($param['lang'])) { diff --git a/index.php b/index.php index 5a4dea80..30dee333 100644 --- a/index.php +++ b/index.php @@ -102,8 +102,8 @@ try{ $format ->setDatas($bridge->getDatas()) ->setExtraInfos(array( - 'name' => $bridge->name, - 'uri' => $bridge->uri, + 'name' => $bridge->getName(), + 'uri' => $bridge->getURI(), )) ->display(); die; @@ -140,7 +140,11 @@ function getHelperButtonsFormat($formats){ function displayBridgeCard($bridgeName, $formats, $isActive = true) { + $bridgeElement = Bridge::create($bridgeName); + if($bridgeElement == false) { + return ""; + } $bridgeElement->loadMetadatas(); $name = ''.$bridgeElement->name.''; diff --git a/lib/Bridge.php b/lib/Bridge.php index 29ac6d2a..b4945202 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -8,6 +8,8 @@ interface BridgeInterface{ public function collectData(array $param); public function getCacheDuration(); public function loadMetadatas(); + public function getName(); + public function getURI(); } abstract class BridgeAbstract implements BridgeInterface{ @@ -207,6 +209,19 @@ class Bridge{ throw new \LogicException('Please use ' . __CLASS__ . '::create for new object.'); } + /** + * Checks if a bridge is an instantiable bridge. + * @param string $nameBridge name of the bridge that you want to use + * @return true if it is an instantiable bridge, false otherwise. + */ + static public function isInstantiable($nameBridge) { + + $re = new ReflectionClass($nameBridge); + return $re->IsInstantiable(); + + } + + /** * Create a new bridge object * @param string $nameBridge Defined bridge name you want use @@ -225,7 +240,11 @@ class Bridge{ require_once $pathBridge; - return new $nameBridge(); + if(Bridge::isInstantiable($nameBridge)) { + return new $nameBridge(); + } else { + return FALSE; + } } static public function setDir($dirBridge){ From 1efaba5c7c9de113cc073ae293ac8a2939acaa67 Mon Sep 17 00:00:00 2001 From: teromene Date: Wed, 4 Nov 2015 09:47:21 +0000 Subject: [PATCH 3/5] =?UTF-8?q?Deuxi=C3=A8me=20lot=20de=20bridges.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/MalikiBridge.php | 20 ++++++++++---------- bridges/MemoLinuxBridge.php | 17 ++++++++++------- bridges/MondeDiploBridge.php | 22 ++++++++++------------ bridges/MsnMondeBridge.php | 20 ++++++++++---------- bridges/NasaApodBridge.php | 17 ++++++++++------- bridges/NextInpactBridge.php | 21 ++++++++++----------- bridges/NiceMatinBridge.php | 20 ++++++++++---------- bridges/NumeramaBridge.php | 20 ++++++++++---------- bridges/OpenTheoryBridge.php | 17 +++++++---------- bridges/PlanetLibreBridge.php | 21 +++++++++++---------- bridges/ProjectMGameBridge.php | 18 +++++++++++------- bridges/TwitchApiBridge.php | 4 ++-- 12 files changed, 111 insertions(+), 106 deletions(-) diff --git a/bridges/MalikiBridge.php b/bridges/MalikiBridge.php index 29e4cfa5..de871200 100644 --- a/bridges/MalikiBridge.php +++ b/bridges/MalikiBridge.php @@ -1,16 +1,16 @@ maintainer = "mitsukarenai"; + $this->name = "Maliki"; + $this->uri = "http://www.maliki.com/"; + $this->description = "Returns Maliki's newest strips"; + $this->update = "2014-05-30"; + + } + public function collectData(array $param){ $html = file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404); $count=0; diff --git a/bridges/MemoLinuxBridge.php b/bridges/MemoLinuxBridge.php index 7da5ba0f..02d7ac70 100644 --- a/bridges/MemoLinuxBridge.php +++ b/bridges/MemoLinuxBridge.php @@ -1,13 +1,16 @@ maintainer = "qwertygc"; + $this->name = "MemoLinux"; + $this->uri = "http://memo-linux.com/"; + $this->description = "Returns the 10 newest posts from MemoLinux (full text)"; + $this->update = "2015-01-30"; + + } + public function collectData(array $param){ function StripCDATA($string) { diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index 2077205e..3774be86 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -1,18 +1,16 @@ maintainer = "Pitchoule"; + $this->name = "MondeDiplo"; + $this->uri = "http://www.monde-diplomatique.fr"; + $this->description = "Returns most recent results from MondeDiplo."; + $this->update = "2014-07-22"; + + } + public function collectData(array $param){ $link = 'http://www.monde-diplomatique.fr'; diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index 0d2e4711..1a63da63 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -1,16 +1,16 @@ maintainer = "kranack"; + $this->name = "MSN Actu Monde"; + $this->uri = "http://www.msn.com/fr-fr/actualite/monde"; + $this->description = "Returns the 10 newest posts from MSN Actualités (full text)"; + $this->update = "2015-01-30"; + + } + public function collectData(array $param){ function MsnMondeExtractContent($url, &$item) { diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index f3f76209..63c8c93e 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -1,13 +1,16 @@ maintainer = "corenting"; + $this->name = "NASA APOD Bridge"; + $this->uri = "http://apod.nasa.gov/apod/astropix.html"; + $this->description = "Returns the 3 latest NASA APOD pictures and explanations"; + $this->update = "2014-08-27"; + + } + public function collectData(array $param) { $html = file_get_html('http://apod.nasa.gov/apod/archivepix.html') or $this->returnError('Error while downloading the website content', 404); diff --git a/bridges/NextInpactBridge.php b/bridges/NextInpactBridge.php index c070038a..107f3e72 100644 --- a/bridges/NextInpactBridge.php +++ b/bridges/NextInpactBridge.php @@ -1,17 +1,16 @@ maintainer = "qwertygc"; + $this->name = "NextInpact Bridge"; + $this->uri = "http://www.nextinpact.com/"; + $this->description = "Returns the newest articles."; + $this->update = "2015-10-23"; + + } + public function collectData(array $param) { function StripCDATA($string) { diff --git a/bridges/NiceMatinBridge.php b/bridges/NiceMatinBridge.php index 7c0441a6..bbfe4d83 100644 --- a/bridges/NiceMatinBridge.php +++ b/bridges/NiceMatinBridge.php @@ -1,16 +1,16 @@ maintainer = "pit-fgfjiudghdf"; + $this->name = "NiceMatin"; + $this->uri = "http://www.nicematin.com/"; + $this->description = "Returns the 10 newest posts from NiceMatin (full text)"; + $this->update = "2014-05-26"; + + } + public function collectData(array $param){ function NiceMatinUrl($string) { diff --git a/bridges/NumeramaBridge.php b/bridges/NumeramaBridge.php index cc7e2f2e..f1958a40 100644 --- a/bridges/NumeramaBridge.php +++ b/bridges/NumeramaBridge.php @@ -1,16 +1,16 @@ maintainer = "mitsukarenai"; + $this->name = "Numerama"; + $this->uri = "http://www.numerama.com/"; + $this->description = "Returns the 5 newest posts from Numerama (full text)"; + $this->update = "2015-10-12"; + + } + public function collectData(array $param){ function NumeramaStripCDATA($string) { diff --git a/bridges/OpenTheoryBridge.php b/bridges/OpenTheoryBridge.php index 9117d372..ebafa330 100644 --- a/bridges/OpenTheoryBridge.php +++ b/bridges/OpenTheoryBridge.php @@ -1,18 +1,15 @@ maintainer = "qwertygc"; + $this->name = "Opentheory"; + $this->uri = "http://open1theory.com"; + $this->description = "Returns the 5 newest posts from OpenTheory (full text)"; + $this->update = "02-08-2014"; - + } public function collectData(array $param){ diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php index 5ada5358..6cb92e4d 100644 --- a/bridges/PlanetLibreBridge.php +++ b/bridges/PlanetLibreBridge.php @@ -1,15 +1,16 @@ maintainer = "pit-fgfjiudghdf"; + $this->name = "PlanetLibre"; + $this->uri = "http://www.planet-libre.org"; + $this->description = "Returns the 5 newest posts from PlanetLibre (full text)"; + $this->update = "2014-05-26"; + + } + public function collectData(array $param){ function PlanetLibreExtractContent($url) { diff --git a/bridges/ProjectMGameBridge.php b/bridges/ProjectMGameBridge.php index e8dc05cc..a3180416 100644 --- a/bridges/ProjectMGameBridge.php +++ b/bridges/ProjectMGameBridge.php @@ -1,13 +1,17 @@ maintainer = "corenting"; + $this->name = "Project M Game Bridge"; + $this->uri = "http://projectmgame.com/en/"; + $this->description = "Returns the newest articles."; + $this->update = "2014-08-27"; + + } + + public function collectData(array $param){ $html = ''; $html = file_get_html('http://projectmgame.com/en/') or $this->returnError('Error while downloading the Project M homepage', 404); diff --git a/bridges/TwitchApiBridge.php b/bridges/TwitchApiBridge.php index cedb7496..aec4a9c9 100644 --- a/bridges/TwitchApiBridge.php +++ b/bridges/TwitchApiBridge.php @@ -15,8 +15,8 @@ * Description for the API is available on GitHub: https://github.com/justintv/twitch-api */ -define(TWITCH_LIMIT, 10); // The default limit -define(TWITCH_BROADCASTS, 'false'); // The default flag for broadcasts +define('TWITCH_LIMIT', 10); // The default limit +define('TWITCH_BROADCASTS', 'false'); // The default flag for broadcasts class TwitchApiBridge extends BridgeAbstract{ From ffc01fa3bd517310c31974d59ce683fdc1d2f6ac Mon Sep 17 00:00:00 2001 From: Hauke Schade Date: Wed, 4 Nov 2015 20:22:48 +0100 Subject: [PATCH 4/5] added WikipediaDEBridge --- bridges/WikipediaDEBridge.php | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bridges/WikipediaDEBridge.php diff --git a/bridges/WikipediaDEBridge.php b/bridges/WikipediaDEBridge.php new file mode 100644 index 00000000..973170db --- /dev/null +++ b/bridges/WikipediaDEBridge.php @@ -0,0 +1,48 @@ +returnError('Could not request Wikipedia DE.', 404); + + $element = $html->find('div[id=mf-tfa]', 0); + $element->find('div', -1)->outertext = ''; + + $item = new \Item(); + $item->uri = $host.$element->find('p', 0)->find('a', 0)->href; + $item->title = $element->find('p',0)->find('a',0)->title; + + $html2 = file_get_html($item->uri) or $this->returnError('Could not request Wikipedia DE '.$item->title.'.', 404); + $element2 = $html2->find('div[id=mw-content-text]', 0); + $item->content = str_replace('href="/', 'href="'.$host.'/', $element2->innertext); + + $this->items[] = $item; + } + + public function getName(){ + return 'Wikipedia DE "Today\'s Featured Article"'; + } + + public function getURI(){ + return 'https://de.wikipedia.org/wiki/Wikipedia:Hauptseite'; + } + + public function getCacheDuration(){ + return 3600*8; // 8 hours + } +} From 43f0fc93b7f5f226d6f63b62659ac224ef6218fa Mon Sep 17 00:00:00 2001 From: teromene Date: Thu, 5 Nov 2015 10:12:58 +0000 Subject: [PATCH 5/5] Correction of few bugs. Warn if RSS-Bridge cannot write to disk. Try/Catch the bridge RSS generation. Signed-off-by: teromene --- caches/FileCache.php | 10 ++++++++-- index.php | 30 ++++++++++++++++-------------- lib/Exceptions.php | 2 +- lib/RssBridge.php | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/caches/FileCache.php b/caches/FileCache.php index 594343d3..f2e0dbb7 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -24,7 +24,13 @@ class FileCache extends CacheAbstract{ public function saveData($datas){ $this->isPrepareCache(); - file_put_contents($this->getCacheFile(), json_encode($datas)); + $writeStream = file_put_contents($this->getCacheFile(), json_encode($datas)); + + if(!$writeStream) { + + throw new \Exception("Cannot write the cache... Do you have the right permissions ?"); + + } return $this; } @@ -89,4 +95,4 @@ class FileCache extends CacheAbstract{ $stringToEncode = $_SERVER['REQUEST_URI'] . http_build_query($this->param); return hash('sha1', $stringToEncode) . '.cache'; } -} \ No newline at end of file +} diff --git a/index.php b/index.php index 30dee333..3c3d6780 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,4 @@ setDatas($_REQUEST); $bridge->loadMetadatas(); // Data transformation - $format = Format::create($format); - $format - ->setDatas($bridge->getDatas()) - ->setExtraInfos(array( - 'name' => $bridge->getName(), - 'uri' => $bridge->getURI(), - )) - ->display(); + try { + $format = Format::create($format); + $format + ->setDatas($bridge->getDatas()) + ->setExtraInfos(array( + 'name' => $bridge->getName(), + 'uri' => $bridge->getURI(), + )) + ->display(); + } catch(Exception $e) { + + echo "The brige has crashed. You should report this to the bridges maintainer"; + + } die; } break; @@ -273,10 +278,7 @@ $formats = Format::searchInformation(); ?> - diff --git a/lib/Exceptions.php b/lib/Exceptions.php index 202060f6..74124eaa 100644 --- a/lib/Exceptions.php +++ b/lib/Exceptions.php @@ -58,4 +58,4 @@ class Http{ 508 => 'Loop detected', ); } -} \ No newline at end of file +} diff --git a/lib/RssBridge.php b/lib/RssBridge.php index d2952806..5e0824ff 100644 --- a/lib/RssBridge.php +++ b/lib/RssBridge.php @@ -39,4 +39,4 @@ require_once $vendorLibSimpleHtmlDom; )) ->display(); -*/ \ No newline at end of file +*/