From b4581418d4aad714315d5d14274edf011806b3b5 Mon Sep 17 00:00:00 2001 From: Nicolas Delsaux Date: Thu, 3 Oct 2019 22:30:22 +0200 Subject: [PATCH] [PlantUMLBridge] Added bridge for PlantUML. Fixes #1191 * Fixes #1191 by implementing the RSS feed of PlantUML releases --- bridges/PlantUMLReleasesBridge.php | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 bridges/PlantUMLReleasesBridge.php diff --git a/bridges/PlantUMLReleasesBridge.php b/bridges/PlantUMLReleasesBridge.php new file mode 100644 index 00000000..66480560 --- /dev/null +++ b/bridges/PlantUMLReleasesBridge.php @@ -0,0 +1,67 @@ + 'href', + 'src' => 'src', + 'data-original' => 'src' + ); + + private function getDomain() { + $domain = $this->getInput('domain'); + if (empty($domain)) + $domain = self::DEFAULT_DOMAIN; + if (strpos($domain, '://') === false) + $domain = 'https://' . $domain; + return $domain; + } + + public function getURI() + { + return self::URI; + } + + public function collectData() + { + $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request ' . $this->getURI()); + + // Since GQ don't want simple class scrapping, let's do it the hard way and ... discover content ! + $main = $html->find('div[id=root]', 0); + foreach ($main->find('h2') as $release) { + $item = array(); + $item['author'] = self::AUTHOR; + $release_text = $release->innertext; + if (preg_match('/(.+) \((.*)\)/', $release_text, $matches)) { + $item['title'] = $matches[1]; + // And now, build the date from the date text + $item['timestamp'] = strtotime($matches[2]); + } + $item['uri'] = $this->getURI(); + $item['content'] = $release->next_sibling (); + $this->items[] = $item; + } + } +}