Le Journal du Geek Bridge

This commit is contained in:
Paul Vayssiere 2014-07-14 13:12:52 -05:00
parent 9da81ee290
commit ee45f0a829
2 changed files with 70 additions and 1 deletions

View file

@ -19,7 +19,7 @@ class GizmodoFRBridge extends BridgeAbstract{
$text = $text.$articleHTMLContent->find('div.entry-excerpt', 0)->innertext;
$text = $text.$articleHTMLContent->find('div.entry-content', 0)->innertext;
foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
$text = $text.'<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p>';
$text = $text.'<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p><br>';
}
$text = strip_tags($text, '<p><b><a><blockquote><img><em>');

View file

@ -0,0 +1,69 @@
<?php
/**
* RssBridgeLeJournalDuGeek
* Returns the 15 newest posts from http://www.journaldugeek.com (full text)
* 2014-07-14
*
* @name journaldugeek.com (FR)
* @homepage http://www.journaldugeek.com/
* @description Returns the 15 newest posts from LeJournalDuGeek (full text).
* @maintainer polopollo
*/
class LeJournalDuGeekBridge extends BridgeAbstract{
public function collectData(array $param){
function LeJournalDuGeekStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
function LeJournalDuGeekExtractContent($url) {
$articleHTMLContent = file_get_html($url);
$text = $text.$articleHTMLContent->find('div.post-content', 0)->innertext;
foreach($articleHTMLContent->find('a.more') as $element) {
if ($element->innertext == "Source") {
$text = $text.'<p><a href="'.$element->href.'">Source : '.$element->href.'</a></p>';
break;
}
}
foreach($articleHTMLContent->find('iframe') as $element) {
if (preg_match("/youtube/i", $element->src)) {
$text = $text.'// An IFRAME to Youtube was included in the article: <a href="'.$element->src.'">'.$element->src.'</a><br>';
}
}
$text = strip_tags($text, '<p><b><a><blockquote><img><em><br/><br><ul><li>');
return $text;
}
$rssFeed = file_get_html('http://www.journaldugeek.com/rss') or $this->returnError('Could not request http://www.journaldugeek.com/rss', 404);
$limit = 0;
foreach($rssFeed->find('item') as $element) {
if($limit < 15) {
$item = new \Item();
$item->title = LeJournalDuGeekStripCDATA($element->find('title', 0)->innertext);
$item->uri = LeJournalDuGeekStripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = LeJournalDuGeekExtractContent($item->uri);
$this->items[] = $item;
$limit++;
}
}
}
public function getName(){
return 'LeJournalDuGeek';
}
public function getURI(){
return 'http://www.journaldugeek.com/';
}
public function getCacheDuration(){
return 1800; // 30min
}
}