From dc36b425cd8c8b67f87dc822a2f6dd80792d4705 Mon Sep 17 00:00:00 2001 From: Joseph Date: Wed, 12 Aug 2020 18:07:53 +0000 Subject: [PATCH] [DevToBridge] Fix bridge (#1699) Fixes full article option not working --- bridges/DevToBridge.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bridges/DevToBridge.php b/bridges/DevToBridge.php index c298d462..def7e76a 100644 --- a/bridges/DevToBridge.php +++ b/bridges/DevToBridge.php @@ -45,24 +45,22 @@ apple-icon-5c6fa9f2bce280428589c6195b7f1924206a53b782b371cfe2d02da932c8c173.png' } public function collectData() { - $html = getSimpleHTMLDOMCached($this->getURI()) or returnServerError('Could not request ' . $this->getURI()); $html = defaultLinkTo($html, static::URI); - $articles = $html->find('div.single-article') + $articles = $html->find('div.crayons-story') or returnServerError('Could not find articles!'); foreach($articles as $article) { $item = array(); $item['uri'] = $article->find('a[id*=article-link]', 0)->href; - $item['title'] = $article->find('h3', 0)->plaintext; + $item['title'] = $article->find('h2 > a', 0)->plaintext; - // i.e. "Charlie Harrington・Sep 21" - $item['timestamp'] = strtotime(explode('・', $article->find('h4 a', 0)->plaintext, 2)[1]); - $item['author'] = explode('・', $article->find('h4 a', 0)->plaintext, 2)[0]; + $item['timestamp'] = $article->find('time', 0)->datetime; + $item['author'] = $article->find('a.crayons-story__secondary.fw-medium', 0)->plaintext; // Profile image $item['enclosures'] = array($article->find('img', 0)->src); @@ -70,7 +68,6 @@ apple-icon-5c6fa9f2bce280428589c6195b7f1924206a53b782b371cfe2d02da932c8c173.png' if($this->getInput('full')) { $fullArticle = $this->getFullArticle($item['uri']); $item['content'] = <<

{$fullArticle}

EOD; } else { @@ -80,11 +77,13 @@ EOD; EOD; } - $item['categories'] = array_map(function($e){ return $e->plaintext; }, $article->find('div.tags span.tag')); + // categories + foreach ($article->find('a.crayons-tag') as $tag) { + $item['categories'][] = str_replace('#', '', $tag->plaintext); + } $this->items[] = $item; } - } public function getName() { @@ -101,6 +100,10 @@ EOD; $html = defaultLinkTo($html, static::URI); + if ($html->find('div.crayons-article__cover', 0)) { + return $html->find('div.crayons-article__cover', 0) . $html->find('[id="article-body"]', 0); + } + return $html->find('[id="article-body"]', 0); } }