LichessBridge.php 941 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class LichessBridge extends FeedExpander {
  3. const MAINTAINER = 'AmauryCarrade';
  4. const NAME = 'Lichess Blog';
  5. const URI = 'http://fr.lichess.org/blog';
  6. const DESCRIPTION = 'Returns the 5 newest posts from the Lichess blog (full text)';
  7. public function collectData(){
  8. $this->collectExpandableDatas(self::URI . '.atom', 5);
  9. }
  10. protected function parseItem($newsItem){
  11. $item = parent::parseItem($newsItem);
  12. $item['content'] = $this->retrieveLichessPost($item['uri']);
  13. return $item;
  14. }
  15. private function retrieveLichessPost($blog_post_uri){
  16. $blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
  17. $blog_post_div = $blog_post_html->find('#lichess_blog', 0);
  18. $post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
  19. $post_content = $blog_post_div->find('.body', 0)->innertext;
  20. $content = '<p><em>' . $post_chapo . '</em></p>';
  21. $content .= '<div>' . $post_content . '</div>';
  22. return $content;
  23. }
  24. }