From 8c18c02c65042add22ef783e0f52a0483f3ffcb3 Mon Sep 17 00:00:00 2001 From: Corentin Garcia Date: Fri, 8 Apr 2022 21:21:13 +0200 Subject: [PATCH] [GatesNotesBridge] Add feedaxpander bridge for Bill Gate's blog (fix issue #2386) (#2611) --- bridges/GatesNotesBridge.php | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 bridges/GatesNotesBridge.php diff --git a/bridges/GatesNotesBridge.php b/bridges/GatesNotesBridge.php new file mode 100644 index 00000000..bf456d26 --- /dev/null +++ b/bridges/GatesNotesBridge.php @@ -0,0 +1,54 @@ +Could not request ' . $this->getName() . ': ' . $item['uri'] . '

'; + return $item; + } + $article_html = defaultLinkTo($article_html, $this->getURI()); + + $top_description = '

' . $article_html->find('div.article_top_description', 0)->innertext . '

'; + $hero_image = 'getAttribute('data-src') . '>'; + + $article_body = $article_html->find('div.TGN_Article_ReadTimeSection', 0); + // Convert iframe of Youtube videos to link + foreach($article_body->find('iframe') as $found) { + + $iframeUrl = $found->getAttribute('src'); + + if ($iframeUrl) { + $text = 'Embedded Youtube video, click here to watch on Youtube.com'; + $found->outertext = '

' . $text . '

'; + } + } + // Remove CSS ressources + foreach($article_body->find('link') as $found) { + + $linkedRessourceUrl = $found->getAttribute('href'); + + if (str_ends_with($linkedRessourceUrl, '.css')) { + $found->outertext = ''; + } + } + $article_body = sanitize($article_body->innertext); + + $item['content'] = $top_description . $hero_image . $article_body; + + return $item; + } + + public function collectData(){ + $feed = static::URI . '/rss'; + $this->collectExpandableDatas($feed); + } +}