From caf9b43bb5ea17adc72797e6d6e2190e06a640ca Mon Sep 17 00:00:00 2001 From: Quentin de Longraye Date: Fri, 11 Jan 2019 22:25:33 +0100 Subject: [PATCH 1/5] add n26 blog bridge --- bridges/N26Bridge.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bridges/N26Bridge.php diff --git a/bridges/N26Bridge.php b/bridges/N26Bridge.php new file mode 100644 index 00000000000..abfc47b74b7 --- /dev/null +++ b/bridges/N26Bridge.php @@ -0,0 +1,35 @@ +find('div.ga') as $article) { + $item = []; + + $item['uri'] = self::URI . $article->find('h2 a', 0)->href; + $item['title'] = $article->find('h2 a', 0)->plaintext; + + $fullArticle = getSimpleHTMLDOM($item['uri']); + + $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); + $item['content'] = $fullArticle->find('main article', 0)->innertext; + + $this->items[] = $item; + } + } +} From fce4f9f4121af9a2cdd5e60e4ff67ed25ce5fd1c Mon Sep 17 00:00:00 2001 From: Quentin de Longraye Date: Fri, 11 Jan 2019 22:28:52 +0100 Subject: [PATCH 2/5] indent fixes --- bridges/N26Bridge.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bridges/N26Bridge.php b/bridges/N26Bridge.php index abfc47b74b7..fc78aaa164a 100644 --- a/bridges/N26Bridge.php +++ b/bridges/N26Bridge.php @@ -2,24 +2,24 @@ class N26Bridge extends BridgeAbstract { - const MAINTAINER = 'quentinus95'; - const NAME = 'N26 Blog'; - const URI = 'https://n26.com'; - const CACHE_TIMEOUT = 1800; - const DESCRIPTION = 'Returns recent blog posts from N26.'; + const MAINTAINER = 'quentinus95'; + const NAME = 'N26 Blog'; + const URI = 'https://n26.com'; + const CACHE_TIMEOUT = 1800; + const DESCRIPTION = 'Returns recent blog posts from N26.'; - public function getIcon() + public function getIcon() { - return 'https://n26.com/favicon.ico'; - } + return 'https://n26.com/favicon.ico'; + } - public function collectData() + public function collectData() { - $html = getSimpleHTMLDOM(self::URI . '/en-fr/blog-archive') - or returnServerError('Error while downloading the website content'); + $html = getSimpleHTMLDOM(self::URI . '/en-fr/blog-archive') + or returnServerError('Error while downloading the website content'); - foreach($html->find('div.ga') as $article) { - $item = []; + foreach($html->find('div.ga') as $article) { + $item = []; $item['uri'] = self::URI . $article->find('h2 a', 0)->href; $item['title'] = $article->find('h2 a', 0)->plaintext; @@ -27,9 +27,9 @@ public function collectData() $fullArticle = getSimpleHTMLDOM($item['uri']); $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); - $item['content'] = $fullArticle->find('main article', 0)->innertext; + $item['content'] = $fullArticle->find('main article', 0)->innertext; - $this->items[] = $item; - } - } + $this->items[] = $item; + } + } } From a10a38bd5690ce826b52b33dd0240941b04e37e7 Mon Sep 17 00:00:00 2001 From: Quentin de Longraye Date: Fri, 11 Jan 2019 22:30:28 +0100 Subject: [PATCH 3/5] =?UTF-8?q?use=20tabs=20instead=20of=20spaces=20?= =?UTF-8?q?=F0=9F=A4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/N26Bridge.php | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/bridges/N26Bridge.php b/bridges/N26Bridge.php index fc78aaa164a..a9a73d1e697 100644 --- a/bridges/N26Bridge.php +++ b/bridges/N26Bridge.php @@ -2,34 +2,34 @@ class N26Bridge extends BridgeAbstract { - const MAINTAINER = 'quentinus95'; - const NAME = 'N26 Blog'; - const URI = 'https://n26.com'; - const CACHE_TIMEOUT = 1800; - const DESCRIPTION = 'Returns recent blog posts from N26.'; + const MAINTAINER = 'quentinus95'; + const NAME = 'N26 Blog'; + const URI = 'https://n26.com'; + const CACHE_TIMEOUT = 1800; + const DESCRIPTION = 'Returns recent blog posts from N26.'; - public function getIcon() - { - return 'https://n26.com/favicon.ico'; - } + public function getIcon() + { + return 'https://n26.com/favicon.ico'; + } - public function collectData() - { - $html = getSimpleHTMLDOM(self::URI . '/en-fr/blog-archive') - or returnServerError('Error while downloading the website content'); + public function collectData() + { + $html = getSimpleHTMLDOM(self::URI . '/en-fr/blog-archive') + or returnServerError('Error while downloading the website content'); - foreach($html->find('div.ga') as $article) { - $item = []; + foreach($html->find('div.ga') as $article) { + $item = []; - $item['uri'] = self::URI . $article->find('h2 a', 0)->href; - $item['title'] = $article->find('h2 a', 0)->plaintext; + $item['uri'] = self::URI . $article->find('h2 a', 0)->href; + $item['title'] = $article->find('h2 a', 0)->plaintext; - $fullArticle = getSimpleHTMLDOM($item['uri']); + $fullArticle = getSimpleHTMLDOM($item['uri']); - $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); - $item['content'] = $fullArticle->find('main article', 0)->innertext; + $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); + $item['content'] = $fullArticle->find('main article', 0)->innertext; - $this->items[] = $item; - } - } + $this->items[] = $item; + } + } } From 58ec83ec688cbd2d2960edf91db30487db85b13b Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Sun, 13 Jan 2019 18:14:22 +0100 Subject: [PATCH 4/5] Return server error if full article download failed Co-Authored-By: quentinus95 --- bridges/N26Bridge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bridges/N26Bridge.php b/bridges/N26Bridge.php index a9a73d1e697..274767fd578 100644 --- a/bridges/N26Bridge.php +++ b/bridges/N26Bridge.php @@ -24,7 +24,8 @@ public function collectData() $item['uri'] = self::URI . $article->find('h2 a', 0)->href; $item['title'] = $article->find('h2 a', 0)->plaintext; - $fullArticle = getSimpleHTMLDOM($item['uri']); + $fullArticle = getSimpleHTMLDOM($item['uri']) + or returnServerError('Error while downloading the full article'); $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); $item['content'] = $fullArticle->find('main article', 0)->innertext; From 614dbb7c0e9219849f3275aa70460a0578db78f9 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Sun, 13 Jan 2019 18:15:13 +0100 Subject: [PATCH 5/5] Fix timestamp parsing Co-Authored-By: quentinus95 --- bridges/N26Bridge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bridges/N26Bridge.php b/bridges/N26Bridge.php index 274767fd578..dd1c423c88d 100644 --- a/bridges/N26Bridge.php +++ b/bridges/N26Bridge.php @@ -27,7 +27,8 @@ public function collectData() $fullArticle = getSimpleHTMLDOM($item['uri']) or returnServerError('Error while downloading the full article'); - $item['timestamp'] = strtotime($fullArticle->find('.fk.fl.de.ch.fm.by')); + $dateElement = $fullArticle->find('span[class="fk fl de ch fm by"]', 0); + $item['timestamp'] = strtotime($dateElement->plaintext); $item['content'] = $fullArticle->find('main article', 0)->innertext; $this->items[] = $item;