2016-03-22 22:51:55 +01:00
|
|
|
<?php
|
2016-09-05 18:43:56 +02:00
|
|
|
class LichessBridge extends FeedExpander {
|
2016-03-22 22:51:55 +01:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = 'AmauryCarrade';
|
|
|
|
const NAME = 'Lichess Blog';
|
|
|
|
const URI = 'http://fr.lichess.org/blog';
|
|
|
|
const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)';
|
2016-03-22 22:51:55 +01:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
public function collectData(){
|
2016-09-05 20:26:45 +02:00
|
|
|
$this->collectExpandableDatas(self::URI . '.atom', 5);
|
2016-03-22 22:51:55 +01:00
|
|
|
}
|
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
protected function parseItem($newsItem){
|
2016-09-12 10:42:27 +02:00
|
|
|
$item = parent::parseItem($newsItem);
|
2016-09-05 18:43:56 +02:00
|
|
|
$item['content'] = $this->retrieve_lichess_post($item['uri']);
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function retrieve_lichess_post($blog_post_uri){
|
2016-09-10 19:11:09 +02:00
|
|
|
$blog_post_html = $this->getSimpleHTMLDOMCached($blog_post_uri);
|
2016-03-22 22:51:55 +01:00
|
|
|
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
|
|
|
|
|
|
|
|
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
|
|
|
|
$post_content = $blog_post_div->find('.body', 0)->innertext;
|
|
|
|
|
|
|
|
$content = '<p><em>' . $post_chapo . '</em></p>';
|
|
|
|
$content .= '<div>' . $post_content . '</div>';
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
}
|