From f01bc29f574260b309e126832183290d1991a163 Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:26:15 +0100 Subject: [PATCH 1/5] Added Wikipedia FR bridge --- bridges/WikipediaFRBridge.php | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bridges/WikipediaFRBridge.php diff --git a/bridges/WikipediaFRBridge.php b/bridges/WikipediaFRBridge.php new file mode 100755 index 0000000..3dad0c7 --- /dev/null +++ b/bridges/WikipediaFRBridge.php @@ -0,0 +1,39 @@ +returnError('Could not request Wikipedia FR.', 404); + + $element = $html->find('div[id=accueil-lumieresur]', 0); + $item = new \Item(); + $item->uri = $host.$element->find('p', 0)->find('a', 0)->href; + $item->title = $element->find('p',0)->find('a',0)->title; + $item->content = str_replace('href="', 'href="'.$host, $html->find('div[id=mf-lumieresur]', 0)->innertext); + $this->items[] = $item; + } + + public function getName(){ + return 'Wikipedia FR "Lumière sur..."'; + } + + public function getURI(){ + return 'https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal'; + } + + public function getCacheDuration(){ + return 0*3600*4; // 4 hours + } +} From 5288756d04bb407742db39440b564a4ee548f1ce Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:42:02 +0100 Subject: [PATCH 2/5] Corrected mistake in Wikipedia FR bridge --- bridges/WikipediaFRBridge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/WikipediaFRBridge.php b/bridges/WikipediaFRBridge.php index 3dad0c7..9d9dd94 100755 --- a/bridges/WikipediaFRBridge.php +++ b/bridges/WikipediaFRBridge.php @@ -21,7 +21,7 @@ class WikipediaFRBridge extends BridgeAbstract{ $item = new \Item(); $item->uri = $host.$element->find('p', 0)->find('a', 0)->href; $item->title = $element->find('p',0)->find('a',0)->title; - $item->content = str_replace('href="', 'href="'.$host, $html->find('div[id=mf-lumieresur]', 0)->innertext); + $item->content = str_replace('href="', 'href="'.$host, $element->find('div[id=mf-lumieresur]', 0)->innertext); $this->items[] = $item; } @@ -34,6 +34,6 @@ class WikipediaFRBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 0*3600*4; // 4 hours + return 3600*4; // 4 hours } } From d7e2d65ff7787507cc4071f6b7214e91ecf4e72f Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:42:39 +0100 Subject: [PATCH 3/5] Added Wikipedia EN bridge (Today's featured article) --- bridges/WikipediaENBridge.php | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bridges/WikipediaENBridge.php diff --git a/bridges/WikipediaENBridge.php b/bridges/WikipediaENBridge.php new file mode 100755 index 0000000..ecd2ccf --- /dev/null +++ b/bridges/WikipediaENBridge.php @@ -0,0 +1,41 @@ +returnError('Could not request Wikipedia EN.', 404); + + $element = $html->find('div[id=mp-tfa]', 0); + // Clean the bottom of the featured article + $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; + $item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext); + $this->items[] = $item; + } + + public function getName(){ + return 'Wikipedia EN "Today\'s Featued Article"'; + } + + public function getURI(){ + return 'https://en.wikipedia.org/wiki/Main_Page'; + } + + public function getCacheDuration(){ + return 3600*4; // 4 hours + } +} From 02c7b2be87ab2c4d79acc018c37cc14da502ec49 Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:43:21 +0100 Subject: [PATCH 4/5] Corrected mistake in Wikipedia FR bridge if using absolute links --- bridges/WikipediaFRBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/WikipediaFRBridge.php b/bridges/WikipediaFRBridge.php index 9d9dd94..20376da 100755 --- a/bridges/WikipediaFRBridge.php +++ b/bridges/WikipediaFRBridge.php @@ -21,7 +21,7 @@ class WikipediaFRBridge extends BridgeAbstract{ $item = new \Item(); $item->uri = $host.$element->find('p', 0)->find('a', 0)->href; $item->title = $element->find('p',0)->find('a',0)->title; - $item->content = str_replace('href="', 'href="'.$host, $element->find('div[id=mf-lumieresur]', 0)->innertext); + $item->content = str_replace('href="/', 'href="'.$host.'/', $element->find('div[id=mf-lumieresur]', 0)->innertext); $this->items[] = $item; } From 07d27e042178f61c52e2317ad4fa5bfb70ab19b1 Mon Sep 17 00:00:00 2001 From: gsurrel Date: Thu, 2 Jan 2014 11:58:10 +0100 Subject: [PATCH 5/5] Added Wikipedia Esperanto bridge --- bridges/WikipediaEOBridge.php | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 bridges/WikipediaEOBridge.php diff --git a/bridges/WikipediaEOBridge.php b/bridges/WikipediaEOBridge.php new file mode 100644 index 0000000..19f8cee --- /dev/null +++ b/bridges/WikipediaEOBridge.php @@ -0,0 +1,41 @@ +returnError('Could not request Wikipedia EO.', 404); + + $element = $html->find('div[id=mf-tfa]', 0); + // Link to article + $link = $element->find('p', -2)->find('a', 0); + $item = new \Item(); + $item->uri = $host.$link->href; + $item->title = $link->title; + $item->content = str_replace('href="/', 'href="'.$host.'/', $element->innertext); + $this->items[] = $item; + } + + public function getName(){ + return 'Wikipedia EO "Artikolo de la semajno"'; + } + + public function getURI(){ + return 'https://eo.wikipedia.org/wiki/Vikipedio:%C4%88efpa%C4%9Do'; + } + + public function getCacheDuration(){ + return 3600*12; // 12 hours + } +}